Fresh Signals on New Day

Hello,

I am newbie to AFL Language. My AFL plots Buy , Sell , Short , Cover Arrows. On a new day, previous day signal counterpart carryforwards. But, I want a fresh signal starts with Buy or Short Signal but not Sell or Cover Signal on new day start, Because I want to trade Intraday.

_SECTION_BEGIN("Price");
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() ); 
_SECTION_END();

_SECTION_BEGIN("Signal");
PrevCCI = Ref(CCI(34),-1); //Checks Previous Bar CCI
Alert1 = ( -100 > CCI(34) ); //Buy Alert
Alert2 = ( CCI(34) > 100 ); //Sell Alert
Fbuy = ( PrevCCI < -100 and CCI(34) > -100 and RSI(14) > 40 ); //Buy Signal
FSell = ( PrevCCI > 100 AND CCI(34) < 100 AND RSI(14) < 60 ); //Short Signal

BuyEt = Alert1 AND RSI(14) < 40 ; //Buy Exit (Sell)
SellEt = Alert2 AND RSI(14) > 60; //Short Exit (Cover)

Buy = Fbuy;
Sell = BuyEt;
Short = FSell;
Cover = SellEt;

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

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

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

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-15);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-25);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-20); 


PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=15);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=25);                      
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-20);

PlotShapes(IIf(Cover, shapeStar, shapeNone),colorBrightGreen, 0,L, Offset=-20); 
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorRed, 0,H, Offset= 20);

_SECTION_END();

Please Resolve my problem sir. @Tomasz

Regards,
Prasada Rao Karri

It is mandatory advice to read/search knowledbase base articles first.

How to restrict trading to certain hours of the day

2 Likes

@fxshrat, Thank you so much for your Support sir. Grateful to you. My problem Resolved.

1 Like