Simple Coding Help - No Promise.

vijkris

Learner and Follower
hi dear my friends amitrandive
will you plz add scan to this afl for below condition
buy if slopes is 0<slope<20
sell if slopes is above 80<slope<100
i am not sure is it correct or not .imean scan for buy an sell to this condition according the slope positions








_SECTION_BEGIN("_trending wave");
SetChartOptions(0, chartShowArrows|chartShowDates, chartGrid20 |chartGrid50 |chartGrid80);
_N(Title =EncodeColor(colorGreen)+ StrFormat("{{NAME}} {{DATE}} " + EncodeColor(colorBlack)+" < Open %g > "+ EncodeColor(colorBlue)+ " < High %g > "+ EncodeColor(colorRed)+" < Low %g > "+ EncodeColor(colorBlack) + " < Close %g > " + EncodeColor(colorBrown ) + "< Change" +" %.2f%% > " + "< Range " +(H-L) +" >" +" < Volume " +WriteVal( V, 1.0 ) +" >"+" {{VALUES}} ", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
SetChartBkColor(ParamColor("Outer Panel Color ",colorWhite)); // color of outer border
SetChartBkGradientFill( ParamColor("Inner Panel Color Upper Half",colorWhite),
ParamColor("Inner Panel Color Lower Half",colorWhite)//color of inner panel
,ParamColor("Behind Text Color", colorLavender));
GraphXSpace=7;

Hc=(O+H+L+C)/4;

Ho = AMA( Ref( Hc, -1 ), 0.5 );

pds = Optimize("pds ",Param("pds ",4,1,25,1),1,25,1);
myArray = (RSIa((HC), pds )+ RSIa( Ho,pds ) + Ref(RSIa(Ho,pds),-1) + Ref(RSIa(Ho,pds),-2) + Ref(RSIa(Ho,pds),-3))/5 ;

myArrayS = (AMA( myArray , 0.5 )); //smooth

BS = ParamToggle("smooth","No|Yes",1);
BN = ParamToggle("normal","No|Yes",1);

if (BS) Plot( myArrayS , " smooth ", IIf( myArrayS >=Ref(myArrayS ,-1), colorGreen, colorRed ));
if (BS) Plot ( 1, "", IIf( myArrayS >=Ref(myArrayS ,-1), colorGreen, IIf( myArrayS < Ref(myArrayS ,-1), colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

if (BN) Plot( myArray , " RSI ", IIf( myArray >=Ref(myArray ,-1), colorGreen, colorRed ));
if (BN) Plot ( 2, "", IIf( myArray >=Ref(myArray ,-1), colorGreen, IIf( myArray < Ref(myArray ,-1), colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

HistInd=myArray - myArrayS ;

if (BS AND BN) Plot(HistInd, _DEFAULT_NAME(),
IIf(HistInd>=0, ParamColor("Up Color", colorDarkGreen), ParamColor("Down Color", colorRed)),
ParamStyle( "Style", styleHistogram | styleThick, maskHistogram ));
if (BS AND BN) Plot(0,"",colorBlack, styleLine|styleDashed | styleThick);

Plot(80,"RESISTENCE",colorRed, styleLine|styleDashed | styleThick);
Plot(50,"",colorBlack, styleLine|styleDashed | styleThick);
Plot(20,"SUPPORT",colorBlue, styleLine|styleDashed | styleThick);
_SECTION_END();

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;
Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorWhite, 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
 

john302928

Well-Known Member
Hi Is there any possibility to create afl for Elliot wave labeling texts in amibroker ?
Because everytime we have to create text box and then add the label. Is there any afl or any afl can be created where i can pick the places it could just place the label 12345abc
I have seen these kinds in meta trader.Anything can be done for amibroker?
 

john302928

Well-Known Member
Dear Tarang58,
Try this

MA200=MA(Close,200);
Buy=Close>MA200;
Sell=Close<MA200;
Filter= Buy or sell;
AddColumn(Volume,"volume");
AddColumn(Close,"Close");
AddColumn(MA200,"MA200");

Hi all.
I want to buy / sell stock closing above /below 200 days simple moving average on daily time frame.
Can i have afl for this strategy?
Regards
 
Hi John
Thanks for trying .It is not that i required. I would like to have proper buy sell arrows along with price chart.
Your afl is not giving proper buy sell signals at exact point & used only for exploration. Also giving arrows on all candles. Pl. chk that
Thanks
 

muinali

Well-Known Member
_SECTION_BEGIN("");
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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("MA50-MA200 Crossover");
Buy = Cross( MA( Close, 50 ), MA( Close, 200 ) );
Sell = Cross( MA( Close, 200 ), MA( Close, 50 ) );
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-15);
PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-15);
_SECTION_END();

Plot( MA( Close,50 ),"MA50",colorRed,styleLine);
Plot( MA( Close,200),"MA200",colorBlue,styleLine);
 
Thanks Muinali
Your afl is having 50 ema also. What i want is only 200 MA.
While googling i found one afl but it is giving some syntex errors.Will some one correct them? Afl is as per below
Code:
_SECTION_BEGIN("200EMA);
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() );
Buy - Cross (Close, EMA( Close, 200 )) ;
Sell- Cross (EMA( Close, 200 ), Close) ;
Short = Sell;
Cover = Buy;

//Buy = Ref(Buy,-1);
//Short = Ref(Short,-1);

PlotShapes(IIf(Buy, shapeHollowUpArrow, shapeNone),colorGreen, O,L,Offset=-30);
PlotShapes(IIf(Short, shapeHollowDownArrow, shapeNone),colorRed, O,H,Offset=-30);
Plot( EMA( Close, 200 ),"mcd ema', colorRed,styleThick);

_SECTION_END();
_SECTION_END();
 
Here is corrected code

Code:
_SECTION_BEGIN("200EMA");
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() );
Buy = Cross (Close, EMA( Close, 200 )) ;
Sell= Cross (EMA( Close, 200 ), Close) ;
Short = Sell;
Cover = Buy;

//Buy = Ref(Buy,-1);
//Short = Ref(Short,-1);

PlotShapes(IIf(Buy, shapeHollowUpArrow, shapeNone),colorGreen, O,L,Offset=-30);
PlotShapes(IIf(Short, shapeHollowDownArrow, shapeNone),colorRed, O,H,Offset=-30);
Plot( EMA( Close, 200 ),"mcd EMA", colorRed,styleThick);

_SECTION_END();
Thanks Muinali
Your afl is having 50 ema also. What i want is only 200 MA.
While googling i found one afl but it is giving some syntex errors.Will some one correct them? Afl is as per below
Code:
_SECTION_BEGIN("200EMA);
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() );
Buy - Cross (Close, EMA( Close, 200 )) ;
Sell- Cross (EMA( Close, 200 ), Close) ;
Short = Sell;
Cover = Buy;

//Buy = Ref(Buy,-1);
//Short = Ref(Short,-1);

PlotShapes(IIf(Buy, shapeHollowUpArrow, shapeNone),colorGreen, O,L,Offset=-30);
PlotShapes(IIf(Short, shapeHollowDownArrow, shapeNone),colorRed, O,H,Offset=-30);
Plot( EMA( Close, 200 ),"mcd ema', colorRed,styleThick);

_SECTION_END();
_SECTION_END();
 
meaning of lines..

Hi

I have a paid subscription of Nest Plus API. The below code is not placing order in Nest or NOW platform. It does the charting and there are no error messages in Nest, NOW or Amibroker, if signal gets generated by Amibroker.. Can someone please guide me as to what is wrong with that..

Code:
p1 = Param("TL 1 Periods", 20, 5, 50, 1);
p2 = Param("TL 2 Periods", 5, 3, 25, 1);
TL1 = LinearReg(C, p1);
TL2 = EMA(TL1, p2);
Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorGold), ParamColor("TL Dn Colour", colorBlue));
Plot(TL1, "TL 1", Col1, styleLine|styleThick);
Plot(TL2, "TL 2", Col1, styleLine|styleThick);

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ))));
Plot(C, "Close", colorWhite, styleCandle);

ClientID = ParamStr("ClientId","ABC123");
Symbol = ParamStr("Symbol","SBIN");
Price = NumToStr(C,8.2,True);
Quantity = Param("Quantity",10,10,90,1);
OE = ParamList("Order Execution","Immediate,On Candle Completion",1);
AT = ParamToggle("AutoTrade","No,Yes");

Buy = Cover = TL1 > TL2;
Sell = Short = TL2 > TL1;

if(OE=="On Candle Completion")
	{
	Buy=Ref(Buy,-1);
	Short=Ref(Short,-1);
	Sell=Ref(Sell,-1);
	Cover=Ref(Cover,-1);
	}

AplliedQuantity=IIf(LastValue(Buy) AND LastValue(Cover) OR LastValue(Short) AND LastValue(Sell),Quantity*2,Quantity);
RefNumber = Nz(StaticVarGet("RefNumber"));
Checkdt=Nz(StaticVarGet("lastdt"));
dt = LastValue( DateTime() );
Cond=LastValue(Buy) OR LastValue(Short) OR LastValue(Sell) OR LastValue(Cover);

if(AT)
{
	plus = CreateStaticObject("Nest.PlusApi");
	if(plus)
	{
		plus.SetObjectName(ClientID);
		if(Cond AND Checkdt != dt )
		{
			if(LastValue(Buy) OR LastValue(Cover)){plus.PlaceOrder("BUY",RefNumber,"NFO",Symbol,"DAY","LIMIT",AplliedQuantity,Price,0,1,"NRML",ClientID);}
			if(LastValue(Short) OR LastValue(Sell)){plus.PlaceOrder("SELL",RefNumber,"NFO",Symbol,"DAY","LIMIT",AplliedQuantity,Price,0,1,"NRML",ClientID);}
			StaticVarSet("RefNumber",RefNumber+1);
			StaticVarSet("lastdt",dt );
		}
	}
}
 
Last edited:

Similar threads