AFL Buy Signals

Hello. Please rate this code when it hits the price Collision the movings Buy a signal. Thanks

type or paste code here

_SECTION_BEGIN("Unnamed 2");
GfxSelectFont("Arial Bold", Status("pxheight")/20);
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor("Text Color", ColorHSB( 42, 42, 42 ) ));
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/10);

GfxSelectFont("Arial Bold", Status("pxheight")/30);
GfxTextOut( "", Status("pxwidth")/2, Status("pxheight")/30);
GfxSelectFont("Arial Bold", Status("pxheight")/20);
_SECTION_END();

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 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("WMA");

Periods1 = Param("Periods1",20,1,750,2);
Periods2 = Param("Periods2",50,2,750,2);
Periods3 = Param("Periods3",100,3,750,2);
Periods4 = Param("Periods4",200,4,750,2);
Periods5 = Param("Periods5",360,5,750,2);

WMA1 = WMA(C,Periods1);
WMA2 = WMA(C,Periods2);
WMA3 = WMA(C,Periods3);
WMA4 = WMA(C,Periods4);
WMA5 = WMA(C,Periods5);

Plot(WMA1,"wma1",ParamColor("color1",colorBlue),styleLine);
Plot(WMA2,"wma2",ParamColor("color2",colorGreen),styleLine);
Plot(WMA3,"wma3",ParamColor("color3",colorGold),styleLine);
Plot(WMA4,"wma4",ParamColor("color4",colorCustom12),styleLine);
Plot(WMA5,"wma5",ParamColor("color5",colorRed),styleLine);

_SECTION_END();

Another blind copy/paste from the internet:
Link # 1
Link # 2
Link # 3

Probable "Help Vampire"! :relieved:

(I misunderstood you because my language is Persian and I know a little English) I want this code to be rewritten as long as the price of the chart touches the Moving 400 to issue a purchase signal.

Thought that you wanted someone to backtest and "rate" the code as good or bad.

Thanks for the detail this time! So, if I am correct you want to Buy when Price (assuming as Close) crosses its WMA of 400 period and Sell otherwise, is that right?

For e.g.:

//https://forum.amibroker.com/t/afl-signals-buy/12805/4
_SECTION_BEGIN( "Signals using WMA" );
	 SetChartOptions( 0, chartShowDates );
	 
	 Price = ParamField( "Price Field", 3 );
	 per = Param( "WMA Period", 400, 1, 1000, 1 );
	 ClrWMA = ParamColor( "WMA Color", ColorRGB( 70, 160, 255 ) );
	 
	 WMAc = WMA( Price, per );
	 
	 Buy = Cross( C, WMAc );
	 Sell = Cross( WMAc, C );
	 
	 Buy = Cover = ExRem( Buy, Sell );
	 Sell = Short = ExRem( Sell, Buy );	 
	 
	 Plot( C, "Price Candle", colorDefault, styleCandle );
	 Plot( WMAc, "WMA", ClrWMA, styleThick );
	 
	 PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorBrightGreen, 0, L, -15 );
	 PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorRed, 0, H, -15 );
	 
	 Title =
	 "{{DATE}}" +
	 "\nO " + NumToStr( O, 1.2 ) + "  H " + NumToStr( H, 1.2 ) + "  L " + NumToStr( L, 1.2 ) + "  C " + NumToStr( C, 1.2 );
_SECTION_END();

Not a problem at all, you can always use free Google translator (Persian to English). Like I know nothing of Persia or Persian but still can Copy/Paste to convey a message (thanks to Google).

دفعه بعد که یک کد را کپی کنید
لطفا منبعی را که از آن کپی کرده اید ذکر کنید
لطفا در هنگام ارسال درخواست خود از برچسب کد استفاده کنید

لطفا این را بخوانید


آخر هفته خوبی داشته باشی

P.S. The primary language of this forum is English. What I copy/pasted in Persian was just to show an example to help OP overcome language barrier while posting here.

3 Likes

Thank you.:pray::pray: