Simple Coding Help - No Promise.

pratapvb

Well-Known Member

sanjn84

Active Member
Last edited:

toughard

Well-Known Member
Nehal sir one small AFL request.

Logic is
There will be HIGH EMA & LOW EMA
Buy is when price closed above HIGH EMA and only if next candle closed above that.
reverse or Sell is when price closed below LOW EMA and only if next candle closed below that.

can you help me with the AFL for the same?

Toughard
 

Nehal_s143

Well-Known Member
Nehal sir one small AFL request.

Logic is
There will be HIGH EMA & LOW EMA
Buy is when price closed above HIGH EMA and only if next candle closed above that.
reverse or Sell is when price closed below LOW EMA and only if next candle closed below that.

can you help me with the AFL for the same?

Toughard
hi

I am not sir :p , kindly request for AFL code to seniors like Happy Sir, Pratap Sir & Mastermind007 Sir, I am just learner, sure will try my level best to give afl code for above condition
 
Last edited:

Nehal_s143

Well-Known Member
Nehal sir one small AFL request.

Logic is
There will be HIGH EMA & LOW EMA
Buy is when price closed above HIGH EMA and only if next candle closed above that.
reverse or Sell is when price closed below LOW EMA and only if next candle closed below that.

can you help me with the AFL for the same?

Toughard
you have not mentioned ema value, used 11 ema in afl, plus not given exit rule, hence exit long when price close below low ema and exit short when price close above high ema

hope this is as per your requirement

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("ema_crossover");
x = EMA(Close,11);
y = EMA(High,11);
z = EMA(Low,11);
PH = Ref(High,-1);
PL = Ref(Low,-1);

Plot(EMA(Close,11),"",colorRed,styleLine);
Plot(EMA(Low,11),"",colorPaleGreen,styleLine);
Plot(EMA(High,11),"",colorDarkGreen,styleLine);

Buy= C>O AND C>Y AND C>ph;
Sell=C<Z;
Short= C<O AND C<Z AND C<PL;
Cover=C>Y;

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

PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45);
PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);

PlotShapes(Sell*shapeHollowDownArrow,colorPink,0,L,-45);
PlotShapes(Cover*shapeHollowUpArrow,colorSkyblue,0,H,-45);

/////////////////////////////////// Exploration ///////////////////////
Filter = Buy OR Sell;

/////////// General Columns ////////////////////////
AddTextColumn( FullName( ), "Name" );
AddColumn(C,"Close");
AddTextColumn( MarketID( 1 ), "Market name" );

//////////////// BUY/SELL SIGNALS ///////

AddColumn( IIf(Buy,1,IIf(Sell,-1,Null)) ,"Signal1",1.0,colorWhite,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorWhite)));


//////////////////////////////////// Exploration over ////////////////////////////
 

toughard

Well-Known Member
Sir thank you very much.
Thanks a lot for your support & guidance.

Toughard
 

toughard

Well-Known Member
Sir thank you very much.
Thanks a lot for your support & guidance.

Toughard

Sir in this AFL buy signal is coming on the same candle which is closed above EMA (assume candle A).

So how to get the same signal if the price close above candle A.

PH in the AFL is referring to the candle is before A which may not be above EMA.

Please help

Toughard
 
Dear All AFL Seneors,

I require Exploration(Scanner) for the following conditions.
for Buy Condition.
1. Candel crossed and closed above cross of EMA 5 above EMA 20 and EMA 20 above EMA 30.

2. Candel Crossed ATR 10 Factor 4.

3. RSI 14 is above 50

4. ADX 14 above 30

Reverse for Sale Condition.

I need only scanner for stock fulfilling this conditions.

Thanks and regards.

Maruti Mane
 

Nehal_s143

Well-Known Member
Sir in this AFL buy signal is coming on the same candle which is closed above EMA (assume candle A).

So how to get the same signal if the price close above candle A.

PH in the AFL is referring to the candle is before A which may not be above EMA.

Please help

Toughard
need to take help of seniors, not able to write code for above high of signal candle
 

Similar threads