Good Indicator for Delivery Trading

#1
Hello friends


I have one afl i think its very good for taking delivery trading. in these indicator there are two types of Buy sell Indication one is Ebuy and second is Cbuy. When i use these formula for back testing he filter only Cbuy or Sell But i want only Ebuy or Esell filter formula so any one can make changes pls try these is very usefull.

Here i give afl code below.

//Moving Average Based Trading Advanced version
// Abnash Singh
// 30th October 2011
// [email protected]

SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;



SetChartOptions(0,chartShowArrows|chartShowDates);
showsig=ParamList("Show Signals","YES|NO");
Showprice=ParamList("Show Buy/Sell Prices","YES|NO");

Plot( C, "Close", ParamColor("Color", colorBlack), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

period = Param("Period", 13, 1, 240, 1);
mult = Param("Multiplier", 2.21, 0, 3, 0.01);
A=EMA (RSI(14),5);
B=EMA (RSI(21),5);

f=ATR(period);
x=5;
VS[0] = Close[0];
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;
for( i = period+1; i < BarCount; i++ )
{

vs = vs[i-1];
trend = trend[i-1];
highC = HighC[i-1];
lowc = lowc[i-1];

if ((trend>=0) AND ( C <VS))
{
trend =-1;
HighC = C;
lowc = C;
}

if ((trend<=0) AND (C >VS))
{
trend=1;
HighC = C;
lowc = C;
}

if (trend==-1)
{
if (C<lowc) lowc = C;
VS= lowc+ (mult*f);
}


if (trend==1)
{
if (C>HighC) HighC = C;
VS= HighC-(mult*f);
}

}
Pribbon=ParamList("Ribbon? ", "Yes|No");
if (Pribbon=="Yes")
{
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( trend==1, colorGreen, IIf( trend==-1, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
}




_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), ParamStyle( "Style", styleHistogram | styleThick |styleOwnScale, maskHistogram ),7 );
_SECTION_END();

TrailStop = HHV( C - 2.1 * ATR(3), 7);

//trailstop=(IIf(!downtrend OR uptrend, trailstop, Null));
//Plot( trailstop , "Trailing stop", colorCustom12, 8);

//Plot( IIf(shrttgt<TrailStop,trailstop,(shrttgt+trailstop)/2) , "Trailing stop", colorCustom11, 8);


TrailStop1 = LLV( C + 2.1 * ATR(3), 7);
//trailstop1=(IIf(!uptrend OR downtrend, trailstop1, Null));
//Plot( TrailStop1, "Trailing stop1", colorBlack, 8);



_SECTION_BEGIN("GMMA");
a=C;
g=(EMA(Close,3) * (2 / 4 - 1)-EMA(Close,60) * (2 / 61 - 1)) / (2 /4- 2 /61);
e=Ref(g,-1);
Plot (EMA(a,3), "3ema", colorBlue,styleNoLabel);
Plot (EMA(a,5), "5ema", colorBlue,styleNoLabel);
Plot (EMA(a,8), "8ema", colorBlue,styleNoLabel);
Plot (EMA(a,10), "10ema", colorBlue,styleNoLabel);
Plot (EMA(a,12), "12ema", colorBlue,styleNoLabel);
Plot (EMA(a,15), "15ema", colorBlue,styleNoLabel);

Plot (EMA(a,30), "30ema", colorRed,styleNoLabel);
Plot (EMA(a,35), "35ema", colorRed,styleNoLabel);
Plot (EMA(a,40), "40ema", colorRed,styleNoLabel);
Plot (EMA(a,45), "45ema", colorRed,styleNoLabel);
Plot (EMA(a,50), "50ema", colorRed,styleNoLabel);
Plot (EMA(a,55), "55ema", colorRed,styleNoLabel);
Plot (EMA(a,60), "60ema", colorRed,styleNoLabel);
//Plot(C,"close", colorBlack,styleCandle);

Cond1=StochK(14)>StochD(14);
Cond2=StochK(14)<StochD(14);
Buy=Cross(EMA(C,15),EMA(C,60));
Sell=Cross(EMA(C,60),EMA(C,15));

Filter = Buy OR Sell;

_SECTION_END();
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar );
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.0);
Cond13=PDI()>MDI();

_SECTION_END();

_SECTION_END();

_SECTION_BEGIN("my FIST");

Slowavg=Param("Slow Average",10,10,70,1);
Fastavg=Param("Fast Average",3,1,15,1);
gapx=Param("Tolerance",3,0,10,.001);
SPsignals=ParamList("Generate new Buy/Sells after SP","YES|NO");
n4=4;
Datex=DateNum();
Buy1=Cross(EMA(C,fastavg),EMA(C,slowavg));
Sell1=Cross(EMA(C,slowavg),EMA(C,fastavg));

EMA3=EMA(C,3);
EMA30=EMA(C,30);
Lastsig=0;
diff=5;
for (i=1;i<BarCount;i++)
{
if(Datex!=Datex[i-1] AND Interval()<86400)
{
if(EMA3> EMa30 ) buy1=1;
if(EMA3< EMA30 ) Sell1=1;
}
if(Buy1)
{
if(Sell1[i-1])
{
Buy1=0;
Sell1[i-1]=0;
}
}
if(Sell1)
{
if(Buy1[i-1])
{
Buy1[i-1]=0;
Sell1=0;
}
}
}
gapema=abs(EMA(C,fastavg)-EMA(C,slowavg));

Nowbuy=0;Nowsell=0;starti=0;Lastbuy=Lastsell=0;
avp=(O+C)/2;
for (i=1;i<BarCount;i++)
{
if(Datex!=Datex[i-1])
{
Nowbuy=0;Nowsell=0;starti=0;Lastbuy=Lastsell=0;
}
if(Buy1 )
{
if (lastbuy==0)Nowbuy=1;
Nowsell=0;
Buy1=0;
}
if(Sell1 )
{
Nowbuy=0;
if(Lastsell==0)Nowsell=1;
Sell1=0;
}
if (Nowbuy==1 AND gapema>gapx)
{
Buy1=1;
Nowbuy=0;
Nowsell=0;
}

if (Nowsell==1 AND gapema>gapx )
{
Sell1=1;
starti=i;
Nowsell=0;
Nowbuy=0;
}
if (Buy1)
{
Lastbuy=1;
Lastsell=0;
}
if (Sell1)
{
Lastbuy=0;
Lastsell=1;
}


}

slhigh=HHV(H,BarsSince(Buy1));
sllow=LLV(L,BarsSince(Sell1));
gapy=Param("SP",10,0,50,0.01);
Lastshort=0;priceatcover=priceatshort=0;Cover2=0;Lastcover=0;Sell2=0;Lastsell=newbuy=newshort=0;
for (i=1; i<BarCount-1;i++)
{
if(Datex!=Datex[i-1] )
{
Lastshort=0;priceatsell=priceatcover=priceatshort=0;Lastcover=0;Lastsell=newbuy=newshort=0;
}
if (Sell1)
{
Lastshort=1;
Lastbuy=0;
Lastsell=0;
starti=i;
priceatshort=H;

}

if(Buy1)
{
Lastbuy=1;
Lastshort=0;
Lastcover=0;
starti=i;
priceatbuy=L;
}
if (spsignals=="YES")
{
if (newshort==1 AND avp<priceatcover-n4 AND O>C)
{
sell1=1;
newshort=0;
}
}


if (C-sllow>gapy AND Lastshort==1 AND Lastcover==0 AND I>starti AND sllow==sllow[i-1])
{
Cover2=1;
Lastcover=1;
priceatcover=C;
newshort=1;

}
if ((Lastcover==1 AND C<priceatcover-(gapy/2)) )Lastcover=0;
if (spsignals=="YES")
{
if (newbuy==1 AND avp>priceatsell+n4 AND O<C)
{
Buy1=1;
newbuy=0;
}
}


if(slhigh-C>gapy AND Lastbuy==1 AND Lastsell==0 AND i>starti AND slhigh==slhigh[i-1])

{
Sell2=1;
Lastsell=1;
// priceatsell=avp;
priceatsell=C;
}
if ((Lastsell==1 AND C>priceatsell+(gapy/2)) )Lastsell=0;



}



shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
shape1 = Buy1 * shapeUpTriangle + Sell1 * shapeDownTriangle;
shape2 = Cover2 * shapeHollowUpArrow+ Sell2*shapeHollowDownArrow;
if(showsig=="YES")
{
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ),0, IIf( Buy, Low, High ) );
PlotShapes( shape1, IIf( Buy1, colorBlue, colorRed ),0, IIf( Buy1, Low, High ) );
PlotShapes( shape2, IIf( Cover2, colorGreen, colorGreen ),0, IIf( Cover2, Low, High ) );
}
GraphXSpace = 5;
dist = 5*ATR(10);
mth=int(DateNum()/100)-int(DateNum()/10000)*100;
Currmthstart=int(DateNum()/100)*100;

Profit=profitmth=0;
Lastsig=Lastbuysig=Lastsellsig=Lastcoversig=Lastshortsig=0;
for( i = 0; i < BarCount; i++ )
{
if (i>0)
{
if(mth!=mth[i-1])
{
profitmth=0;
}
else
{
profitmth=profitmth[i-1];
}

}

if(i>0)profit=profit[i-1];
if((i>0 AND Datex!= Datex[i-1]) OR i==(BarCount-1))
{
if(i!=BarCount-1)
{
if (Lastbuysig==1)profit=profit+avp[i-1]-priceatbuy;
if (Lastshortsig==1)profit=profit+priceatshort-avp[i-1];
}
else
{
if (Lastbuysig==1)profit=profit+avp-priceatbuy;
if (Lastshortsig==1)profit=profit+priceatshort-avp;
}

if (showprice=="YES" AND Interval()< 86400)PlotText( "Profit\n" + WriteVal(Profit[ i ],1.0) , i, L[ i ]-dist/2, colorBlack );
if(Datex>Currmthstart AND mth==mth[i-1] )
{
ProfitMth=profitmth[i-1]+profit;
}


profit=0;
Lastsig=Lastbuysig=Lastsellsig=Lastcoversig=Lastshortsig=0;
}




if (Buy1)
{
Lastbuysig=1;
priceatbuy=avp;
if (Lastshortsig==1)
{
profit=profit+priceatshort-avp;
Lastshortsig=0;
}
}




if (Sell1)
{
Lastshortsig=1;
priceatshort=avp;
if (Lastbuysig==1)
{
profit=profit+avp-priceatbuy;
Lastbuysig=0;
}

}
if (Cover2)
{
Lastcoversig=1;
priceatcover=avp;
if (Lastshortsig==1)
{
profit=profit+priceatshort-avp;
Lastshortsig=0;
}
}
if (Sell2)
{
Lastsellsig=1;
priceatsell=avp;
if (Lastbuysig==1)
{
profit=profit+avp-priceatbuy;
Lastbuysig=0;
}

}

if(showprice=="YES" )
{
if( Buy ) PlotText( "CBuy\n@" + avp[ i ] , i, L[ i ]-dist, colorBlue );
if( Sell ) PlotText( "CSell\n@" + avp[ i ], i, H[ i ]+dist, colorBlue);
if( Buy1 ) PlotText( "EBuy\n@" + avp[ i ], i, L[ i ]-dist, colorBlue );
if( Sell1 ) PlotText( "ESell\n@" + avp[ i ], i, H[ i ]+dist, colorBlue);
}
}
Plot( 1, "", IIf(EMA(C,15)>EMA(C,60) , colorPaleGreen, colorRose ),styleArea | styleOwnScale, 0, 1 );
_SECTION_END();


_SECTION_BEGIN("Volume At Price");
//PlotVAPOverlay(Param("Lines", 1000, 100, 1000, 10), Param("Width", 15, 1, 100, 1), ParamColor("Color", colorBlue), ParamToggle("Side", "Left|Right", 1) | 4 *ParamToggle("Z-order", "On top|Behind", 1));

_SECTION_END();
Title = "Moving Average TRADES "+Date()+" "+ Interval(format=2)+" "+Name()+" "+"O "+WriteVal(O,1.2)+" "+"H "+WriteVal(H,1.2)+" L"+WriteVal(L,1.2)+" C "+WriteVal(C,1.2)+" Vol "+WriteVal(V,1.0)+" "+EncodeColor(colorRed)+WriteIf(EMA(C,3)>EMA(C,16),EncodeColor(colorGreen),EncodeColor(colorRed))+" EMA 3/16 "+WriteVal(EMA(C,3),1.0)+"/"+WriteVal(EMA(C,16),1.0)+WriteIf(EMA(C,15)>EMA(C,60),EncodeColor(colorGreen),EncodeColor(colorRed))+" EMA 15/60 "+WriteVal(EMA(C,15),1.0)+"/"+WriteVal(EMA(C,60),1.0)+" ProfitMth "+WriteVal(profitmth+profit,1.0)+" Bar Secs Left "+ WriteVal(secstogo,1.0)+" "+
"\n"+EncodeColor(colorRed)+" Stoploss " +WriteVal(Trailstop,1.2)
;


Thanks
 

velmont86

Active Member
#5
Hello friends


I have one afl i think its very good for taking delivery trading. in these indicator there are two types of Buy sell Indication one is Ebuy and second is Cbuy. When i use these formula for back testing he filter only Cbuy or Sell But i want only Ebuy or Esell filter formula so any one can make changes pls try these is very usefull.

Here i give afl code below.

//Moving Average Based Trading Advanced version
// Abnash Singh
// 30th October 2011
// [email protected]

SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;



SetChartOptions(0,chartShowArrows|chartShowDates);
showsig=ParamList("Show Signals","YES|NO");
Showprice=ParamList("Show Buy/Sell Prices","YES|NO");

Plot( C, "Close", ParamColor("Color", colorBlack), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

period = Param("Period", 13, 1, 240, 1);
mult = Param("Multiplier", 2.21, 0, 3, 0.01);
A=EMA (RSI(14),5);
B=EMA (RSI(21),5);

f=ATR(period);
x=5;
VS[0] = Close[0];
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;
for( i = period+1; i < BarCount; i++ )
{

vs = vs[i-1];
trend = trend[i-1];
highC = HighC[i-1];
lowc = lowc[i-1];

if ((trend>=0) AND ( C <VS))
{
trend =-1;
HighC = C;
lowc = C;
}

if ((trend<=0) AND (C >VS))
{
trend=1;
HighC = C;
lowc = C;
}

if (trend==-1)
{
if (C<lowc) lowc = C;
VS= lowc+ (mult*f);
}


if (trend==1)
{
if (C>HighC) HighC = C;
VS= HighC-(mult*f);
}

}
Pribbon=ParamList("Ribbon? ", "Yes|No");
if (Pribbon=="Yes")
{
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( trend==1, colorGreen, IIf( trend==-1, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
}




_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), ParamStyle( "Style", styleHistogram | styleThick |styleOwnScale, maskHistogram ),7 );
_SECTION_END();

TrailStop = HHV( C - 2.1 * ATR(3), 7);

//trailstop=(IIf(!downtrend OR uptrend, trailstop, Null));
//Plot( trailstop , "Trailing stop", colorCustom12, 8);

//Plot( IIf(shrttgt<TrailStop,trailstop,(shrttgt+trailstop)/2) , "Trailing stop", colorCustom11, 8);


TrailStop1 = LLV( C + 2.1 * ATR(3), 7);
//trailstop1=(IIf(!uptrend OR downtrend, trailstop1, Null));
//Plot( TrailStop1, "Trailing stop1", colorBlack, 8);



_SECTION_BEGIN("GMMA");
a=C;
g=(EMA(Close,3) * (2 / 4 - 1)-EMA(Close,60) * (2 / 61 - 1)) / (2 /4- 2 /61);
e=Ref(g,-1);
Plot (EMA(a,3), "3ema", colorBlue,styleNoLabel);
Plot (EMA(a,5), "5ema", colorBlue,styleNoLabel);
Plot (EMA(a,8), "8ema", colorBlue,styleNoLabel);
Plot (EMA(a,10), "10ema", colorBlue,styleNoLabel);
Plot (EMA(a,12), "12ema", colorBlue,styleNoLabel);
Plot (EMA(a,15), "15ema", colorBlue,styleNoLabel);

Plot (EMA(a,30), "30ema", colorRed,styleNoLabel);
Plot (EMA(a,35), "35ema", colorRed,styleNoLabel);
Plot (EMA(a,40), "40ema", colorRed,styleNoLabel);
Plot (EMA(a,45), "45ema", colorRed,styleNoLabel);
Plot (EMA(a,50), "50ema", colorRed,styleNoLabel);
Plot (EMA(a,55), "55ema", colorRed,styleNoLabel);
Plot (EMA(a,60), "60ema", colorRed,styleNoLabel);
//Plot(C,"close", colorBlack,styleCandle);

Cond1=StochK(14)>StochD(14);
Cond2=StochK(14)<StochD(14);
Buy=Cross(EMA(C,15),EMA(C,60));
Sell=Cross(EMA(C,60),EMA(C,15));

Filter = Buy OR Sell;

_SECTION_END();
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar );
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.0);
Cond13=PDI()>MDI();

_SECTION_END();

_SECTION_END();

_SECTION_BEGIN("my FIST");

Slowavg=Param("Slow Average",10,10,70,1);
Fastavg=Param("Fast Average",3,1,15,1);
gapx=Param("Tolerance",3,0,10,.001);
SPsignals=ParamList("Generate new Buy/Sells after SP","YES|NO");
n4=4;
Datex=DateNum();
Buy1=Cross(EMA(C,fastavg),EMA(C,slowavg));
Sell1=Cross(EMA(C,slowavg),EMA(C,fastavg));

EMA3=EMA(C,3);
EMA30=EMA(C,30);
Lastsig=0;
diff=5;
for (i=1;i<BarCount;i++)
{
if(Datex!=Datex[i-1] AND Interval()<86400)
{
if(EMA3> EMa30 ) buy1=1;
if(EMA3< EMA30 ) Sell1=1;
}
if(Buy1)
{
if(Sell1[i-1])
{
Buy1=0;
Sell1[i-1]=0;
}
}
if(Sell1)
{
if(Buy1[i-1])
{
Buy1[i-1]=0;
Sell1=0;
}
}
}
gapema=abs(EMA(C,fastavg)-EMA(C,slowavg));

Nowbuy=0;Nowsell=0;starti=0;Lastbuy=Lastsell=0;
avp=(O+C)/2;
for (i=1;i<BarCount;i++)
{
if(Datex!=Datex[i-1])
{
Nowbuy=0;Nowsell=0;starti=0;Lastbuy=Lastsell=0;
}
if(Buy1 )
{
if (lastbuy==0)Nowbuy=1;
Nowsell=0;
Buy1=0;
}
if(Sell1 )
{
Nowbuy=0;
if(Lastsell==0)Nowsell=1;
Sell1=0;
}
if (Nowbuy==1 AND gapema>gapx)
{
Buy1=1;
Nowbuy=0;
Nowsell=0;
}

if (Nowsell==1 AND gapema>gapx )
{
Sell1=1;
starti=i;
Nowsell=0;
Nowbuy=0;
}
if (Buy1)
{
Lastbuy=1;
Lastsell=0;
}
if (Sell1)
{
Lastbuy=0;
Lastsell=1;
}


}

slhigh=HHV(H,BarsSince(Buy1));
sllow=LLV(L,BarsSince(Sell1));
gapy=Param("SP",10,0,50,0.01);
Lastshort=0;priceatcover=priceatshort=0;Cover2=0;Lastcover=0;Sell2=0;Lastsell=newbuy=newshort=0;
for (i=1; i<BarCount-1;i++)
{
if(Datex!=Datex[i-1] )
{
Lastshort=0;priceatsell=priceatcover=priceatshort=0;Lastcover=0;Lastsell=newbuy=newshort=0;
}
if (Sell1)
{
Lastshort=1;
Lastbuy=0;
Lastsell=0;
starti=i;
priceatshort=H;

}

if(Buy1)
{
Lastbuy=1;
Lastshort=0;
Lastcover=0;
starti=i;
priceatbuy=L;
}
if (spsignals=="YES")
{
if (newshort==1 AND avp<priceatcover-n4 AND O>C)
{
sell1=1;
newshort=0;
}
}


if (C-sllow>gapy AND Lastshort==1 AND Lastcover==0 AND I>starti AND sllow==sllow[i-1])
{
Cover2=1;
Lastcover=1;
priceatcover=C;
newshort=1;

}
if ((Lastcover==1 AND C<priceatcover-(gapy/2)) )Lastcover=0;
if (spsignals=="YES")
{
if (newbuy==1 AND avp>priceatsell+n4 AND O<C)
{
Buy1=1;
newbuy=0;
}
}


if(slhigh-C>gapy AND Lastbuy==1 AND Lastsell==0 AND i>starti AND slhigh==slhigh[i-1])

{
Sell2=1;
Lastsell=1;
// priceatsell=avp;
priceatsell=C;
}
if ((Lastsell==1 AND C>priceatsell+(gapy/2)) )Lastsell=0;



}



shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
shape1 = Buy1 * shapeUpTriangle + Sell1 * shapeDownTriangle;
shape2 = Cover2 * shapeHollowUpArrow+ Sell2*shapeHollowDownArrow;
if(showsig=="YES")
{
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ),0, IIf( Buy, Low, High ) );
PlotShapes( shape1, IIf( Buy1, colorBlue, colorRed ),0, IIf( Buy1, Low, High ) );
PlotShapes( shape2, IIf( Cover2, colorGreen, colorGreen ),0, IIf( Cover2, Low, High ) );
}
GraphXSpace = 5;
dist = 5*ATR(10);
mth=int(DateNum()/100)-int(DateNum()/10000)*100;
Currmthstart=int(DateNum()/100)*100;

Profit=profitmth=0;
Lastsig=Lastbuysig=Lastsellsig=Lastcoversig=Lastshortsig=0;
for( i = 0; i < BarCount; i++ )
{
if (i>0)
{
if(mth!=mth[i-1])
{
profitmth=0;
}
else
{
profitmth=profitmth[i-1];
}

}

if(i>0)profit=profit[i-1];
if((i>0 AND Datex!= Datex[i-1]) OR i==(BarCount-1))
{
if(i!=BarCount-1)
{
if (Lastbuysig==1)profit=profit+avp[i-1]-priceatbuy;
if (Lastshortsig==1)profit=profit+priceatshort-avp[i-1];
}
else
{
if (Lastbuysig==1)profit=profit+avp-priceatbuy;
if (Lastshortsig==1)profit=profit+priceatshort-avp;
}

if (showprice=="YES" AND Interval()< 86400)PlotText( "Profit\n" + WriteVal(Profit[ i ],1.0) , i, L[ i ]-dist/2, colorBlack );
if(Datex>Currmthstart AND mth==mth[i-1] )
{
ProfitMth=profitmth[i-1]+profit;
}


profit=0;
Lastsig=Lastbuysig=Lastsellsig=Lastcoversig=Lastshortsig=0;
}




if (Buy1)
{
Lastbuysig=1;
priceatbuy=avp;
if (Lastshortsig==1)
{
profit=profit+priceatshort-avp;
Lastshortsig=0;
}
}




if (Sell1)
{
Lastshortsig=1;
priceatshort=avp;
if (Lastbuysig==1)
{
profit=profit+avp-priceatbuy;
Lastbuysig=0;
}

}
if (Cover2)
{
Lastcoversig=1;
priceatcover=avp;
if (Lastshortsig==1)
{
profit=profit+priceatshort-avp;
Lastshortsig=0;
}
}
if (Sell2)
{
Lastsellsig=1;
priceatsell=avp;
if (Lastbuysig==1)
{
profit=profit+avp-priceatbuy;
Lastbuysig=0;
}

}

if(showprice=="YES" )
{
if( Buy ) PlotText( "CBuy\n@" + avp[ i ] , i, L[ i ]-dist, colorBlue );
if( Sell ) PlotText( "CSell\n@" + avp[ i ], i, H[ i ]+dist, colorBlue);
if( Buy1 ) PlotText( "EBuy\n@" + avp[ i ], i, L[ i ]-dist, colorBlue );
if( Sell1 ) PlotText( "ESell\n@" + avp[ i ], i, H[ i ]+dist, colorBlue);
}
}
Plot( 1, "", IIf(EMA(C,15)>EMA(C,60) , colorPaleGreen, colorRose ),styleArea | styleOwnScale, 0, 1 );
_SECTION_END();


_SECTION_BEGIN("Volume At Price");
//PlotVAPOverlay(Param("Lines", 1000, 100, 1000, 10), Param("Width", 15, 1, 100, 1), ParamColor("Color", colorBlue), ParamToggle("Side", "Left|Right", 1) | 4 *ParamToggle("Z-order", "On top|Behind", 1));

_SECTION_END();
Title = "Moving Average TRADES "+Date()+" "+ Interval(format=2)+" "+Name()+" "+"O "+WriteVal(O,1.2)+" "+"H "+WriteVal(H,1.2)+" L"+WriteVal(L,1.2)+" C "+WriteVal(C,1.2)+" Vol "+WriteVal(V,1.0)+" "+EncodeColor(colorRed)+WriteIf(EMA(C,3)>EMA(C,16),EncodeColor(colorGreen),EncodeColor(colorRed))+" EMA 3/16 "+WriteVal(EMA(C,3),1.0)+"/"+WriteVal(EMA(C,16),1.0)+WriteIf(EMA(C,15)>EMA(C,60),EncodeColor(colorGreen),EncodeColor(colorRed))+" EMA 15/60 "+WriteVal(EMA(C,15),1.0)+"/"+WriteVal(EMA(C,60),1.0)+" ProfitMth "+WriteVal(profitmth+profit,1.0)+" Bar Secs Left "+ WriteVal(secstogo,1.0)+" "+
"\n"+EncodeColor(colorRed)+" Stoploss " +WriteVal(Trailstop,1.2)
;


Thanks





please post the rules also .....
 
#6
Hello,

Rule is When i go automatic Analyses window i want only ebuy or esell call filter no considor cbuy or csell.

When Ebuy call is display buy at same candel closing price and when Esell window is dispaly sell same candel closing price.

i want back tested these last 5 years. only ebuy or esell call.
 
#7
HI FRIENDS
This afl is what is called GMMA ,it is a part of pattern explorer codes.
If you dont have,try to get PE-pattern explorer and install it in Amibroker.

The trick to trade with GMMA is like this
1 Wait till Blue color lines go above Orange colored lines and separate,and Orange color lines separate
2 Let price go above both groups of lines
3.Setup BAR location choose a setup bar- after spotting a time where SHORT MA ABOVE LONG MA,both short ma and long ma lines are parallel,not mixed,choose a price bar THAT CLOSED
ABOVE THE UPPERMOST MOVING AVERAGE LINE. THIS IS MUST CONDITION FOR SETUP BAR.

4 Mark High and Low of this bar,Draw horizontal lines
5 your long entry is above high of setup bar,low of the setup bar is your stoploss, the risk is bar height itself.
6 once you enter use a trailing stop to lock profits
7 if things go wrong exit at setup bar low
that is all.A SIMPLE TARGET RULE CAN BE TAKE PROFIT WHEN PRICE PIERCES DOWN TOP 3 MOVING AVERAGE LINES.

you can invert his process for short trade
wait for short ma lines go below long ma lines,wait for both lines go separate and bcome parallel,wait for price go below blu lines,find a setup bar after both groups of lines become parallel & separated reasonably,bracket HI &LOW of the setup bar,enter short on price break below low of setup bar
risk is always limitd to setup bar height or distance between hi &lo of setup bar. Trick is avoid choosing a wide bar with long risk,instead choose a short bar with reasonable low risk (like 2 to 4 units.)
 

Attachments

Last edited:

Similar threads