AFL help....to Plot midpoint of Candle!

lasty66

Active Member
#1
Hi Traderji Gurus,
Can anybody write a afl which plots the mid-point of previous candle....
eg: say a range of a candle is 10 points....i want a afl that plots a line from that point....:)

Thanks
 

mastermind007

Well-Known Member
#2
Add following line to the AFL

Plot ( Ref((H - L)/2, -1), "Mid point", colorBlack, styleLine);
 
#4
Once I found a very good afl to draw Opening range breakout according to Toby Crabel ideas. I seek help from AFL experts of traderji to slightly modify this afl. In this afl there is an option to select either Single Breakout line or Two Breakout lines. I want both : to draw both Single and Two breakout lines as they all are important. I will be very obliged to get help about this little modification so that I could choose Both. It will be very helpful for other traders too.

_SECTION_BEGIN("BrkOuts");
// Condition
ShowHM = ParamToggle("Show HM", "No|Yes", 0);
ShowMA65 = ParamToggle("Show MA65", "No|Yes", 0);
ShowShapes = ParamToggle("Show Shapes", "No|Yes", 0);
ShowBOs = ParamToggle("Show BOs", "No|Yes", 1);

// Parameters
Priceyy = ParamField("Pricey");
ph = Param("HullP", 10,1,100,1);

// Formula 1
function HMA1(Pricey, ph)
{
return WMA(2*WMA(Pricey, ph/2)-WMA(Pricey, ph), sqrt(ph));
}

function JMA1( array, per )
{
TN1=MA(array,per);
s1=0;
for( i = 0; i < per; i=i+1 )
{
s1=s1+((per-(2*i)-1)/2)*Ref(array,-i);
}
return TN1+(((per/2)+1)*S1)/((per+1)*per);
}

a=Param("Hull_JMA",25,1,100,1);
k=Param("kp",10,1,100,1);

L = HMA1(C,k);
M=JMA1(C,k);
N=((L*a)+(M*(100-a)))/100;
if(ShowHM) {
Plot( N, "HullM", ParamColor( "HMColor", colorDarkBlue ), ParamStyle("HMStyle", styleThick ) | styleNoRescale ); }
if(ShowMA65) {
Plot (MA(C,65),"",ParamColor( "MA65Color", colorPink ), ParamStyle("MA65Style", styleThick ) | styleNoRescale ); }

// Open Range Breakout AFL
// Current ORB level time is set as 9.30 a.m. which can be easily changed
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=093000;
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 * shapeSmallUpTriangle + fastSell * shapeSmallDownTriangle;
if(ShowShapes) {
PlotShapes( shape, IIf( fastBuy, colorBlue, colorRed ), 0, IIf( fastBuy, Low, High) ); }
if(ShowBOs) {
if (ORbtype=="Single")
{
Plot(r2,"R2",ParamColor("BoColor", colorViolet ), ParamStyle("BoStyle", styleThick) | styleNoTitle | styleNoRescale );
}
else
{
Plot(r2,"R2",ParamColor("R2BoColor", colorRed ), ParamStyle("R2BoStyle", styleThick) | styleNoTitle | styleNoRescale );
Plot(s2,"S2",ParamColor("S2BoColor", colorLime ), ParamStyle("S2BoStyle", styleThick) | styleNoTitle | styleNoRescale);
}
}
_SECTION_END();
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?