Buy /sell signal only after first three bar of occurrence

Hii,

I am trying to plot zone and assign study ID to generate buy / sell signal. While marking zone, buy/sell signal generate from the first bar only [ please refer to attached screenshot. ] I want to avoid first three bars and generate only when next time price touch the zone [ after three bar].

SU =	 Study("su", 2048 ) ;
RE = 	 Study("RE", 2048 );

BUY=		(C<=SU OR L<=SU  ); 
SELL=		(C>=RE OR H>=RE);
buy=		ExRem(Buy,sell);
sell=		ExRem(sell,buy);


PlotShapes(shapeUpArrow*Buy,colorGreen,0, L,-20 ); 
PlotShapes(shapeDownArrow*Sell,colorRed,0, H,-20 ); 

SIGNAL

I have used buy=event(ref,-3) , but it generates signal even price not touched.

Please anyone have idea how to do ?

Thanks in advance

@travick @fxshrat

anyone has idea how to avoid signal (not entry) in above scenario
I have used Fibonacci tool to draw zone and assigned SU for entry
but while marking zone , by default entry signal generates on first candle itself,
my strategy is to trade on next occurrence of the zone (say after three occurrence).

Please help if you can , I have tried many thing to solve, hold() and ref() postponed the entry not signal.

Regards

hii friends
could anyone help ??.

@sandeep First a comment. I think your buy signal can be shortened to just Low<=SU, because if Close is below support then Low must also be below support.

I don't use chart studies so I can't comment on your appropriate use but I can answer a general question about having your condition true for 3 bars before triggering a BUY.

Condition = ... // your Buy conditions

And you want three bars of continuously true Condition. Another way of looking at that is how many bars since the Condition was not true.

BuySignal = BarsSince(!Condition)>3;

You could alternatively define and code your condition as the inverse so instead of NOT (the !Condition) you would use BarsSince(Condition). Good luck.
image

2 Likes

It works like charm ,Thank You !!