// Downloaded From https://www.WiseStockTrader.com Stop1 = 0; myATR=ATR(14); for( i = 1; i < BarCount; i++ ) { PREV = stop1[ i - 1 ]; HH = H[ i ]; LL=L[i]; ar=4.5*myATR[i]; Stop1[ i ] = IIf( PREV < LL,IIf(( HH - ar ) >= PREV,( HH - ar ),PREV),( HH - ar)); } Stop2 = 0; for( i = 1; i < BarCount; i++ ) { PREV = Stop2[ i - 1 ]; CC= C[ i ]; LL=L[i]; Stop2[ i ] = IIf( PREV < LL,IIf(( CC - 3.5*myATR[i] ) >= PREV,( CC - 3.5*myATR[i] ),PREV),( CC - 3.5*myATR[i] )); } StopLong=IIf(Stop1>Stop2,Stop1,Stop2); Stop3 = 0; for( i = 1; i < BarCount; i++ ) { PREV = stop3[ i - 1 ]; HH = H[ i ]; LL=L[i]; Stop3[ i ] = IIf( PREV > HH,IIf(( LL + 4*myATR[i] ) <= PREV,( LL + 4*myATR[i]),PREV),( LL + 4*myATR[i] )); } Stop4 = 0; for( i = 1; i < BarCount; i++ ) { PREV = Stop4[ i - 1 ]; CC= C[ i ]; HH=H[i]; Stop4[ i ] = IIf( PREV > HH,IIf(( CC + 3.5*myATR[i] ) <= PREV,( CC + 3.5*myATR[i] ),PREV),( CC + 3.5*myATR[i] )); } StopShort=IIf(Stop3BarsSince(H>Ref(StopShort,-1)) ),StopLong,StopShort); Buy=IIf(Cross(MA(C,1), result ) ,1,0); Sell=IIf(Cross(result ,MA(C,1) ),1,0); Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); shape = Buy * shapeUpArrow + Sell * shapeDownArrow; PlotShapes( shape, IIf( Buy, colorBlue, colorRed ), 0, IIf( Buy, Low, High ) ); //uptrend=PDI(42)>MDI(42)AND PDI(14)>MDI(14); //downtrend=PDI(42)C,1,0); Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon", IIf( uptrend, 43, IIf( downtrend, colorRed, 0 )), /* choose color */ styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); //state=IIf(BarsSince(Buy)MDI(42)) AND (PDI(14)>MDI(14)),1,0); bearish=IIf((PDI(42)Ref(H,1)) AND(H>Ref(H,2)) AND(H>Ref(H,3)) AND(Ref(C,4)>0) AND(Lresult,0,1); Plot(result,"Swing",IIf(a,colorBlue,colorRed),styleStaircase); s=IIf(C2.08,MN+(1.33*SD),2.08); Val2=IIf(MN-(1.33*SD)<-1.92,MN-(1.33*SD),-1.92); ln1=IIf(Ref(Pk,-1)>=0 AND Pk>0,Val1,IIf(Ref(Pk,-1)<=0 AND Pk<0,Val2,0)); Red=IIf(Ref(Pk,-1)>Pk,Pk,0); Green=IIf(Pk>Ref(Pk,-1),Pk,0); tip=IIf(green>ln1 AND green>1,1,0); bip=IIf(redln1 AND red>1,1,0); bottom=IIf(green