Please add exploration for ORB AFL

amitrandive

Well-Known Member
#1
Dear All

Below is the ORB for Opening Range breakout.I need exploration for single level and two levels ORB breakout.

SetBarsRequired(1000,0);
ORBtype=ParamList("ORB Single or Two levels?","Single|Two");
Style=ParamList("Plot Bars or Candle","Bars|Candle");
BarColor = IIf(Close > Open, colorGreen, colorRed);
SetBarFillColor(BarColor);
if(style=="Bars")Cstyle=styleBar;
else Cstyle=styleCandle;
Plot(C,"Close",colorWhite,Cstyle);
timesetting=0092500;
tn=TimeNum();
Datey=DateNum();
fastprice=lev=0;
avp=(O+C)/2;
r2=s2=ar1=ar2=ar3=bs1=bs2=bs3=0;
fastbuy=fastsell=0;
gapzz=10;
Lastsig=Buycond=Shortcond=dayopen=dayclose=dayhigh=daylow=0;
for (i=2;i<BarCount;i++)
{

//PlotText(WriteVal(1,1.0),i,H+15,colorWhite);

//day high low logic
if (Datey!=Datey[i-1])
{
Dayopen=O;
Dayclose=C;
Buycond=Shortcond=lastsig=0;
ar1=ar2=ar3=bs1=bs2=bs3=0;
fastprice=lev=0;
}
if (Datey==Datey[i-1])
{
Dayopen=Dayopen[i-1];
Dayclose=Dayclose[i-1];
Dayhigh=Dayhigh[i-1];
Daylow=Daylow[i-1];
}
if (H>Dayhigh)Dayhigh=H;
if (Daylow==0)Daylow=L;
if (L<Daylow)Daylow=L;
// day high low logic end
//PlotText(WriteVal(i,1.0),i,H+10,colorWhite);

if (tn<timesetting )
{
//PlotText(WriteVal(1,1.0),i,H+10,colorWhite);

r2=Dayhigh;
s2=Daylow;
if (ORbtype=="Single")fastprice=r2=s2=(Dayhigh+Daylow)/2;
}
else
{
//PlotText(WriteVal(1,1.0),i,H+10,colorWhite);

r2=r2[i-1];
s2=s2[i-1];
}
Lev=0;
if (ORbtype=="Single")
{
fastprice=r2;
if (avp>r2)Lev=1;
if (avp<s2)Lev=8;

}
else
{
if (avp>r2){fastprice=r2;Lev=1;}
if (avp<s2){fastprice=s2;Lev=8;}
if (avp<r2 AND avp>s2 AND avp>(r2+s2)/2){fastprice=r2;}
if (avp<r2 AND avp>s2 AND avp<(r2+s2)/2){fastprice=s2;}
}

if (Lev==1)
{
ar1=avp-r2;ar2=avp[i-1]-r2;ar3=avp[i-2]-r2;
//passthrough
if (avp>r2 AND avp[i-1]<r2)Buycond=1;
//kiss and go above
if (ar2<gapzz AND ar1>ar2 AND ar3>ar2) Buycond=1;
}
if (Lev==8)
{
bs1=s2-avp;bs2=s2-avp[i-1];bs3=s2-avp[i-2];
//pass through
if (avp[i-1]>s2 AND avp<s2)Shortcond=1;
//kiss and go
if (bs2<gapzz AND bs1>bs2 AND bs3>bs2) Shortcond=1;
}
if (Lev==1 AND Buycond==1 AND Lastsig!=1)
{
fastbuy=1;
Lastsig=1;
Buycond=shortcond=0;
}
if (Lev==8 AND Shortcond==1 AND Lastsig!=-1)
{
fastsell=1;
Lastsig=-1;
Buycond=shortcond=0;
}
}
shape = fastBuy * shapeUpArrow + fastSell * shapeDownArrow;
PlotShapes( shape, IIf( fastBuy, colorLime, colorRed ), 0, IIf( fastBuy, Low, High));
if (ORbtype=="Single")
{
Plot(r2,"R2",colorYellow,styleLine|styleDashed|styleNoTitle);
}
else
{
Plot(r2,"R2",colorYellow,styleLine|styleDashed|styleNoTitle);
Plot(s2,"S2",colorRed,styleLine|styleDashed|styleNoTitle);
}
 
#2
Hi Amitrandive

just add these lines to your code.


HTML:
//================================

GraphXSpace =5;

// Plot the ribbon-code by casoni
ribboncol= IIf( BarsSince(fastBuy)<BarsSince(fastSell), colorGreen, colorRed );
Plot( 2, "", ribboncol, styleArea | styleOwnScale | styleNoLabel, 0, 100 );
//hope this is what you required. 
Cldcolor = IIf(C>r2,ColorRGB(0,45,0),IIf(C<s2,ColorRGB(45,0,0),colorDarkGrey));
PlotOHLC(r2,r2,s2,s2," ",Cldcolor,styleCloud);
Filter=(fastBuy ) OR (fastSell ) ;
AddColumn(Close," ",1.2);
AddColumn(fastBuy,"buy",1.0);
AddColumn(fastSell,"sell",1.0);
AddColumn(MACD(),"macd()",1.1);
AddColumn(ATR(10),"atr(10)",1.1);
AddColumn(Volume/1000,"v/1000",1.0);

//exploration by ford7k
 
Last edited:

amitrandive

Well-Known Member
#3
Ford K

Thanks very much , you also added the ribbons and buy,sell zones in the opening range.Exploration also works.

Thanks
Amit :clap::thumb:
 
#4
Hello Ford7k,

Please help me also. Below exploration plots lines on 10% excess of High and Low of previous day. I tried very much to create exploration for the same so that when the 15 minute candle closes above this 10% line, it shows up in the scanner. The same way it should show up in downside.

I tried to create the exploration, but the results were worst.

********************************************

_SECTION_BEGIN("10%");
Plot(C,"",3,64);
dH1= TimeFrameGetPrice("H",inDaily,-1);
dL1= TimeFrameGetPrice("L",inDaily,-1);
yrng=(dH1-dL1);
rrp=Optimize("room%",Param("room%",10,0.5),1,10,0.5);
room=(yrng*rrp)/100;

today=Day()==LastValue(Day());

Plot(IIf(today,dh1+room,Null),"",colorLightYellow,styleDashed,8);
Plot(IIf(today,dl1-room,Null),"",colorLightYellow,styleDashed,8);
_SECTION_END();

***************************************
 

Similar threads