AFL Code Writer wanted.

#1
Hi Friends I have a 2 set of ATR based Trading system which I have been trading manually all this while. I was hoping if some one cud write a back testable code for me and also advise the charge and time line for it.



I will share the details once you show interest.

Broadly speaking My system is basically a 2 ATr system. A longer ATR and a smaller ATR. (longer and shorter in terms of ATR multiplier and time Period).

System checks for the over all trend of the market based on the longer ATR. (14,5) 5 is the multiplier and 14 is the look back time.

Now the shorter ATR is used to make trade entries. Entries are made in the direction of the trend. ATR parameters wud be (5, 2).

Square off wud happen on Shorter ATR reversal.


Position sizing. The system wud square off half the positions at 1R. (R is the initial amount risked). So if based on shorter ATR, if my stop loss was coming at 40 points, as soon as the price moves in our direction by 40 points, half the position gets squared off.

the reMAINDER OF THE POSITION WUD B SQUARED OFF BASIS strategy exit (ATR reversal)
 
#2
use 2 charts with different setting, that will do your job for you . . .

if you want it on same chart .. . insert the ATR afl twice on the same chart . . .



:) Happy



Edit: ok you want to back test . . .
anyway . . . had a very good day at trading so . . . what the heck ... will try to post it for you in a while . . . :)

Edit 2:

Code:
_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("ATR SYSTEM");
HTF	=	Param("Choose HTF",60,15,60*24,1)*in1Minute;
n	=	Optimize("HTF Factor",5,3,8,0.25);
m	=	Optimize("Factor",2,1,3,0.25);
p	=	Param("HTF Lookback",14,8,30,1);
q	=	Param("Lookback",5,2,10,1);

A	=	n*ATR(20);
B	=	m*ATR(20);
TimeFrameSet(HTF);
 R  = Ref(Close,-p)+A;	S  = Ref(Close,-p)-A;
 UP = Close > R;			DN = Close < S;
 UP = ExRem(UP,DN);		DN = ExRem(DN,UP); 
TimeFrameRestore();
//Plot(TimeFrameExpand(S,inHourly),"",colorRed,styleThick|styleStaircase);
//Plot(TimeFrameExpand(R,inHourly),"",colorBlueGrey,styleThick|styleStaircase);
HTF_LONG	=	BarsSince(TimeFrameExpand(UP,inHourly)) < BarsSince(TimeFrameExpand(DN,inHourly));
HTF_SHORT	=	NOT (HTF_LONG);
Plot(10,"",IIf(HTF_SHORT,colorRed,colorBlue),styleOwnScale|styleArea,-10,400); //HTF TREND
Res	 = 	Ref(Close,-q)+B;	 				Sup = Ref(Close,-q)-B;
Plot(Sup,"",colorRed,styleStaircase);	Plot(Res,"",colorBlueGrey,styleStaircase);
Buy   = Close > Res AND HTF_LONG; 		Sell  = Close < Sup;
Buy   = ExRem(Buy,Sell);				Sell  = ExRem(Sell,Buy); 
Short = Close < Sup AND HTF_SHORT;		Cover = Close > Res;
Short = ExRem(Short,Cover);				Cover = ExRem(Cover,Short); 
PlotShapes(Buy+2*Short,colorWhite,0,IIf(Buy,L,H),-24);
PlotShapes(3*Cover+4*Sell,colorWhite,0,IIf(Cover,L,H));
BuyPrice=Close;		SellPrice=Close; 		ShortPrice=Close; 	CoverPrice=Close;
SetTradeDelays(0,0,0,0);	SetPositionSize(100,4);
_SECTION_END();
check if this is what you want . . .
 
Last edited:

mastermind007

Well-Known Member
#3
Hi Friends I have a 2 set of ATR based Trading system which I have been trading manually all this while. I was hoping if some one cud write a back testable code for me and also advise the charge and time line for it.
It sounds like a week's work bulk of which will be spent in backtesting!
 

Similar threads