Superstar X V2
Superstar X V2
indicator("Trend Signals with TP & SL [SUPERSTAR X V1]", shorttitle = "Trend Signals with TP & SL
[SUPERSTAR X V1]", overlay = true)
src = input(hl2, title="Source", group = "Trend Continuation Signals with TP & SL")
Multiplier = input.float(2, title="Sensitivity (0.5 - 5)", step=0.1, defval=2, minval=0.5, maxval=5, group
= "Trend Continuation Signals with TP & SL")
atrPeriods = input.int(14, title="ATR Length", defval=10, group = "Trend Continuation Signals with TP
& SL")
cloud_val = input.int(10, title="Cloud Moving Average Length", defval = 10, minval = 5, maxval = 500,
group = "Trend Continuation Signals with TP & SL")
stopLossVal = input.float(2.0, title="Stop Loss Percent (0 for Disabling)", minval=0, group = "Trend
Continuation Signals with TP & SL")
// Calculations
momm1 = ta.change(src1)
momm2 = ta.change(src2)
m1 = f1(momm1, momm2)
m2 = f2(momm1, momm2)
sm1 = math.sum(m1, 1)
sm2 = math.sum(m2, 1)
cmoCalc = percent(sm1 - sm2, sm1 + sm2)
hh = ta.highest(2)
h1 = ta.dev(hh, 2) ? na : hh
hpivot = fixnan(h1)
ll = ta.lowest(2)
l1 = ta.dev(ll, 2) ? na : ll
lpivot = fixnan(l1)
rsiCalc = ta.rsi(close, 9)
lowPivot = lpivot
highPivot = hpivot
trend = 1
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
takeProfitForLong2R = entryOfLongPosition * (1 + sl * 2)
takeProfitForShort2R = entryOfShortPosition * (1 - sl * 2)
takeProfitForLong3R = entryOfLongPosition * (1 + sl * 3)
takeProfitForShort3R = entryOfShortPosition * (1 - sl * 3)
pos := 0
lindex = ta.valuewhen(longCond, bar_index, 0)
// Only create a line and label if we are entering a trade and it doesn't already exist
line.delete(entryLine)
line.delete(stopLine)
line.delete(tpLine1)
line.delete(tpLine2)
line.delete(tpLine3)
label.delete(labelEntry)
label.delete(labelStop)
label.delete(labelTp1)
label.delete(labelTp2)
label.delete(labelTp3)
entryLine := line.new(bar_index, pos > 0 ? entryOfLongPosition : entryOfShortPosition, pos > 0 ?
lindex : sindex, pos > 0 ? entryOfLongPosition : entryOfShortPosition, color=entryColor)
//