# 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);
``````

UPDATE

``````Buy =  B;
Sell = S;

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);
``````

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 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