Skip to content

Instantly share code, notes, and snippets.

@DTM-SC
Created May 18, 2019 04:17
Show Gist options
  • Save DTM-SC/e8044b11828ee3c2754f323ef613486e to your computer and use it in GitHub Desktop.
Save DTM-SC/e8044b11828ee3c2754f323ef613486e to your computer and use it in GitHub Desktop.
Open Range Breakout (ORB) Intraday
/* This is simple ORB Breakout AFL, can be planned for any Breakout Strategy, Run explorer to see the data points
Planned for 15 MIn candle as default, but you can plan this strategy based on your need. The breakout is mentioned below for 15 minute candle for Indian market
Developed by DTM FInancial Solutions www.dailytrademantra.com
Please contact us for any clarification or further query : [email protected]
*/
_SECTION_BEGIN("ORB Breakout AFL");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarFillColor(IIf(C>O,ParamColor("UP Color", colorGreen),IIf(C<=O,ParamColor("Down Color", colorRed),colorLightGrey)));
Plot(C,"Price",IIf(C>O,ParamColor("Wick UP Color", colorLime),IIf(C<=O,ParamColor("Wick Down Color", colorOrange),colorLightGrey)),styleCandle | styleNoTitle);
_N(Title = "ORB Intraday AFL\n" + StrFormat("{{INTERVAL}} {{DATE}} \nOpen= %g, HiGH= %g, LoW= %g, Close= %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//FastEMALengthS = Optimize( "FEMA", 9, 1, 100, 1);
//SlowEMALengthS = Optimize( "SEMA", 26, 1, 100, 1);
FastEMALengthS = 9;
SlowEMALengthS = 26;
MArket_start_time = 091500;
Brake_out_time = 093000;
End_Of_Day_time = 153000;
Start_time = Cross(TimeNum(),MArket_start_time);
Exit_time = Cross(TimeNum(),End_Of_Day_time);
NewDay = Day()!= Ref(Day(), -1);
EndDay = (Day()!= Ref(Day(), 1));
EndTime = ValueWhen(EndDay,TimeNum(),1);
SquareOffTime = EndTime;
EntryBar = floor(1800/900) - 1; // starts after 9:30 am in the morning
BarsSinceNewDay = BarsSince(NewDay);
BarsSinceEOD = BarsSince(EndDay);
EntryBarEnd = floor(21600/900) - 1; // ends after 3:15 pm in the afternoon
EntryBarEnd = IIf(EntryBarEnd < EntryBar, EntryBar, EntryBarEnd);
F_15Min_Range = (TimeNum() >= MArket_start_time AND TimeNum()<= Brake_out_time );
No_Of_Bar = BarsSince(F_15Min_Range>0);
Num_Bars = 900 / Interval(1);
F_15Min_H = Ref(HHV(High,Num_Bars),-(No_Of_Bar+1));
F_15Min_L = Ref(LLV(Low,Num_Bars),-(No_Of_Bar+1));
Buy_Entry = F_15Min_H;
Short_Entry = F_15Min_L;
//F_Candlesize = F_15Min_H - F_15Min_L;
//Currtime =TimeNum();
plot(EMA(C,SlowEMALengths),"EMA-Slow",ParamColor("EMA-Slow",colorBlue));
Plot(EMA(C,FastEMALengthS),"EMA-Fast",ParamColor("EMA-Fastr",colorWhite));
Plot(F_15Min_H,"",colorBlue,styleLine); //Plot ORB lines
Plot(F_15Min_L,"",colorRed,styleLine);
//Explore your data points
Filter = 1; // show all bars
AddColumn( F_15Min_H, "ORB High",1.2,colorblack,IIf(C>F_15Min_H,colorGreen,colorWhite));
AddColumn( F_15Min_L, "ORB Low",1.2,colorWhite,IIf(C<F_15Min_L,colorred,colorWhite));
AddColumn( EMA(C,SlowEMALengths), "EMA 26",1.2);
AddColumn( EMA(C,FastEMALengthS), "EMA 9",1.2);
_SECTION_END();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment