Can someone please tell me how I can alter the AFL code so that I get a sell arrow on the chart. I need it so that I can perform a backtest. I just set the buy cond to Buy =0; to keep the AFL short.
I want it to say
Sell = ( a close below the countback line );
Thanks
Buy =0;
Sell =0;
nR=2;
Cbl[nR]=Null;
bCBL=False;
for( i=nR; i < BarCount; i++)
{
if( (Low[i-2]<Low[i-1]) && (Low[i-1]<Low[i]) )
{
Cbl[i] = Low[i-2];
bCBL = True;
}
else if (bCBL)
{
if (Low[i] < Cbl[i-1])
{
Cbl[i] = Cbl[i-1];
bCBL = False;
}
else
{
n = nR;
minval[i] = Low[i];
breakloop= False;
for (j = 1; NOT(breakloop) && j <= i; j++)
{
if (Low[i-j] < minval[i])
{
if (n>1)
{
minval[i] = Low[i-j];
n--;
}
else
{
Cbl[i] = Low[i-j];
breakloop=True;
}
}
}
if (Cbl[i] < Cbl[i-1])
Cbl[i] = Cbl[i-1];
}
}
else
{
Cbl[i] = Cbl[i-1];
}
if (Cbl[i]==0)
Cbl[i] = Cbl[i-1];
}
Plot(Cbl,"",colorLightGrey,1);
Plot(C,"",-1,64);
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
if( trailstop > 0 AND Close[ i ] < trailstop )
{
Sell[ i ] = 1;
SellPrice[ i ] = trailstop;
trailstop = 0;
Buy =0;
nR=2;
Cbl[nR]=Null;
bCBL=False;
for( i=nR; i < BarCount; i++)
{
if( (Low[i-2]<Low[i-1]) && (Low[i-1]<Low[i]) )
{
Cbl[i] = Low[i-2];
bCBL = True;
}
else if (bCBL)
{
if (Low[i] < Cbl[i-1])
{
Cbl[i] = Cbl[i-1];
bCBL = False;
}
else
{
n = nR;
minval[i] = Low[i];
breakloop= False;
for (j = 1; NOT(breakloop) && j <= i; j++)
{
if (Low[i-j] < minval[i])
{
if (n>1)
{
minval[i] = Low[i-j];
n--;
}
else
{
Cbl[i] = Low[i-j];
breakloop=True;
}
}
}
if (Cbl[i] < Cbl[i-1])
Cbl[i] = Cbl[i-1];
}
}
else
{
Cbl[i] = Cbl[i-1];
}
if (Cbl[i]==0)
Cbl[i] = Cbl[i-1];
}
Sell = Close < Cbl;
Plot(Cbl,"",colorLightGrey,1);
Plot(C,"",-1,64);
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Buy =0;
nR=2;
Cbl[nR]=Null;
bCBL=False;
for( i=nR; i < BarCount; i++)
{
if( (Low[i-2]<Low[i-1]) && (Low[i-1]<Low[i]) )
{
Cbl[i] = Low[i-2];
bCBL = True;
}
else if (bCBL)
{
if (Low[i] < Cbl[i-1])
{
Cbl[i] = Cbl[i-1];
bCBL = False;
}
else
{
n = nR;
minval[i] = Low[i];
breakloop= False;
for (j = 1; NOT(breakloop) && j <= i; j++)
{
if (Low[i-j] < minval[i])
{
if (n>1)
{
minval[i] = Low[i-j];
n--;
}
else
{
Cbl[i] = Low[i-j];
breakloop=True;
}
}
}
if (Cbl[i] < Cbl[i-1])
Cbl[i] = Cbl[i-1];
}
}
else
{
Cbl[i] = Cbl[i-1];
}
if (Cbl[i]==0)
Cbl[i] = Cbl[i-1];
}
Sell = Close < Cbl;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Plot(Cbl,"",colorLightGrey,1);
Plot(C,"",-1,64);
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Sell = Cross( Cbl,Close);
Is there a way that the AFL can be altered so that I can alter the CBL and its colour in Parameters instead of editing the formula?
Plot(Cbl , "Cbl" , ParamColor ( "Cbl Colour" , colorLightGrey ),styleLine);
nR = 2;
nR = Param( "Cbl n lower lows" , 2 , 2 , 6 ,1 );
Can you please tell me how to optimize the 2 values of EMA ( 13 & 22 only) in this equation. I dont want to optimize the 200EMA
Sell = Close < EMA( Close ,200 )
AND EMA( Close , 13 ) < EMA( Close , 22 );
I tried this but it doesnt work.
fast = EMA(C, Optimize("FastEMA", 13, 3, 20, 1));
slow = EMA(C, Optimize("SlowEMA",22, 5, 50, 1));
Buy = Close > EMA( Close , 200 );
Sell = Close < EMA( Close ,200 )
AND EMA( Close , fast ) < EMA( Close , slow );
fast = Optimize("FastEMA", 13, 3, 20, 1);
slow = Optimize("SlowEMA",22, 5, 50, 1);
Buy = Close > EMA( Close , 200 );
Sell = Close < EMA( Close ,200 )
AND EMA( Close , fast ) < EMA( Close , slow );
Hpds=Optimize("hpds",20 , 1 , 25 ,1 );
Lpds=Optimize("lpds",20 , 1 , 25 ,1 );
DonchianUpper =HHV(Ref(H,-1),Hpds);
DonchianLower = LLV(Ref(L,-1),Lpds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;
Plot(DonchianUpper,"DU",colorBlue,styleLine);
Plot(DonchianMiddle,"DM",colorGreen,styleLine);
Plot(DonchianLower,"DL",colorRed,styleLine);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
PlotShapes(Buy*shapeCircle,colorGreen,0,Low);
PlotShapes(Sell*shapeCircle,colorRed,0,High);
Hello and welcome to Aussie Stock Forums!
To gain full access you must register. Registration is free and takes only a few seconds to complete.
Already a member? Log in here.