Facing issue for Intraday NR3 Breakout AFL

Dear All,

KIndly help me create the Intraday NR3 breakout based Entry.

but the currently afl is generating based on the Yesterday NR3 Breakout . Kindly help to reslove this issue.

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

SetPositionSize(1,spsShares);

_SECTION_BEGIN("Master Candle Exploration");

Newday = Day()!= Ref(Day(), -1);
Endday = Day()!= Ref(Day(), 1);
Inbetween = Flip(Newday, Endday);

Buycondition = BarsSince(Newday) > 2 AND  Ref(H,-1) > Ref(H,0)  AND Ref(L,-1) < Ref(L,0) AND Ref(H,-2) > Ref(H,-1)  AND Ref(L,-2) < Ref(L,-1) ;

Buycontinue = Flip(Buycondition,EndDay);
BuyRemove = ExRem(Buycontinue,EndDay);

ShortTrigger = ValueWhen(Buycondition,Ref(L,-2));
BuyTrigger = ValueWhen(Buycondition,Ref(H,-2));

Buy = Cross(H,BuyTrigger) AND TimeNum() < 150000 AND BarsSince(Newday) > 2 ;
Short = Cross(ShortTrigger,L) AND TimeNum() < 151500 AND BarsSince(Newday) > 2;
BuyPrice = BuyTrigger;
ShortPrice = ShortTrigger;

Sell =  TimeNum() >= 150000 ;
Cover = TimeNum() >= 150000 ;


Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover, Short);

 ![Capture|690x374](upload://dMypyNWQ0vw6s0DY4KUETftecLs.png) 

Please find the unwanted signal attached imageCapture

You already have Flip() in your code. So why not using it?

Buy = Cross(H,BuyTrigger) AND TimeNum() < 150000 AND BarsSince(Newday) > 2;
Buy = Buy AND Flip(Buycondition,Endday);

Similar for Short.

@fxshrat Thank you for your reply.

As per your guideline, The issue is solved and in some area the signal is not generating.Please find the attached image and afl codeCapture . Kindly help me to reslove this issue.

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

SetPositionSize(1,spsShares);

_SECTION_BEGIN("Master Candle Exploration");

Newday = Day()!= Ref(Day(), -1);
Endday = Day()!= Ref(Day(), 1);
Inbetween = Flip(Newday, Endday);

Buycondition = Ref(H,-1) > Ref(H,0)  AND Ref(L,-1) < Ref(L,0) AND Ref(H,-2) > Ref(H,-1)  AND Ref(L,-2) < Ref(L,-1) ;
  
Buycontinue = Flip(Buycondition,EndDay);
BuyRemove = ExRem(Buycontinue,EndDay);

ShortTrigger = ValueWhen(BuyRemove,Ref(L,-2));
BuyTrigger = ValueWhen(BuyRemove,Ref(H,-2));

Buy = Cross(H,BuyTrigger)  AND TimeNum() <= 150000 ; 
Buy = Buy AND Flip(Buycondition,EndDay);
Short = Cross(ShortTrigger,L) AND TimeNum() <= 150000 ;
Short = Short AND Flip(Buycondition,EndDay);

BuyPrice = BuyTrigger;
ShortPrice = ShortTrigger;

Sell =  L < Ref(L,-1) OR TimeNum() >= 151500 ;
Cover = H > Ref(H,-1) OR TimeNum() >= 151500 ;

SellPrice = IIf(L < Ref(L,-1), Ref(L,-1),C);
CoverPrice = IIf(h > Ref(h,-1),Ref(H,-1),C);

Buy = Buy AND Sum( Buy,BarsSince(newDay) + 1) <= 1;
Short = Short AND Sum( Short,BarsSince(newDay) + 1) <= 1;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover, Short);
 
Filter = Buy OR Short;

Plot(IIf(Buycontinue,BuyTrigger,Null),"BuyTrigger",colorOrange,styleLine|styleDots);
plot(IIf(Buycontinue,ShortTrigger,Null),"ShortTrigger",colorOrange,styleLine|styleDots);
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorGreen, 0, L, Offset = -45 );
PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorRed, 0, H, Offset = 30 );
PlotShapes( IIf( cover, shapeUpArrow, shapeNone ), colorBlue, 0, L, Offset = -45 );
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorBlue, 0, H, Offset = 30 );

This is what you wrote

but the currently afl is generating based on the Yesterday NR3 Breakout .

So first you say that you do not want to consider yesterday's break out lines "today".
Now you do want to consider yesterday values on next day all of the sudden again.

Your last picture shows break through yesterday's lines "today".
That's what you didn't want.

Do you actually know what it is that you really want to achieve?

So by your last picture you only want to consider first Buy signal (so all subsequent ones (of same lines) shall be ignored). If so then why don't you write that in first place?

So here is new one.

Buy = Cross(H,BuyTrigger) AND TimeNum() <= 150000; 
Buy = Buy AND SumSince(BuyTrigger!=Ref(BuyTrigger,-1), Buy) < 2;

1 Like

@fxshrat My issue is resloved.
Thank you for your support.

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