If buy signal how to write exit buy if price below buy and plot a shape

if i get a signal and in long or short position how to write the code to plot a shape if the price gets below the buy to exit the long or short entry

Buy =  BB
Sell = SS
Plot(IIf(BB AND " C <BB" ),"",shapecircle);
Plot(IIf(SS AND "C >SS"),"",shapecircle);


Buy =  B;
Sell = S;
intrade = Flip(Buy, Sell);

Stopbuy =  SB;
Stopsell  =  SS;

Plot(IIf(B AND " Close of any candle after the buy signal is == SB" ),"",shapecircle);
Plot(IIf(S AND "Close of any candle after the sell signal is == SS"),"",shapecircle);
Plot(IIf(B AND SB ,Null,0,0,0,0),"",shapeStar,colorRed);
Plot(IIf(S AND SS ,Null,0,0,0,0),"",shapeStar,colorRed);

Please help with the missing code to plot the shape

B, S, SB and SS in your example are unknown to reader so this below PlotShapes code is posted without guarantee that it will actually show up shapes on your chart.

PlotShapes((B AND SB) * shapeStar, colorRed, 0, L, -12, 0 );
PlotShapes((S AND SS) * shapeStar, colorRed, 0, H, -12, 0 );

But for further information see PlotShapes documentation.

1 Like

thanks for pointing it out :slight_smile:
actually wanted to try with many different afl setup anyways can take a simple example of if buy that is cross over of EMA 20 and 50 and the close of any candle after the buy signal is generated id below the cross over ema 20 and 50 exit the trade or call it stoploss hit same for the sell signal

buy is cross ema 20 and 50 and stoploss is if the close of any candle is below the crossover after buy same for sell

@fxshrat please help always running in loss cause not able decide a stoploss price when on trade

was trying with all the free afl on internet

@fxshrat i think m missing out something
please help
BUY = cross ema (C, 20) and ema (C, 50)
same with sell
want a stoploss plotted after the buy signal only if the close of any candle after buy cross the buy signal of the buy crossover