not sure about the conversation since I didnt test it.can some plz look and see if anyone can convert this to Thinkorswim ?
CSS:
#//@version=4
#strategy("ππππππ πππππππ", overlay=true,
# Converted by Sam4Cok@Samer800 - Need to be tested - 11/2022
input alternatesignals = yes; #"Alternate Signals",
input ShowWeakSignals = no;
input ShowCloud = yes;
def na = Double.NaN; def c = close; def h = high; def l = low; def o = open; def v = volume;
def price = ohlc4; # "Close Line"
#//TREND INDICATORSβΌβΌβΌβΌβΌβΌβΌ
#//Trend EMA
#tttradetrend = "Only place BUY or SELL orders with the direction of the Trend EMA."
input tradeTrendOption = no; # "Only Tade with Trend"
input len111 = 200; # "Trend EMA Length"
def src111 = close;
def out111 = ExpAverage(src111, len111);
def ma111 = out111; # "EMA 200"
def mabuy = out111 > out111[1];
def masell = out111 < out111[1];
#//5 EMAs/////////////////////////////////////////////////////////////////////
def len1 = 9;
def src1 = close;
def out1 = ExpAverage(src1, len1);
def ema1color = if out1 > out1[1] then 1 else 0;# #00bcd4 : #
def ema1 = out1;#, title="EMA 9", linewidth=3, color=color.new(ema1color, 50), offset=0,
AddCloud(if ShowCloud then price else na, out1, CreateColor(0,53,60), CreateColor(100,10,41));#title="EMA 9 Fill", color=color.new(ema1color, 90), editable=true)
def len2 = 21;
def src2 = close;
def out2 = ExpAverage(src2, len2);
def ema2color = if out2 > out2[1] then 1 else 0; #00bcd4 : #e91e63)
def ema2 = out2;#, title="EMA 21", linewidth=3, color=color.new(ema2color, 50),
AddCloud(if ShowCloud then price else na, ema2, CreateColor(0,53,60), CreateColor(100,10,41));
def len3 = 55;
def src3 = close;
def out3 = ExpAverage(src3, len3);
def ema3color = if out3 > out3[1] then 1 else 0; #00bcd4 : #e91e63)
def ema3 = out3;#, title="EMA 55", linewidth=3, color=color.new(ema3color, 50), off
AddCloud(if ShowCloud then price else na, out3, CreateColor(0,53,60), CreateColor(100,10,41));
def len4 = 100;
def src4 = close;
def out4 = ExpAverage(src4, len4);
def ema4color = if out4 > out4[1] then 1 else 0; #00bcd4 : #e91e63)
def ema4 = out4;#, title="EMA 100", linewidth=3, color=color.new(ema4color, 50),
AddCloud(if ShowCloud then price else na, out4, CreateColor(0,53,60), CreateColor(100,10,41));
def len5 = 200;
def src5 = close;
def out5 = ExpAverage(src5, len5);
def ema5color = if out5 > out5[1] then 1 else 0; #00bcd4 : #e91e63)
def ema5 = out5;#, title="EMA 200", linewidth=3, color=color.new(ema5color, 50),
AddCloud(if ShowCloud then price else na, out5, CreateColor(0,53,60), CreateColor(100,10,41));
#//Supertrend////////////////////////////////////////////////////////////////////
#Supertrend(Source, AtrMult, atrPeriod, ChangeATR);
script supertrend {
input Source = hl2;
input AtrMult = 1;
input atrPeriod = 10;
input changeATR = yes;
def ATR = if changeATR then ATR(atrPeriod) else SimpleMovingAvg(TrueRange(high, close, low), atrPeriod);
def UP = Source + (AtrMult * ATR);
def LW = Source - (AtrMult * ATR);
def UP_Band = if ((UP < UP_Band[1]) or (close[1] > UP_Band[1])) then UP else UP_Band[1];
def LW_Band = if ((LW > LW_Band[1]) or (close[1] < LW_Band[1])) then LW else LW_Band[1];
def ST = if ((ST[1] == UP_Band[1]) and (close < UP_Band)) then UP_Band
else if ((ST[1] == UP_Band[1]) and (close > UP_Band)) then LW_Band
else if ((ST[1] == LW_Band[1]) and (close > LW_Band)) then LW_Band
else if ((ST[1] == LW_Band) and (close < LW_Band)) then UP_Band
else LW_Band;
plot Super = ST;
}
input changeATR = yes;
def atrPeriod = 10;
def factor = 3;
def ST = supertrend(c, factor, atrPeriod, changeATR);
def uptrend = c > ST;
def downtrend = c < ST;
def LongTrigger = !uptrend[1] and uptrend;
def ShortTrigger = !downtrend[1] and downtrend;
#//HMA////////////////////////////////
def len6 = 100;
def src6 = close;
def hma = WMA(2 * WMA(src6, len6 / 2) - WMA(src6, len6), Floor(Sqrt(len6)));
def hmacolor = if c > hma then 1 else 0; #00bcd4 : #e91e63
plot MAhma = hma;#, title="HMA Line", color=color.new(hmacolor, 25), linewidth=5)
MAhma.AssignValueColor(if hmacolor then CreateColor(0, 188, 212) else CreateColor(233, 30, 99));
MAhma.SetLineWeight(2);
#//Parabolic SAR///////////////////////////////////////////////////////////
def start = 0.02;
def maximum = 0.2;
def psar = ParabolicSAR(start, maximum);
#//Bollinger Bands///////////////
def length1 = 20;
def src7 = close;
def mult1 = 2.0;
def basis = SimpleMovingAvg(src7, length1);
def dev = mult1 * StDev(src7, length1);
def upper = basis + dev;
def lower = basis - dev;
#//Average True Range ////////////////////////////////
def length2 = 1;
def mult2 = 1.85;
def natr = mult2 * ATR(length = length2);
def longStop1 = Highest(h, length2) - natr;
def longStopPrev = If(IsNaN(longStop1[1]), longStop1, longStop1[1]);
def longStop = If(c[1] > longStopPrev, Max(longStop1, longStopPrev), longStop[1]);
def shortStop1 = Lowest(l, length2) + natr;
def shortStopPrev = If(IsNaN(shortStop1[1]), shortStop1, shortStop1[1]);
def shortStop = If(c[1] < shortStopPrev, Min(shortStop1, shortStopPrev), shortStop[1]);
#var int dir = 1
def dir = if dir[1] == 0 then 1 else
if c > shortStopPrev then 1 else if c < longStopPrev then -1 else dir[1];
def buySignal = dir == 1 and dir[1] == -1;
def sellSignal = dir == -1 and dir[1] == 1;
#//Chaikin Money Flow////////
def length19 = 50;
def ad19 = If(c == h and c == l or h == l, 0, ((2 * c - l - h) / (h - l)) * v);
def cmf = Sum(ad19, length19) / Sum(v, length19);
#//VWAP////////
def _vwap = vwap;
def vwapValue = _vwap;
#//Candle Patterns/////////////
#//Bullish Engulfing
def priceAvg = SimpleMovingAvg(c, 50);
def C_DownTrend = c < priceAvg;
def C_UpTrend = c > priceAvg;
def C_Len = 14;
def C_ShadowPercent = 5.0;
def C_ShadowEqualsPercent = 100.0;
def C_DojiBodyPercent = 5.0;
def C_Factor = 2.0;
def C_BodyHi = Max(c, o);
def C_BodyLo = Min(c, o);
def C_Body = C_BodyHi - C_BodyLo;
def C_BodyAvg = ExpAverage(C_Body, C_Len);
def C_SmallBody = C_Body < C_BodyAvg;
def C_LongBody = C_Body > C_BodyAvg;
def C_UpShadow = h - C_BodyHi;
def C_DnShadow = C_BodyLo - l;
def C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body;
def C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body;
def C_WhiteBody = o < c;
def C_BlackBody = o > c;
def C_Range = h - l;
def C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo;
def C_BodyMiddle = C_Body / 2 + C_BodyLo;
def C_ShadowEquals = C_UpShadow == C_DnShadow or (AbsValue(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (AbsValue(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent;
def C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100;
def C_Doji = C_IsDojiBody and C_ShadowEquals;
def patternLabelPosLow = l - (ATR(Length=30) * 0.6);
def patternLabelPosHigh = h + (ATR(Length=30) * 0.6);
def C_EngulfingBullishNumberOfCandles = 2;
def C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and C_SmallBody[1] and c >= o[1] and o <= c[1] and ( c > o[1] or o < c[1] );
#//Bearish Engulfing
def C_EngulfingBearishNumberOfCandles = 2;
def C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and C_SmallBody[1] and c <= o[1] and o >= c[1] and (c < o[1] or o > c[1] );
#//plot(psar, "ParabolicSAR", style=plot.style_circles, color=#ffffff)
# stoch(source, high, low, length) =>
script stoch {
input src = close;
input h = high;
input l = low;
input len = 0;
def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
plot return = stoch;
}
script FindPivots {
input dat = close; # default data or study being evaluated
input HL = 0; # default high or low pivot designation, -1 low, +1 high
input lbL = 5; # default Pivot Lookback Left
input lbR = 1; # default Pivot Lookback Right
##############
def _nan; # used for non-number returns
def _BN; # the current barnumber
def _VStop; # confirms that the lookforward period continues the pivot trend
def _V; # the Value at the actual pivot point
##############
_BN = BarNumber();
_nan = Double.NaN;
_VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
fold a = 1 to lbR + 1 with b=1 while b do
if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
if (HL > 0) {
_V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
then dat else _nan;
} else {
_V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
then dat else _nan;
}
plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#valuewhen (Cond, source, lbr, occurrence)
script valuewhen {
input cond = 0;
input src = close;
input lbr = 0;
input occurrence = 0;
def n = occurrence + 1;
def offset = fold j = 0 to 200 with p=1 while p < n + 1
do p + ( if p == n then j - n else if cond[j] == yes then 1 else 0 );
plot price = GetValue(src[lbr], offset - 1);
}
#_inRange(cond) =>
script _inRange {
input cond = yes;
input rangeUpper = 60;
input rangeLower = 5;
def bars = if cond then 0 else bars[1] + 1;
def inrange = (rangeLower <= bars) and (bars <= rangeUpper);
plot retrun = inrange;
}
#Div(source, lbl, lbr, MaxLookback, MinLookback, DivBull = yes, DivBear = yes, DivHiddenBull=no, DivHiddenBear=no),
script Div {
input divSrc = close;
input lbl = 5;
input lbr = 5;
input MaxLookback = 60;
input MinLookback = 5;
input DivBull = yes;
input DivBear = yes;
input DivHiddenBull = no;
input DivHiddenBear = no;
def h = high;
def l = low;
def pl = findpivots(divSrc, -1, lbl, lbr);
def ph = findpivots(divSrc, 1, lbl, lbr);
def plFound = if !IsNaN(pl) then 1 else 0;
def phFound = if !IsNaN(ph) then 1 else 0;
def vlFound = valuewhen(plFound, divSrc, 0, 1);
def vhFound = valuewhen(phFound, divSrc, 0, 1);
def plPrice = valuewhen(plFound, l, 0, 1);
def phPrice = valuewhen(phFound, h, 0, 1);
#// Regular Bullish
def oscHL = divSrc > vlFound and _inRange(plFound[1], MaxLookback, MinLookback);
def priceLL = l < plPrice;
def bullCond = DivBull and plFound and oscHL and priceLL;
#// Regular Bearish
def oscLH = divSrc < vhFound and _inRange(phFound[1], MaxLookback, MinLookback);
def priceHH = h > phPrice;
def bearCond = DivBear and phFound and oscLH and priceHH;
plot BullDiv = if bullCond then 1 else 0;
plot BearDiv = if bearCond then 1 else 0;
}
#//MOMENTUM INCIDATORS
#//RSI Divergence/////////////////////////
def len11 = 14;
def src11 = close;
def lbR11 = 2;
def lbL11 = 6;
def rangeUpper11 = 60;
def rangeLower11 = 5;
def osc11 = RSI(price = src11, Length = len11);
#---- Div
def bullCond = DIV(osc11, lbL11, lbR11, rangeUpper11, rangeLower11).BullDiv;
def bearCond = DIV(osc11, lbL11, lbR11, rangeUpper11, rangeLower11).BearDiv;
def bullCond11 = if bullCond then 1 else 0;
def bearCond11 = if bearCond then 1 else 0;
#//MACD Divergence//////////////////////////////////////////////////
def fast_length12 = 12;
def slow_length12 = 26;
def src12 = close;
def signal_length12 = 9;
#//Calculating
def fast_ma12 = ExpAverage(src12, fast_length12);
def slow_ma12 = ExpAverage(src12, slow_length12);
def macd = fast_ma12 - slow_ma12;
def signal = ExpAverage(macd, signal_length12);
def hist = macd - signal;
#donttouchzero12 = true
def lbR12 = 2;
def lbL12 = 6;
def rangeUpper12 = 60;
def rangeLower12 = 5;
def osc12 = macd;
def priceHHZero12 = Highest(osc12, lbL12 + lbR12 + 5);
def blowzero12 = priceHHZero12 < 0;
def priceLLZero12 = Lowest(osc12, lbL12 + lbR12 + 5);
def bearzero12 = priceLLZero12 > 0;
#---- Div
def bullCond2 = DIV(osc12, lbL12, lbR12, rangeUpper12, rangeLower12).BullDiv;
def bearCond2 = DIV(osc12, lbL12, lbR12, rangeUpper12, rangeLower12).BearDiv;
def bullCond12 = if bullCond2 and blowzero12 then 1 else 0;
def bearCond12 = if bearCond2 and bearzero12 then 1 else 0;
#//Wave Trend Divergence//////////////////////
def n1 = 9;
def n2 = 12;
def ap = hlc3 ;
def esa = ExpAverage(ap, n1);
def d1 = ExpAverage(AbsValue(ap - esa), n1);
def ci = (ap - esa) / (0.015 * d1);
def tci = ExpAverage(ci, n2);
#hline = 0
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 4);
def osc13 = tci;
#//Divergence
def lbR13 = 2;
def lbL13 = 6;
def rangeUpper13 = 60;
def rangeLower13 = 5;
#---- Div
def bullCond3 = DIV(osc13, lbL13, lbR13, rangeUpper13, rangeLower13).BullDiv;
def bearCond3 = DIV(osc13, lbL13, lbR13, rangeUpper13, rangeLower13).BearDiv;
def bullCond13 = if bullCond3 then 1 else 0;
def bearCond13 = if bearCond3 then 1 else 0;
#//Stochastic Divergence///////////////
def periodK14 = 14;
def smoothK14 = 3;
def periodD14 = 3;
def k14 = SimpleMovingAvg(stoch(c, h, l, periodK14), smoothK14);
def d14 = simpleMovingAvg(k14, periodD14);
#//Divergence
def lbR14 = 2;
def lbL14 = 6;
def rangeUpper14 = 60;
def rangeLower14 = 5;
def osc14 = k14;
#---- Div
def bullCond4 = DIV(osc14, lbL14, lbR14, rangeUpper14, rangeLower14).BullDiv;
def bearCond4 = DIV(osc14, lbL14, lbR14, rangeUpper14, rangeLower14).BearDiv;
def bullCond14 = if bullCond4 then 1 else 0;
def bearCond14 = if bearCond4 then 1 else 0;
#//Relative Volatility Index Divergence////////
def length15 = 12;
def src15 = close;
def len15 = 14;
def stddev15 = StDev(src15, length15);
def upper15 = ExpAverage(if (src15 - src15[1]) <= 0 then 0 else stddev15, len15);
def lower15 = ExpAverage(if (src15 - src15[1]) > 0 then 0 else stddev15, len15);
def rvi = upper15 / (upper15 + lower15) * 100;
#//Divergence
def lbR15 = 2;
def lbL15 = 6;
def rangeUpper15 = 60;
def rangeLower15 = 5;
def osc15 = rvi;
#---- Div
def bullCond5 = DIV(osc15, lbL15, lbR15, rangeUpper15, rangeLower15).BullDiv;
def bearCond5 = DIV(osc15, lbL15, lbR15, rangeUpper15, rangeLower15).BearDiv;
def bullCond15 = if bullCond5 then 1 else 0;
def bearCond15 = if bearCond5 then 1 else 0;
#//OBV Divergence/////////////////////////////////////////
def len18 = 20;
def src18 = close;
def csrc = src18 - src18[1];
def os = TotalSum(if csrc > 0 then v else if csrc < 0 then -v else 0);
def obv = (os - ExpAverage(os, len18));
#//Divergence
def lbR18 = 2;
def lbL18 = 6;
def rangeUpper18 = 60;
def rangeLower18 = 5;
def osc18 = obv;
#---- Div
def bullCond8 = DIV(osc18, lbL18, lbR18, rangeUpper18, rangeLower18).BullDiv;
def bearCond8 = DIV(osc18, lbL18, lbR18, rangeUpper18, rangeLower18).BearDiv;
def bullCond18 = if bullCond8 then 1 else 0;
def bearCond18 = if bearCond8 then 1 else 0;
#//Support and Resistance///////////////////////
def left16 = 200;
def right16 = 20;
def quick_right16 = 5;
#def src16 = yes;
def phc = findpivots(c, 1, left16, right16);
def plc = findpivots(c, -1, left16, right16);
def phc16 = findpivots(c, 1, left16, quick_right16);
def plc16 = findpivots(c, -1, left16, quick_right16);
def pivot_high16 = If(!IsNaN(phc), 1, na);
def pivot_lows16 = If(!IsNaN(plc), 1, na);
def quick_pivot_high16 = If(!IsNaN(phc16), 1, na);
def quick_pivot_lows16 = If(!IsNaN(plc16), 1, na);
def level1 = valuewhen(!isNaN(quick_pivot_high16), c,quick_right16, 0);
def level2 = valuewhen(!isNaN(quick_pivot_lows16), c,quick_right16, 0);
def level3 = valuewhen(!isNaN(pivot_high16), c,right16, 0);
def level4 = valuewhen(!isNaN(pivot_lows16), c,right16, 0);
def level5 = valuewhen(!isNaN(pivot_high16), c,right16, 1);
def level6 = valuewhen(!isNaN(pivot_lows16), c,right16, 1);
def level7 = valuewhen(!isNaN(pivot_high16), c,right16, 2);
def level8 = valuewhen(!isNaN(pivot_lows16), c,right16, 2);
def length17 = 9;
def src17 = close;
def hma17 = WMA(2 * WMA(src17, length17 / 2) - WMA(src17, length17), Floor(Sqrt(length17)));
def buy1 = hma17 > level1 and hma17[1] < level1[1] and c > c[2];
def buy2 = hma17 > level2 and hma17[1] < level2[1] and c > c[2];
def buy3 = hma17 > level3 and hma17[1] < level3[1] and c > c[2];
def buy4 = hma17 > level4 and hma17[1] < level4[1] and c > c[2];
def buy5 = hma17 > level5 and hma17[1] < level5[1] and c > c[2];
def buy6 = hma17 > level6 and hma17[1] < level6[1] and c > c[2];
def buy7 = hma17 > level7 and hma17[1] < level7[1] and c > c[2];
def buy8 = hma17 > level8 and hma17[1] < level8[1] and c > c[2];
def sell1 = hma17 < level1 and hma17[1] > level1[1] and c < c[2];
def sell2 = hma17 < level2 and hma17[1] > level2[1] and c < c[2];
def sell3 = hma17 < level3 and hma17[1] > level3[1] and c < c[2];
def sell4 = hma17 < level4 and hma17[1] > level4[1] and c < c[2];
def sell5 = hma17 < level5 and hma17[1] > level5[1] and c < c[2];
def sell6 = hma17 < level6 and hma17[1] > level6[1] and c < c[2];
def sell7 = hma17 < level7 and hma17[1] > level7[1] and c < c[2];
def sell8 = hma17 < level8 and hma17[1] > level8[1] and c < c[2];
#//SIGNAL SCORES
#//Alternate Signals Option
#//Score Requirements
input strongLongScore = 10;#, minval=0, maxval=1000, title="Required Strong LONG Score")
input strongShortScore = 10;#, minval=0, maxval=1000, title="Required Strong SHORT Score")
input weakLongScore = 8;#, minval=0, maxval=1000, title="Required Weak LONG Score")
input weakShortScore = 8;#, minval=0, maxval=1000, title="Required Weak SHORT Score")
#//Trend Indicator Signals//////////////////////////////////////////
#//EMA Signals
input emaDirectionImportance = 2; # "EMA Trend Direction Importance")
def emadirectionup = if out5 < c then emadirectionimportance else 0;
#emadirectionupstatus = emadirectionup ? "EMA Trend Direction Up" : na
def emadirectiondown = if out5 > c then emadirectionimportance else 0;
#emadirectiondownstatus = emadirectiondown ? "EMA Trend Direction Down" : na
input emaPushPullImportance = 2; # "EMA Pressure Importance")
def emapushup = if out2 > out2[1] and out3 < out3[1] then emapushpullimportance else 0;
#emapushupstatus = emapushup ? "EMA Pushing Up" : na
def emapulldown = If(out2 < out2[1] and out3 > out3[1], emapushpullimportance, 0);
#emapulldownstatus = emapulldown ? "EMA Pulling Down" : na
#//Super Trend Signals
def supertrendDirImportance = 0; # "SuperTrend Direction Importance")
def supertrendup = If(uptrend, supertrenddirimportance, 0);
def supertrenddown = If(downtrend, supertrenddirimportance, 0);
input supertrendRevImportance = 4;#, minval=0, maxval=100, title="SuperTrend Reversal Importance")
def supertrendrevup = If(LongTrigger, supertrendrevimportance, 0);
def supertrendrevdown = If(ShortTrigger, supertrendrevimportance, 0);
#/Parabolic SAR Signals
def psarDirImportance = 0;#, minval=0, maxval=100, title="Parabolic SAR Direction Importance")
def psardirup = If(psar < c, psardirimportance, 0);
def psardirdown = If(psar > c, psardirimportance, 0);
input psarRevImportance = 3;#00, title="Parabolic SAR Reversal Importance")
def psarrevup = If(psar < c and psar[1] > c[1], psarrevimportance, 0);
def psarrevdown = If(psar > c and psar[1] < c, psarrevimportance, 0);
#//HMA Signals
input hmaClosePosImportance = 1;#, title="HMA Trend Direction Importance")
def hmacloseposup = If(hma < c, hmacloseposimportance, 0);
def hmacloseposdown = If(hma > c, hmacloseposimportance, 0);
input hmaPivotImportance = 3;#100, title="HMA Pivot Importance")
def hmapivotup = If(hma > hma[1] and hma[1] < hma[2], hmapivotimportance, 0);
def hmapivotdown = If(hma < hma[1] and hma[1] > hma[2], hmapivotimportance, 0);
#//Momentum Indicator Signals////////
#//RSI Signals
input rsiDivImportance = 4;#tle="RSI Divergence Importance")
def rsidivup = If(bullCond11 or bullCond11[1] or bullCond11[2], rsidivimportance, 0);
def rsidivdown = If(bearCond11 or bearCond11[1] or bearCond11[2], rsidivimportance, 0);
input rsiLevelImportance = 0;# title="RSI Level Importance")
def rsioversold = If(osc11 < 30, rsilevelimportance, 0);
def rsioverbought = If(osc11 > 70, rsilevelimportance, 0);
input rsiDirectionImportance = 1;# title="RSI Cross 50-Line Importance")
def rsicrossup = If((osc11 > 50 and osc11[1] < 50) or (osc11 > 50 and osc11[2] < 50), rsidirectionimportance, 0);
def rsicrossdown = If((osc11 < 50 and osc11[1] > 50) or (osc11 < 50 and osc11[2] > 50), rsidirectionimportance, 0);
#//MACD Signals
input macdDivImportance = 0;# minval=0, maxval=100, title="MACD Divergence Importance")
def macddivup = If(bullCond12 or bullCond12[1] or bullCond12[2], macddivimportance, 0);
def macddivdown = If(bearCond12 or bearCond12[1] or bearCond12[2], macddivimportance, 0);
input histPivotImportance = 1;#100, title="MACD Histogram Pivot Importance")
def histpivotup = If(hist > hist[1] and hist[1] < hist[2] and hist < 0, histpivotimportance, 0);
def histpivotdown = If(hist < hist[1] and hist[1] > hist[2] and hist > 0, histpivotimportance, 0);
input macdCrossSignalImportance = 1;#title="MACD Cross Signal Importance")
def macdcrosssignalup = If(macd > signal and macd[1] < signal[1] and signal < 0, macdCrossSignalImportance, 0);
def macdcrosssignaldown = If(macd < signal and macd[1] > signal[1] and signal > 0, macdCrossSignalImportance, 0);
#//WaveTrend Signals
input wtDivImportance = 0;# title="WaveTrend Divergence Importance")
def wtdivup = If(bullCond13 or bullCond13[1] or bullCond13[2], wtDivImportance, 0);
def wtdivdown = If(bearCond13 or bearCond13[1] or bearCond13[2], wtDivImportance, 0);
input wtCrossSignalImportance = 4;#le="WaveTrend Cross Signal Importance")
def wtcrosssignalup = If(wt1 > wt2 and wt1[1] < wt2[1] and wt2 < -10, wtCrossSignalImportance, 0);
def wtcrosssignaldown = If(wt1 < wt2 and wt1[1] > wt2[1] and wt2 > 10, wtCrossSignalImportance, 0);
#//Stochastic Signals
input sDivImportance = 1;#="Stochastic Divergence Importance")
def sdivup = If(bullCond14 or bullCond14[1] or bullCond14[2], sDivImportance, 0);
def sdivdown = If(bearCond14 or bearCond14[1] or bearCond14[2], sDivImportance, 0);
input sCrossSignalImportance = 1;#title="Stoch Cross Signal Importance")
def scrosssignalup = If(k14 > d14 and k14[1] < d14[1], sCrossSignalImportance, 0);
def scrosssignaldown = If(k14 < d14 and k14[1] > d14[1], sCrossSignalImportance, 0);
#//Volatility Indicators/////////////////////////////////////////////////////////
#//Bollinger Bands Signals
input bbContImportance = 0;#="BollingerBands Contact Importance")
def bbcontup = If(c < lower, bbContImportance, 0);
def bbcontdown = If(o > upper, bbContImportance, 0);
#//Average True Range Signals
input atrRevImportance = 1;#e="ATR Reversal Importance")
def atrrevup = If(buySignal, atrRevImportance, 0);
def atrrevdown = If(sellSignal, atrRevImportance, 0);
#//Relative Volatility Index Signals
input rviPosImportance = 3;#00, title="RVI Position Importance")
def rviposup = If(rvi > 25 and rvi[1] < 40, rviPosImportance, 0);
def rviposdown = If(rvi < 75 and rvi[1] > 60, rviPosImportance, 0);
input rviDivImportance = 4;#, title="RVI Divergence Importance")
def rvidivup = If(bullCond15 or bullCond15[1] or bullCond15[2], rviDivImportance, 0);
def rvidivdown = If(bearCond15 or bearCond15[1] or bearCond15[2], rviDivImportance, 0);
#//Support and Resistance Signals
input srcrossimportance = 0;#itle="Support/Resistance Cross Importance")
def srcrossup = If(buy1 or buy2 or buy3 or buy4 or buy5 or buy6 or buy7 or buy8, srcrossimportance, 0);
def srcrossdown = If(sell1 or sell2 or sell3 or sell4 or sell5 or sell6 or sell7 or sell8, srcrossimportance, 0);
#//Volume Indicator Signals//////////////////////////////////////////////////////
#//On Balance Volume Divergence Signals
input obvdivimportance = 0;#=100, title="OBV Divergence Importance")
def obvdivup = If(bullCond18 or bullCond18[1] or bullCond18[2], obvdivimportance, 0);
def obvdivdown = If(bearCond18 or bearCond18[1] or bearCond18[2], obvdivimportance, 0);
#//Chaikin Money Flow Signals
input cmfCrossImportance = 0;#title="CMF Cross 50-Line Importance")
def cmfcrossup = If(cmf > 0 and cmf[1] < 0, cmfCrossImportance, 0);
def cmfcrossdown = If(cmf < 0 and cmf[1] > 0, cmfCrossImportance, 0);
input cmfLevImportance = 0;#axval=100, title="CMF Level Importance")
def cmflevup = If(cmf > 0, cmfLevImportance, 0);
def cmflevdown = If(cmf < 0, cmfLevImportance, 0);
#//VWAP Signals
input vwapCrossImportance = 0;#0, title="VWAP Cross HMA Importance")
def vwapcrossup = if(hma < vwapValue and hma[1] > vwapValue[1], vwapcrossimportance, 0);
def vwapcrossdown = if(hma > vwapValue and hma[1] < vwapValue[1], vwapcrossimportance, 0);
input vwapTrendImportance = 0;#, minval=0, maxval=100, title="VWAP Trend Importance")
def vwaptrendup = if(out2 > vwapValue, vwaptrendimportance, 0);
def vwaptrenddown = if(out2 < vwapValue,vwaptrendimportance, 0);
#//Candle Patterns Signals
input engulfingCandleImportance = 0;#00, title="Engulfing Candle Importance")
def bulleng = If(C_EngulfingBullish, engulfingCandleImportance, 0);
def beareng = If(C_EngulfingBearish, engulfingCandleImportance, 0);
#//Classify Entries
def stronglongentrysignal = emadirectionup + emapushup + supertrendup + supertrendrevup + psardirup + psarrevup + hmacloseposup + hmapivotup + rsidivup + rsioversold + rsicrossup + macddivup + histpivotup + macdcrosssignalup + wtdivup + wtcrosssignalup + sdivup + scrosssignalup + bbcontup + atrrevup + rviposup + rvidivup + srcrossup + obvdivup + cmfcrossup + cmflevup + vwapcrossup + vwaptrendup + bulleng >= stronglongscore;
def strongshortentrysignal = emadirectiondown + emapulldown + supertrenddown + supertrendrevdown + psardirdown + psarrevdown + hmacloseposdown + hmapivotdown + rsidivdown + rsioverbought + rsicrossdown + macddivdown + histpivotdown + macdcrosssignaldown + wtdivdown + wtcrosssignaldown + sdivdown + scrosssignaldown + bbcontdown + atrrevdown + rviposdown + rvidivdown + srcrossdown + obvdivdown + cmfcrossdown + cmflevdown + vwapcrossdown + vwaptrenddown + beareng >= strongshortscore;
def weaklongentrysignal = emadirectionup + emapushup + supertrendup + supertrendrevup + psardirup + psarrevup + hmacloseposup + hmapivotup + rsidivup + rsioversold + rsicrossup + macddivup + histpivotup + macdcrosssignalup + wtdivup + wtcrosssignalup + sdivup + scrosssignalup + bbcontup + atrrevup + rviposup + rvidivup + srcrossup + obvdivup + cmfcrossup + cmflevup + vwapcrossup + vwaptrendup + bulleng >= weaklongscore;
def weakshortentrysignal = emadirectiondown + emapulldown + supertrenddown + supertrendrevdown + psardirdown + psarrevdown + hmacloseposdown + hmapivotdown + rsidivdown + rsioverbought + rsicrossdown + macddivdown + histpivotdown + macdcrosssignaldown + wtdivdown + wtcrosssignaldown + sdivdown + scrosssignaldown + bbcontdown + atrrevdown + rviposdown + rvidivdown + srcrossdown + obvdivdown + cmfcrossdown + cmflevdown + vwapcrossdown + vwaptrenddown + beareng >= weakshortscore;
#/Alternate Entry Signals
def pos;
if stronglongentrysignal and pos[1] <= 0 {
pos = 1;
} else {
if strongshortentrysignal and pos[1] >= 0 {
pos = -1;
} else {
pos = pos[1];}}
def longentry = pos == 1 and pos[1] != 1;
def shortentry = pos == -1 and pos[1] != -1;
def alternatelong = if(alternatesignals, longentry , stronglongentrysignal);
def alternateshort = if(alternatesignals, shortentry, strongshortentrysignal);
AddChartBubble(if(tradetrendoption,alternatelong and mabuy, alternatelong), l,"L",Color.GREEN,no);
AddChartBubble(if(tradetrendoption,alternateshort and masell,alternateshort),h,"S",Color.RED,yes);
plot WeakLong = if weaklongentrysignal then l else na;#, title="Weak Long Triangle",
WeakLong.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
WeakLong.SetHiding(!ShowWeakSignals);
WeakLong.SetDefaultColor(Color.YELLOW);
plot WeakShort = if weakshortentrysignal then h else na;#"Weak Short Triangle"
WeakShort.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
WeakShort.SetDefaultColor(Color.WHITE);
WeakShort.SetHiding(!ShowWeakSignals);
#---- END CODE