need afl writer for an orb trading system

dell

Well-Known Member
#1
i need to code some of my idea of opening range breakout system :

having three idea's need to be get coded.......

1) plain vanila system :

here we are playing with 5m breakout , trade will not taken after 10.30 , once trade initiate ,second trade will be not done untill sl of first trade hit ,buy- short positions are initiate after breakout range +2 point filter , if same bar breaks up range and down range than it have to consider last breakout/breakdown and false signal should be removed.....

if first trade fails than trade double quantity of first trade in second trade and if second also fails than no trade thereafter ,
we trade here with 2 lots , one lot get booked at fixed percentage or say fixed point and second lot at eod 3.25 p.m.

initial sl will be range + buffer point % , here range is high of first 5 minute -low of first 5 minute

all parameters should be such that we can optimize and param according to script need , system should be backtestable , exploreable and all details should be infront of screen ..

most important it should not look in future and , i also coded this system but find some minor bugs in it , so want to code it by proffesional coder ......
have many more idea's to get coded ......
after code i will see it on team viewer and if it satisfy all conditions,money will instantly paid in ur account .....

2 and 3 are some modifying concepts , will provide details while completing 1st work ......

if any one interested , write here or pm me
 

rkkarnani

Well-Known Member
#2
I dont use Amibroker, no idea about AFL. But do have some AFL's saved from the Net trying to build a data base in case if at any time I wish to start using Amibroker ! :p

Had this AFL as ORB : See if its of any use :

function ParamOptimize( pname, defaultval, minv, maxv, step )
{
return Optimize( pname,
Param( pname, defaultval, minv, maxv, step ),
minv, maxv, step );
}




_SECTION_BEGIN("Augubhai's ORB System v1.1");

//--Intraday time frame
TimeFrameSet(in5Minute); //If reseting, check formula for TimeFrameInMinutes
TimeFrameInMinutes = 5;

//--Define all params
EntryBufferPct = ParamOptimize("Entry Buffer %", 0, 0, 2, 0.1);
SLPct = ParamOptimize("SL %", 1.4, 0.1, 10, 0.1);
TargetPct = ParamOptimize("Target %", 0, 0, 20, 0.5);
MaxTarget = 100;
TargetPct = IIf(TargetPct == 0, MaxTarget, TargetPct);
EntryTimeStart = ParamOptimize("Entry Time Start (Minutes)", 5, 5, 120, 5);
EntryBarStart = floor(EntryTimeStart/TimeFrameInMinutes) - 1;
EntryTimeEnd = ParamOptimize("Entry Time End (Minutes)", 25, 10, 180, 5);
EntryBarEnd = floor(EntryTimeEnd/TimeFrameInMinutes) - 1;
EntryBarEnd = IIf(EntryBarEnd < EntryBarStart, EntryBarStart, EntryBarEnd);

//--Plot Price Candle Chart
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", colorBlack, styleNoTitle | GetPriceStyle() );

//--New Day & Time. End Day & Time . End Day & Time is null till end of day 1
NewDay = (Day()!= Ref(Day(), -1)) OR BarIndex() == 0;
printf("\n NewDay : " + NewDay );
EndDay = (Day()!= Ref(Day(), 1));
printf("\n EndDay : " + EndDay );
FirstBarTime = ValueWhen(NewDay,TimeNum(),1);
EndTime = ValueWhen(EndDay,TimeNum(),1);
SquareOffTime = EndTime;

//--Calculate ORB, and SL
HighestOfDay = HighestSince(NewDay,H,1);
LowestOfDay = LowestSince(NewDay,L,1);
BarsSinceNewDay = BarsSince(NewDay);
ORBH = ValueWhen(BarsSinceNewDay<=EntryBarStart,HighestOfDay ,1) * (1 + (EntryBufferPct/100));
ORBL = ValueWhen(BarsSinceNewDay<=EntryBarStart,LowestOfDay ,1) * (1 - (EntryBufferPct/100));
ORBHSL = ORBH * (1-(SLPct/100));
//ORBHSL = ORBL;
ORBLSL = ORBL * (1+(SLPct/100));
//ORBLSL = ORBH;
ORBHTarget = ORBH * (1+(TargetPct/100));
ORBLTarget = ORBL * (1-(TargetPct/100));

//--Find Buy, Sell, Short & Cover Signals
BuySignal = (H >= ORBH) AND (BarsSinceNewDay > EntryBarStart);
printf("\nBuySignal : " + BuySignal );
ShortSignal = (L <= ORBL) AND (BarsSinceNewDay > EntryBarStart) ;
printf("\nShortSignal : " + ShortSignal );
BarsSinceLastBuySignal = (BarsSince(Ref(BuySignal,-1)) + 1);
BarsSinceLastShortSignal = (BarsSince(Ref(ShortSignal,-1)) + 1);
BarsSinceLastEntrySignal = Min(BarsSinceLastBuySignal, BarsSinceLastShortSignal);
BothEntrySignalsNull = IsNull(BarsSinceLastBuySignal) AND IsNull(BarsSinceLastShortSignal); //true for start of Day 1
printf("\n\nBarsSinceNewDay : " + BarsSinceNewDay );
printf("\n BarsSinceLastEntrySignal : " + BarsSinceLastEntrySignal);
Buy = (H >= ORBH) AND (BarsSinceNewDay > EntryBarStart) AND (BarsSinceNewDay <= EntryBarEnd) AND ((BarsSinceNewDay < BarsSinceLastEntrySignal) OR BothEntrySignalsNull );
Sell = (L <= ORBHSL) OR (H >= ORBHTarget) OR (TimeNum() > SquareOffTime-1) AND (BarsSinceNewDay > BarsSinceLastBuySignal);
Short = (L <= ORBL) AND (BarsSinceNewDay > EntryBarStart) AND (BarsSinceNewDay <= EntryBarEnd) AND ((BarsSinceNewDay < BarsSinceLastEntrySignal) OR BothEntrySignalsNull );
Cover = (H >= ORBLSL) OR (L <= ORBLTarget) OR (TimeNum() > SquareOffTime-1) AND (BarsSinceNewDay > BarsSinceLastShortSignal);
printf("\nBuy : " + Buy );
printf("\nSell : " + Sell );
printf("\nShort : " + Short );
printf("\nCover : " + Cover );

//--Handle if ORB broken both sides on same bar
//--And remove duplicate Sell & Cover signals, since ExRem did not work as needed when Buy & Sell on same bar
orbBothSides = IIf(Buy AND Short, 1, 0);
Buy = IIf(orbBothSides AND C <= O, 0, Buy);
Short = IIf(orbBothSides AND C > O, 0, Short);
Sell = IIf(orbBothSides AND C > O AND (L <= ORBHSL), 1, Sell);
Sell = IIf((BarsSince(Buy) < (BarsSince(Ref(Sell,-1))+1)) OR (BarsSince(Buy) AND IsNull(BarsSince(Ref(Sell,-1)))),Sell,0);
Cover = IIf(orbBothSides AND C <= O AND (H >= ORBLSL), 1, Cover);
Cover = IIf((BarsSince(Short) < (BarsSince(Ref(Cover,-1))+1)) OR (BarsSince(Short) AND IsNull(BarsSince(Ref(Cover,-1)))),Cover,0);
printf("\n\norbBothSides : " + orbBothSides);
printf("\nBuy : " + Buy );
printf("\nSell : " + Sell );
printf("\nShort : " + Short );
printf("\nCover : " + Cover );

//--Special Condition for 18 & 19 May 2009 for the Indian Market
Buy =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Buy );
Sell =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Sell );
Short =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Short );
Cover =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Cover );

//--Set prices
BuyPrice = IIf(Buy, ORBH, Null);
SellPrice = IIf(Sell, IIf(H >= ORBHTarget, ORBHTarget, Max(ORBHSL, L)), Null);
ShortPrice = IIf(Short, ORBL, Null);
CoverPrice = IIf(Cover, IIf(L <= ORBLTarget, ORBLTarget, Min(ORBLSL, H)), Null);

//--Plot ORB, and SL
Plot(ORBHSL,"",colorRed,styleDashed);
Plot(ORBLSL,"",colorRed,styleDashed);
Plot(IIf(TargetPct == MaxTarget, Null, ORBHTarget),"",colorGreen,styleDashed);
Plot(IIf(TargetPct == MaxTarget, Null, ORBLTarget),"",colorGreen,styleDashed);
PlotOHLC( ORBL, ORBH, ORBL, ORBH, "", colorYellow, styleCloud);

//--Plot Signals
shape1 = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape1, IIf( Buy, colorGreen, colorGreen), 0, IIf( Buy, Low, High ) );
shape2 = Cover * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape2, IIf( Cover, colorRed, colorRed), 0, IIf( Cover, Low, High ) );
GraphXSpace = 5;

//--Restore time frame
TimeFrameRestore();
_SECTION_END();
 

dell

Well-Known Member
#3
I dont use Amibroker, no idea about AFL. But do have some AFL's saved from the Net trying to build a data base in case if at any time I wish to start using Amibroker ! :p

Had this AFL as ORB : See if its of any use :
Sir . this afl is very good from augubhai ....but it looks in future and has serious bugs ....in backtesting u cann't rely on this .....it can only be used as a visual looks .....
Thanks for concern....
 

Similar threads