My Nifty Trading AFL

#13
Can anyone please help me, i have been trying to backtest a strategy for intraday, but i cannot find intraday settings(5mins, 15mins, 1hr) in the periodicity option in backtest settings. Please see image.



Am i doing something wrong here??
 
#14
i think your data base setting is (END-OF-DAY)

OR

You have only eod data

plz chek once
 
#15
Thanks Santhosh Ji, Its working now. ::D

The Lines show pretty good levels... Anyone tried to backtest this afl? How about the the results?

One question, if the yellow line is flat... should we still enter into any position?
 

suri112000

Well-Known Member
#17
Can somebody share this AFL please. Must show Entry level, Targts, and Stop loss.

 
#18
hi, here some code on this system that can be backtested. Systems like this (in my opinion) have some good trades but also too many whipsaws. Also there is always an optimized set of parameters that will work for a while and then will fail miserably. I would not trade with it in this form.

SetTradeDelays(0,0,0,0);
SetOption("CommissionMode",3);
SetOption("CommissionAmount",2.32);
SetOption("FuturesMode",True);
NumContracts=1;
PositionSize=NumContracts*MarginDeposit;
SetOption("MaxOpenPositions",4);

OptimizerSetEngine("cmae");
p1=Optimize("Period 1",7,1,20,1);
p2=Optimize("Period 2",17,10,50,1);

res1=HHV(H,p1);
sup1=LLV(L,p1);
tsl1=IIf(ValueWhen(IIf(C>Ref(res1,-1),1,IIf(C<Ref(sup1,-1),-1,0))!=0,IIf(C>Ref(res1,-1),1,IIf(C<Ref(sup1,-1),-1,0)),1)==1,sup1,res1);
res2=HHV(H,p2);
sup2=LLV(L,p2);
tsl2=IIf(ValueWhen(IIf(C>Ref(res2,-1),1,IIf(C<Ref(sup2,-1),-1,0))!=0,IIf(C>Ref(res2,-1),1,IIf(C<Ref(sup2,-1),-1,0)),1)==1,sup2,res2);

trend=IIf(C>tsl2,1,IIf(C<tsl2,-1,0));

Buy=C>tsl1 AND trend==1;Buy=Ref(Buy,-1);BuyPrice=O;
Sell=C<tsl1;Sell=Ref(Sell,-1);SellPrice=O;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Short=C<tsl1 AND trend==(-1);Short=Ref(Short,-1);ShortPrice=O;
Cover=C>tsl1;Cover=Ref(Cover,-1);CoverPrice=O;
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(colorBlack);
Plot( C, "Close", ParamColor("Color", colorLightGrey ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
Plot(tsl1,"", colorBlue, styleStaircase);
Plot(tsl2,"", colorYellow, styleStaircase);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorDarkGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Sell,shapeSmallCircle,shapeNone),colorWhite,0,SellPrice,0);
PlotShapes(IIf(Short,shapeSmallDownTriangle,shapeNone),colorRed,0,H,IIf(Short AND Sell,-30,-15));
PlotShapes(IIf(Short,shapeSmallCircle,shapeNone),colorWhite,0,ShortPrice,0);
PlotShapes(IIf(Cover,shapeSmallUpTriangle,shapeNone),colorDarkGreen,0,L,IIf(Cover AND Buy,-30,-15));
PlotShapes(IIf(Cover,shapeSmallCircle,shapeNone),colorWhite,0,CoverPrice,0);
 
#19
can some senior tell me what exactly this afl do ??

can some senior throw some light on what this afl exactly do ? whats the concept behind it ??
u want some light throwing senior to give feedback. . . but maybe no senior's around :)


anyway . . .

from code looks like Break-out / Break-down form 17/7 bars high-low

Code:
res=HHV(H,7);
sup=LLV(L,7);

res=HHV(H,17);
sup=LLV(L,17);

:) Happy


EDIT: Adding this code for clear buy/sell. Hope you enjoy it :thumb:

Code:
_SECTION_BEGIN("Signals");
R1	=	Ref(HHV(H,7),-1);	S1	=	Ref(LLV(L,7),-1);
R2	=	Ref(HHV(H,17),-1);	S2	=	Ref(LLV(L,17),-1);
UP	=	BarsSince(Cross(C,R2)) < BarsSince(Cross(S2,C));	
DN	=	BarsSince(Cross(C,R2)) > BarsSince(Cross(S2,C));
Buy 	=	Cross(C,R1) AND UP;	Sell	= Cross(S1,C); 
Buy 	=	ExRem(Buy,Sell);		Sell	= ExRem(Sell,Buy); 
Short	=	Cross(S1,C) AND DN;	Cover	= Cross(C,R1);
Short	=	ExRem(Short,Cover);	Cover	= ExRem(Cover,Short);
PlotShapes(Buy + 2*Short, colorWhite, 0 , IIf(Buy,L,H));
PlotShapes(Sell*4 + 3*Cover, colorWhite, 0 , IIf(Sell,H,L),-24);
_SECTION_END();

:) Happy
 
Last edited:

Similar threads