Request help in inserting Buy/Sell signal

#1
Hi,

Please could you help me in inserting Buy and Sell signals in the below GMMA formula. The conditions are as below

1)When the price goes up from below the fastest EMA (i.e.EMA2) it should give buy call.
2)When the price goes down from above the slowest EMA (i.e.EMA60) it should give sell call.

_SECTION_BEGIN("Guppy Multiple Moving Average");

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",1),ParamColor("Lower Chart",1),ParamColor("Titleblock",colorPaleBlue));


barcolor = IIf(C >= O, colorGreen, colorDarkRed);
SetBarFillColor( barcolor );
Plot( C, "", IIf( C > O,colorLightBlue, colorLightBlue ), styleCandle );
FastMA_UP = ParamColor("FastUP", colorGreen);
FastMA_Down = ParamColor("FastDOWN", colorRed);
SlowMA_UP = ParamColor("SlowUP", colorLightBlue);
SlowMA_Down = ParamColor("SlowDOWN", colorDarkBlue);

FAST2=EMA(C, 3);
FAST5=EMA(C, 5);
FAST8=EMA(C, 8);
FAST10=EMA(C, 10);
FAST12=EMA(C, 12);
FAST15=EMA(C, 15);

Slow30=EMA(C, 30);
Slow35=EMA(C, 35);
Slow40=EMA(C, 40);
Slow45=EMA(C, 45);
Slow50=EMA(C, 50);
Slow60=EMA(C, 60);


Plot(FAST2,"" , IIf(FAST2> Ref(FAST2,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST5,"" , IIf(FAST5> Ref(FAST5,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST8,"" , IIf(FAST8> Ref(FAST8,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST10,"" , IIf(FAST10> Ref(FAST10,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST12,"" ,IIf(FAST10> Ref(FAST10,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST15,"" , IIf(FAST15> Ref(FAST15,-1),FastMA_UP,FastMA_Down), styleLine);

Plot(Slow30,"" , IIf(Slow30> Ref(Slow30,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow35,"" , IIf(Slow35> Ref(Slow35,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow40,"" , IIf(Slow40> Ref(Slow40,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow45,"" , IIf(Slow45> Ref(Slow45,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow50,"" , IIf(Slow50> Ref(Slow50,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow60,"" , IIf(Slow60> Ref(Slow60,-1),SlowMA_UP,SlowMA_Down), styleLine);

Plot( EMA( C, 89 ),"" , colorBlack, styleDashed );
Plot( EMA( C, 144 ),"" , colorViolet, styleLine );
Plot( EMA( C, 200 ),"" , colorOrange, styleThick );
_SECTION_END();

Also kindly guide me in how to back test it.

Thanking you in anticipation.

Regards
 
Last edited:
#2
Try below one and enjoy.

_SECTION_BEGIN("Guppy Multiple Moving Average");

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",1),ParamColor("Lower Chart",1),ParamColor("Titleblock",colorPaleBlue));


barcolor = IIf(C >= O, colorGreen, colorDarkRed);
SetBarFillColor( barcolor );
Plot( C, "", IIf( C > O,colorLightBlue, colorLightBlue ), styleCandle );
FastMA_UP = ParamColor("FastUP", colorGreen);
FastMA_Down = ParamColor("FastDOWN", colorRed);
SlowMA_UP = ParamColor("SlowUP", colorLightBlue);
SlowMA_Down = ParamColor("SlowDOWN", colorDarkBlue);

FAST2=EMA(C, 3);
FAST5=EMA(C, 5);
FAST8=EMA(C, 8);
FAST10=EMA(C, 10);
FAST12=EMA(C, 12);
FAST15=EMA(C, 15);

Slow30=EMA(C, 30);
Slow35=EMA(C, 35);
Slow40=EMA(C, 40);
Slow45=EMA(C, 45);
Slow50=EMA(C, 50);
Slow60=EMA(C, 60);


Plot(FAST2,"" , IIf(FAST2> Ref(FAST2,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST5,"" , IIf(FAST5> Ref(FAST5,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST8,"" , IIf(FAST8> Ref(FAST8,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST10,"" , IIf(FAST10> Ref(FAST10,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST12,"" ,IIf(FAST10> Ref(FAST10,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST15,"" , IIf(FAST15> Ref(FAST15,-1),FastMA_UP,FastMA_Down), styleLine);

Plot(Slow30,"" , IIf(Slow30> Ref(Slow30,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow35,"" , IIf(Slow35> Ref(Slow35,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow40,"" , IIf(Slow40> Ref(Slow40,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow45,"" , IIf(Slow45> Ref(Slow45,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow50,"" , IIf(Slow50> Ref(Slow50,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow60,"" , IIf(Slow60> Ref(Slow60,-1),SlowMA_UP,SlowMA_Down), styleLine);

Plot( EMA( C, 89 ),"" , colorBlack, styleDashed );
Plot( EMA( C, 144 ),"" , colorViolet, styleLine );
Plot( EMA( C, 200 ),"" , colorOrange, styleThick );




Buy= Cross(FAST2,Slow60);
Sell=Cross(Slow60,FAST2);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

PlotShapes(IIf(Buy, shapeSmallUpTriangle, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSmallDownTriangle, shapeNone),colorWhite, 0,H, Offset=-45);


_SECTION_END();
 
#3
Thanks a ton bro.

I wish I could have the buy call when price crosses Fastest EMA from below and sell call when price crosses Slowest EMA from above.

Can you do that for me?I tried doing it but I couldn't.

Regards.
 
#4
Thanks a ton bro.

I wish I could have the buy call when price crosses Fastest EMA from below and sell call when price crosses Slowest EMA from above.

Can you do that for me?I tried doing it but I couldn't.

Regards.
In the above code change this
Code:
Buy= Cross(FAST2,Slow60);
Sell=Cross(Slow60,FAST2);


to this . . .



Code:
Buy= Cross(C, FAST2);
Sell=Cross(Slow60, C);
Cheers
:thumb:
 
#6
Hello,
what does offset=.45 does in this code?
PlotShapes(IIf(Buy, shapeSmallUpTriangle, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSmallDownTriangle, shapeNone),colorWhite, 0,H, Offset=-45);



Try below one and enjoy.

_SECTION_BEGIN("Guppy Multiple Moving Average");

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",1),ParamColor("Lower Chart",1),ParamColor("Titleblock",colorPaleBlue));


barcolor = IIf(C >= O, colorGreen, colorDarkRed);
SetBarFillColor( barcolor );
Plot( C, "", IIf( C > O,colorLightBlue, colorLightBlue ), styleCandle );
FastMA_UP = ParamColor("FastUP", colorGreen);
FastMA_Down = ParamColor("FastDOWN", colorRed);
SlowMA_UP = ParamColor("SlowUP", colorLightBlue);
SlowMA_Down = ParamColor("SlowDOWN", colorDarkBlue);

FAST2=EMA(C, 3);
FAST5=EMA(C, 5);
FAST8=EMA(C, 8);
FAST10=EMA(C, 10);
FAST12=EMA(C, 12);
FAST15=EMA(C, 15);

Slow30=EMA(C, 30);
Slow35=EMA(C, 35);
Slow40=EMA(C, 40);
Slow45=EMA(C, 45);
Slow50=EMA(C, 50);
Slow60=EMA(C, 60);


Plot(FAST2,"" , IIf(FAST2> Ref(FAST2,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST5,"" , IIf(FAST5> Ref(FAST5,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST8,"" , IIf(FAST8> Ref(FAST8,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST10,"" , IIf(FAST10> Ref(FAST10,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST12,"" ,IIf(FAST10> Ref(FAST10,-1),FastMA_UP,FastMA_Down), styleLine);
Plot(FAST15,"" , IIf(FAST15> Ref(FAST15,-1),FastMA_UP,FastMA_Down), styleLine);

Plot(Slow30,"" , IIf(Slow30> Ref(Slow30,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow35,"" , IIf(Slow35> Ref(Slow35,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow40,"" , IIf(Slow40> Ref(Slow40,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow45,"" , IIf(Slow45> Ref(Slow45,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow50,"" , IIf(Slow50> Ref(Slow50,-1),SlowMA_UP,SlowMA_Down), styleLine);
Plot(Slow60,"" , IIf(Slow60> Ref(Slow60,-1),SlowMA_UP,SlowMA_Down), styleLine);

Plot( EMA( C, 89 ),"" , colorBlack, styleDashed );
Plot( EMA( C, 144 ),"" , colorViolet, styleLine );
Plot( EMA( C, 200 ),"" , colorOrange, styleThick );




Buy= Cross(FAST2,Slow60);
Sell=Cross(Slow60,FAST2);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

PlotShapes(IIf(Buy, shapeSmallUpTriangle, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSmallDownTriangle, shapeNone),colorWhite, 0,H, Offset=-45);


_SECTION_END();
 

Similar threads