Development and Testing of Trading Hypothesis

chintan786

Well-Known Member
#11
Ok. So here is the code:
Code:
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
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;

H_Yest = TimeFrameGetPrice("H",inDaily,-1);
L_Yest = TimeFrameGetPrice("L",inDaily,-1);
H_Tody = TimeFrameGetPrice("H",inDaily,0);
L_Tody = TimeFrameGetPrice("L",inDaily,0);

Filt = L_Tody > H_Yest OR H_Tody < L_Yest; // Gap
//--Restore time frame
TimeFrameRestore();
_SECTION_END();
 

chintan786

Well-Known Member
#13
Although given strategy not showing colourful results if we backtest Fut or Cash data as exit is at 1515 if signal stays as... but if short Options with SL at other Extreme then will add huge value to Account and Bonus is very less Trade generated.
this Options thing is back tested and showing positive return but data is too small.
Currently weekly options considered for this.
 

TracerBullet

Well-Known Member
#15
Although given strategy not showing colourful results if we backtest Fut or Cash data as exit is at 1515 if signal stays as... but if short Options with SL at other Extreme then will add huge value to Account and Bonus is very less Trade generated.
this Options thing is back tested and showing positive return but data is too small.
Currently weekly options considered for this.
1) If something does not have edge, then we really should not try to force it. Better try to find something else. Also if data is too small, then it may not be real.
Some common sense is needed in interpreting the results and its probably good to be a sceptic.
2) When you have a concept, there are two things. Does it have an edge ? And are you able to convert the idea into logic/code. There may be different ways of tackling an idea and that is where some of your human brain can work.
3) This is an ongoing process. You can have an idea bin and then test those ideas on and off as you feel like it. Some dont work but some do. It would have been nice if someone tried to show which of the systems and ideas taken from the forum actually have value. And best way is to take one concept and test it manually/mechanically.

Anyway, good luck ..
 

chintan786

Well-Known Member
#16
Since i starting this Thread today. Here is my first hypothsis which need to back test/can be developed as indicator Etc.

Hypothesis:
"If mkt. open Outside Previous day VA and A-period singles didn't get tagged (High or Lowers once, either side remain virgin) then that High/Low remain protected for the day. It may give rise to Trend day as well OR trend remain intact till Europe open at least.

Back Test: I have no idea how to back test this Hypothesis and for that Need little help.

A-Period: 1st 30-min. Bar of the day.

VA: VAlue Area.

Kindly share if anyone have any thoughts.
Given Hypo worked well today as well.
 

chintan786

Well-Known Member
#17
1) If something does not have edge, then we really should not try to force it. Better try to find something else. Also if data is too small, then it may not be real.
Some common sense is needed in interpreting the results and its probably good to be a sceptic.
2) When you have a concept, there are two things. Does it have an edge ? And are you able to convert the idea into logic/code. There may be different ways of tackling an idea and that is where some of your human brain can work.
3) This is an ongoing process. You can have an idea bin and then test those ideas on and off as you feel like it. Some dont work but some do. It would have been nice if someone tried to show which of the systems and ideas taken from the forum actually have value. And best way is to take one concept and test it manually/mechanically.

Anyway, good luck ..
Dear Tracerbullet, thanks for your Post.
I am very happy with what u have written.... And Must say everyone, kindly go through this Gem of a Post before using this strategy. .. if at all anyone willing.

Anyone wants to use this, plz bear in mind: DO YOUR DUE DILIGENCE.

My personal take is : I starting using this for Large size trade.
weekly options data remains small... whether one is happy with back test result or not is not mine headache
Nor its' mine concern whether "EDGE" is delivered or NOT.

I started this Thread to dissect Hypothesis... which origins from intution, lagta Hai etc etc.

Rest can be made many things out of this.

Why This is Ok to me: Coz I hate "adjustment(s)"..may be this is my personality.. that I can't bear adjust(s) as and when.
So i ain't going to change (for myself only) this OR Add another indicator to this.

I do have something in Mind regarding "C" period... will try to put that in word in coming days.

Thanks @Happy_Singh for your support and all others sharing your view.
 

chintan786

Well-Known Member
#18
03-Jun:
Today experimenting with C-period Hi-lo. As A-period Hi-lo both got visited.
Holding Long with C-period low as SL which is 10059.20