//plotting price
Plot( C,"",colorDefault,styleCandle);
//condition for buying
Buy = Cross( MACD(), Signal() );
//plot a green arrow below the candle on chart when condition is true
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-12);
//referring to the previous bar before the condition
bar_before_buy=Ref(Buy,1);
//plot a yellow arrow below that candle
PlotShapes(IIf(bar_before_buy,shapeUpArrow,shapeNone),colorYellow,0,L,-12);
//referring to the previous bar's high before the condition
hh=ValueWhen(bar_before_buy,H);
//referring to the previous bar's low before the condition
ll=ValueWhen(bar_before_buy,L);
//plotting those highs and lows
Plot(hh,"",colorBlue,styleLine|styleDots);
Plot(ll,"",colorViolet,styleLine|styleDots);