AFL writing guide for new user

1. I have written an afl code based on WOODIES Pivots.
2. The Pivot Point (PP) is calculated on daily data.
3. The levels are plotted on 5 min RT chart in Amibroker.
4. Now I want this code to use in Real Time scan to identify those scrips whose current value cross the PP.
5. Thus suitable Buy-Sell code is to be added but this Buy sell must be based on 5 min data crossing PP.
6. The code is given below.
7. kind help me.

_SECTION_BEGIN("Price");

TimeFrameSet(inDaily);

PP=(Ref(H,-1)+Ref(L,-1)+(2*O))/4;

R1 = (2 * PP) - Ref(L,-1);
R3 = Ref(H,-1) + 2 * (PP - Ref(L,-1));
R2 = PP + (Ref(H,-1)-Ref(L,-1));

S1 = (2 * PP) - Ref(H,-1);
S2 = PP - (Ref(H,-1)-Ref(L,-1));
S3 = Ref(L,-1) - 2 * (Ref(H,-1) - PP);

Plot(EndValue(R1),"\n\nR1",colorRed,styleLine|styl eThick,Null,0,0,5);
Plot(EndValue(R2),"\nR2",colorRed,styleLine|styleT hick,Null,0,0,5);
Plot(EndValue(R3),"\nR3",colorRed,styleLine|styleT hick,Null,0,0,5);

Plot(EndValue(PP),"\n\nPIV",colorBlue,styleLine|st yleThick,Null,0,0,5);

Plot(EndValue(S1),"\n\nS1",colorGreen,styleLine|st yleThick,Null,0,0,5);
Plot(EndValue(S2),"\nS2",colorGreen,styleLine|styl eThick,Null,0,0,5);
Plot(EndValue(S3),"\nS3",colorGreen,styleLine|styl eThick,Null,0,0,5);

TimeFrameRestore();
_SECTION_END();
Edit/Delete Message
 
1. I have written an afl code based on WOODIES Pivots.
2. The Pivot Point (PP) is calculated on daily data.
3. The levels are plotted on 5 min RT chart in Amibroker.
4. Now I want this code to use in Real Time scan to identify those scrips whose current value cross the PP.
5. Thus suitable Buy-Sell code is to be added but this Buy sell must be based on 5 min data crossing PP.
6. The code is given below.
7. kind help me.

_SECTION_BEGIN("Price");

TimeFrameSet(inDaily);

PP=(Ref(H,-1)+Ref(L,-1)+(2*O))/4;

R1 = (2 * PP) - Ref(L,-1);
R3 = Ref(H,-1) + 2 * (PP - Ref(L,-1));
R2 = PP + (Ref(H,-1)-Ref(L,-1));

S1 = (2 * PP) - Ref(H,-1);
S2 = PP - (Ref(H,-1)-Ref(L,-1));
S3 = Ref(L,-1) - 2 * (Ref(H,-1) - PP);

Plot(EndValue(R1),"\n\nR1",colorRed,styleLine|styl eThick,Null,0,0,5);
Plot(EndValue(R2),"\nR2",colorRed,styleLine|styleT hick,Null,0,0,5);
Plot(EndValue(R3),"\nR3",colorRed,styleLine|styleT hick,Null,0,0,5);

Plot(EndValue(PP),"\n\nPIV",colorBlue,styleLine|st yleThick,Null,0,0,5);

Plot(EndValue(S1),"\n\nS1",colorGreen,styleLine|st yleThick,Null,0,0,5);
Plot(EndValue(S2),"\nS2",colorGreen,styleLine|styl eThick,Null,0,0,5);
Plot(EndValue(S3),"\nS3",colorGreen,styleLine|styl eThick,Null,0,0,5);

TimeFrameRestore();
_SECTION_END();
 
hi can any one code this for me , would be a great help !

there 4 points of trade named as P1,P2,P3 AND N1 On any stock that being calculated by me I wanted to code

Buy = on crossover of price...
 
Thank you my friend,
I really appreciate if active members like you help others. It is really very cool to know AFl because then you can test your own trading methods by yourself. right? I searched many, but there is really no good site I found. If any memeber knows any good thread in traderji or any other site. Please share it here. I think it will help new AFL users.

Debarghya Mukherjee
sir

Symbol Series Date Prev Close Open Price High Price (g)Low Price Last Price Close Price Average Price

excel formula buy sell

=AVERAGE(G2:G9)
=M9+0.21*(G10-M9)

=IF(I10>M10,"BUY","SELL")

explin
g=lowprice
m=average price(8day)

convert alf buysell signal amiborker
please help
 
Hi All,
I am new to Amibroker AFL. I downloaded the below code to plot Pivots on the chart. How do i make it plot the Pivots Lines only for the current day? Any help will be greatly appreciated. :confused:


GraphXSpace = 5 ;
SetChartOptions(0,chartShowArrows|chartShowDates);

Plot(C,"Close",colorBlack, styleCandle);
ppl = ParamToggle("Plot Pivot Levels","Off|On",1);

numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = -33.5;

/* This code calculates the previous days high, low and close */
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
C1 = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);

//----------------------------------------------------------------------------------

/* This code calculates Daily Piovts */

rg = (Hi - Lo);
bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
r2 = bp + r1 - s1; r2I = LastValue (r2,1);
s2 = bp - r1 + s1; s2I = LastValue (s2,1);
r3 = bp + r2 - s1; r3I = LastValue (r3,1);
s3 = bp - r2 + s1; s3I = LastValue (s3,1);
r4 = bp + r2 - s2; r4I = LastValue (r4,1);
s4 = bp - r2 + s2; s4I = LastValue (s4,1);

if(ppl==1) {
Plot(bp,"",colorBlue,styleLine|styleDots|styleNoRescale);
Plot(s1,"",colorRed,styleLine|styleNoRescale);
Plot(s2,"",colorRed,styleLine|styleNoRescale);
Plot(s3,"",colorRed,styleLine|styleNoRescale);
Plot(s4,"",colorRed,styleLine|styleNoRescale);
Plot(r1,"",colorGreen,styleLine|styleNoRescale);
Plot(r2,"",colorGreen,styleLine|styleNoRescale);
Plot(r3,"",colorGreen,styleLine|styleNoRescale);
Plot(r4,"",colorGreen,styleLine|styleNoRescale);
PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +0.05, colorBlue);
PlotText(" R1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorGreen);
PlotText(" S1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorRed);
PlotText(" R2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorGreen);
PlotText(" S2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorRed);
PlotText(" R3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorGreen);
PlotText(" S3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorRed);
PlotText(" R4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorGreen);
PlotText(" S4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorRed);
}

//--end----------------------------------------------------------------------------
 
Last edited:
trend direction indicator using EMA 200 trend

(**************** LATEST *********************)



INDICATOR USED :

TREND DIRECTION INDICATOR ( 6-4 SETTINGS IN INDICATOR )



checkpoint for buy entry:

EMA200 in 5M/ 15M/ 30 M / 1 HR / 4 HR / DAILY
to be calculated all the day

When 4 out of 6 are in buy trend, we confirm
to trade only whenever a valid buy comes



valid buy :

buy arrow confirmed candle's high to break
for entering a buy position


place a target pip


if target hit, wait for fresh buy/sell signal
in trend direction indicator.. no immediate re entry

use lot multiplier for making average target


stoploss, when EMA200 in 5M/ 15M/ 30 M / 1 HR / 4 HR / DAILY
trends 4 out of 6 turned to negative

===============================================================



checkpoint for sell entry:

EMA200 in 5M/ 15M/ 30 M / 1 HR / 4 HR / DAILY
to be calculated all the day

When 4 out of 6 are in sell trend, we confirm
to trade only whenever a valid sell comes


valid sell

sell arrow confirmed candle's low to break for
entering a sell position


place a target pip


if target hit, wait for fresh buy/sell signal
in trend direction indicator.. no immediate re entry

use lot multiplier for making average target

stoploss, when EMA200 in 5M/ 15M/ 30 M / 1 HR / 4 HR / DAILY
trends 4 out of 6 turned to positive


=================================================================
 

hmp

Well-Known Member
Rely nice attempt Gogou!
Request some expert to help him to add buy, sell ,stoploss & target to make it more helpful.
Regards
 
Last edited:

Similar threads