Help Required For buy reentry Sell Re-entry

#1
Hello Friends,

I required help buy re-entry and sell re-Entry for below mention afl code.


_SECTION_BEGIN("Price");
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() );

ChannelPeriods = Param("Channel Periods",10,1,50,1);
AvgPeriods = Param("Average Periods",21,1,50,1);


n1 = ChannelPeriods; // Channel periodsdefault is 10.
n2 = AvgPeriods; // Average periodsdefault is 21.

AP = Avg; //Typical Price
ESA = EMA(AP, n1);
D = EMA(abs(AP - ESA), n1);
CI = (AP - ESA) / (0.015 * D);
TCI = EMA(CI, n2);

WaveTrend1 = TCI;
WaveTrend2 = MA(WaveTrend1,4);

myColor =
IIf (WaveTrend1 > WaveTrend2, colorLavender,
IIf (WaveTrend2 > WaveTrend1, colorRed ,colorLightYellow));

//Plot(WaveTrend1,"WaveTrend ",myColor,styleDots | styleThick);

//Plot(WaveTrend2,"WaveTrend2",colorLightYellow,styl eDashed);
//Plot(WaveTrend2,"WaveTrend2",ParamColor("Signal Line color", colorPaleBlue),styleDots);

//Plot(OverBought,"OB Line",ColOB,8+16);//|styleNoLabel);//8+16
//Plot(OverSold,"OS Line",ColOS,8+16);//|styleNoLabel);
//Plot(n1,"Channel Periods",colorBlue,styleNoLabel |styleNoRescale |styleNoDraw);
//Plot(n2,"Avg Periods",colorBlue,styleNoLabel |styleNoRescale | styleNoDraw);
//Plot(0,"0",colorRed,styleNoLabel);
//Plot(100,"",9 ,styleOwnScale | styleArea | styleNoLabel,-5,100);
//Background pane coloring

bSetup=Cross(WaveTrend1,WaveTrend2);
sSetup=Cross(waveTrend2,WaveTrend1);
BuySetupValue = ValueWhen(bSetup,H,1);
SellsetupValue = ValueWhen(sSetup,L,1);
Longa = Flip(Bsetup,Ssetup);
shrta = Flip(Ssetup,Bsetup);
Buy1 = Longa AND Cross(C,BuySetupValue);
Sell1 = shrta AND Cross(SellsetupValue,C);
Buy1 = ExRem(Buy1,Sell1);
Sell1 = ExRem(Sell1,Buy1);
shape=Buy1*shapeUpArrow+Sell1*shapeDownArrow;
PlotShapes( shape, IIf( Buy1, colorWhite, colorYellow ), 0, IIf( Buy1, L-1, IIf(Sell1,H+1,Null)));


Buy2=Close>EMA(Close,50);
Sell2=Close<EMA(Close,50);

Buy2 = ExRem(Buy2,Sell2);
Sell2 = ExRem(Sell2,Buy2);

shape=Buy2*shapeUpArrow+Sell2*shapeDownArrow;
PlotShapes( shape, IIf( Buy2, colorGreen, colorRed ), 0, IIf( Buy2, L-1, IIf(Sell2,H+1,Null)));


Buy=Buy1 AND Buy2;
Sell=Sell1 AND Sell2;

shape=Buy2*shapeUpArrow+Sell2*shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, L-1, IIf(Sell,H+1,Null)));


_SECTION_END();

_SECTION_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();



i have attached chart image here for easy reference. in that chart when price close below or above 50 EMA and Wavetrend Crossover come in a same candle then buy and sell signal triggers.

white and yellow is for re-entry for buy or sell.

BUT What i Rquired is

buy IF : Close Above 50 EMA And LATER it has Positive WaveTrend Crossover
buy IF : Positive WaveTrend Crossover and Later Price Close Above 50 Ema its A buy

buy exit : if Price is Above 50 Ema and Negative Wavetrend Crossover comes its a long exit only.

Buy Re-Entry : if Price is above 50 Ema and positive corssover comes its a buy or buy Re-Entry.



For Sell all condition is reversed. if i get buy codes i will write sell coding with help of that..

if you can help me with this formula and condition it will be very much helpful for me. I spent lot of time but didn't get desired outcome. searched a lot and tried many codes and condition but error never goes.

plz help me with this..

Thanx Friends,

Chetan
 

Attachments

casoni

Well-Known Member
#3
Hello chetan .

This should work as you mentioned ...this code will buy / sell only when price is above ema50
// option 1
B1=Close>EMA(Close,50);
S1=Close<EMA(Close,50);
b2=Cross(WaveTrend1,WaveTrend2);
s2=Cross(waveTrend2,WaveTrend1);

Buy1=BarsSince(B1)<BarsSince(S1) AND B2;
SELL1=BarsSince(B1)<BarsSince(S1) AND S2;

Buy=ExRem(Buy1,Sell1);
Sell=ExRem(SELL1,BUY1);
shape=Buy*shapeDigit1+Sell*shapeDigit1;
PlotShapes(Buy*shapeDigit1, 5,0, L-20,0);//, IIf(Sell,H+25,Null)));
PlotShapes(Sell*shapeDigit1, 4,0, H+20,0);//, IIf(Sell,H+25,Null)));

// option 2

B1=Close>EMA(Close,50);
S1=Close<EMA(Close,50);
b2=WaveTrend1>WaveTrend2;//Cross(WaveTrend1,WaveTrend2);
s2=WaveTrend1<WaveTrend2;//Cross(waveTrend2,WaveTrend1);

Buy1=BarsSince(B1)<BarsSince(S1) AND B2;
SELL1=BarsSince(B1)<BarsSince(S1) AND S2;

Buy=ExRem(Buy1,Sell1);
Sell=ExRem(SELL1,BUY1);
shape=Buy*shapeDigit1+Sell*shapeDigit1;
PlotShapes(Buy*shapeDigit2, 5,0, L-20,0);//, IIf(Sell,H+25,Null)));
PlotShapes(Sell*shapeDigit2, 4,0, H+20,0);//, IIf(Sell,H+25,Null)));

do the rest ....
 
Last edited:
#5
To Ca Soni Sir,

Sir i am looking for a well knowledged and expirenced amibroker coder.
Actually i am trading in nse future with large portfolios. i am using other technical software like falcon and spider. When i started technical it was amibroker but due to lack of programming and coding knowledge i quit using that. Because it was hard for me to put ideas in chart.

but now i found if you know the coading and afl language its as simple as other charting software and way much faster then other platforms.

I required a AFL programmer who can made change in Afl's that i provide to him according to our technique for a fair consideration in return.

here is my mail address if you can help me in finding a good programmer.

[email protected]

Thanx

Chetan.
 

Similar threads