How to plot different buy/sell signals for first and subsequent orders

i use the following code for plotshapes:
'''
Buy= ISOK AND Buy;
Sell= Sell OR ISNOTOK;

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorDarkBlue, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),coloryellow, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colordarkRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colordarkRed, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),coloryellow, 0,H, Offset=-45);

'''
now, i'd like to have a different shape plotted for the first buy/sell signal in a raw, and a different
shape for subsequent signals, so that i can easily distinguish them.
how do i do that, please?

Your code is incomplete and no within code tags.

m = MA( Close, 20 ); 
Buy = Cross( Close, m ); 
Sell = Cross( m, Close ); 

Plot( C, "Price", colorDefault, styleBar );

function sum_since(cond, array) {
	return SumSince(cond,array)+ValueWhen(cond,array);
}

NOT_visible = Ref(Status("barvisible"),-1) == 0;
first_buy = Buy AND sum_since(NOT_visible,Buy)==1;
first_sell = Sell AND sum_since(NOT_visible,Sell)==1;

PlotShapes(IIf(first_buy, shapeSquare, IIf(Buy,shapeUpArrow, shapeNone)), colorGreen, 0, L );
PlotShapes(IIf(first_sell, shapeSquare, IIf(Sell,shapeDownArrow, shapeNone)) , colorRed, 0, H );

Or using Cum and reducing bars.

period = 20;
m = MA( Close, period ); 
Buy = Cross( Close, m ); 
Sell = Cross( m, Close ); 

Plot( C, "Price", colorDefault, styleBar );

first_buy = Buy AND Cum(Buy)==1;
first_sell = Sell AND Cum(Sell)==1;

PlotShapes(IIf(first_buy, shapeSquare, IIf(Buy,shapeUpArrow, shapeNone)), colorGreen, 0, L );
PlotShapes(IIf(first_sell, shapeSquare, IIf(Sell,shapeDownArrow, shapeNone)), colorRed, 0, H );

SetBarsRequired(period);

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.