Hi to all,
Here is my effort to make an AFL on Acme N System. In the AFL itself I have included the parameters to be met for buy conditions to be satisfied.
I would be grateful if somebody correct my AFL as I failed miserably to write the code for some conditions.
Here is my effort to make an AFL on Acme N System. In the AFL itself I have included the parameters to be met for buy conditions to be satisfied.
I would be grateful if somebody correct my AFL as I failed miserably to write the code for some conditions.
///1. Is the current bar an NR5 bar AND the previous bar an NR5 bar?
Range=High-Low;
CON1=Ref (LLV (Range, 5), -1) > Range AND Ref (LLV (Range, 6), -2) > Range;
//2. Is the current bar an ID bar AND the previous bar an ID bar?
CON2 = (High < Ref( High, -1 ) AND Low > Ref( Low, -1 )) AND (Ref( Low, -1 ) > Ref( Low, -2 ) AND Ref( High, -2 ) > Ref( High, -1 ));
//3. Is the current bar an NR10 bar?
CON3 =Ref (LLV (Range, 10), -1) > Range;
//4. Is the current bar an ID bar AND an NR4 bar?
CON4 = (High < Ref( High, -1 ) AND Low > Ref( Low, -1 )) AND Ref (LLV (Range, 4), -1) > Range;
//5. Calculate the Range Ratio (RR) tor the current bar divided by the
//range of the last 7 bars (RR 1:7). Is the RR 1:7 less than 0.7?
CON5 = Range/ATR(7);
RR = CON5 < 0.7;
//7.3.1 Long Signal
//Calculations
//1. Calculate the ATR for the past 20 bars (ATR20).
//2. Multiply the Range Percentage (RP) of the current bar by ATR20.
A=ATR(20);
RP=(RANGE*100/A);
//3. Calculate the ADX for the Filter length (ADX14).
//4. Calculate the 50-bar moving average (MA50).
//5. Calculate the historic volatility for the Filter length (HV14).
//CON6= Ref (HHV( High, -14 ));
//CON7=Ref( LLV (Low, -14));
//HV14 = CON6-CON7;
//Entry Rules
//1. Narrow Range Condition = True
CON8 = CON1 OR CON2 OR CON3 OR CON4 OR RR;
//2. Range <=RP*ATR20
CON9 = RANGE < RP*ATR(20);
//3. Close > 20
//4. ADX14 >=18
CON10 = ADX(14)>18;
//5. HV14>=0.5
//CON11= HV14 > 0.5;
//6. Retracement Bars >= 2
CON12 = Ref( LLV( Low, 2 ), -1 ) > Low AND Ref( LLV( High, 2 ), -1 ) > High;
//7. Median Price > MA50
//CON13=((High-Range*0.5)> MA(50));
//8. Buy the next bar at OR above the High + (EntryFactor * ATR20)
Buy = CON8 AND CON9 AND CON10 AND CON12 ;//AND CON12 AND CON13;
Filter = Buy;
Sell=Short=Ref( LLV( RR, 7 ), -1 ) > RR AND RR<0.7;
Cover=0;
AddColumn (C, "");
AddColumn (RR,"RR");
Range=High-Low;
CON1=Ref (LLV (Range, 5), -1) > Range AND Ref (LLV (Range, 6), -2) > Range;
//2. Is the current bar an ID bar AND the previous bar an ID bar?
CON2 = (High < Ref( High, -1 ) AND Low > Ref( Low, -1 )) AND (Ref( Low, -1 ) > Ref( Low, -2 ) AND Ref( High, -2 ) > Ref( High, -1 ));
//3. Is the current bar an NR10 bar?
CON3 =Ref (LLV (Range, 10), -1) > Range;
//4. Is the current bar an ID bar AND an NR4 bar?
CON4 = (High < Ref( High, -1 ) AND Low > Ref( Low, -1 )) AND Ref (LLV (Range, 4), -1) > Range;
//5. Calculate the Range Ratio (RR) tor the current bar divided by the
//range of the last 7 bars (RR 1:7). Is the RR 1:7 less than 0.7?
CON5 = Range/ATR(7);
RR = CON5 < 0.7;
//7.3.1 Long Signal
//Calculations
//1. Calculate the ATR for the past 20 bars (ATR20).
//2. Multiply the Range Percentage (RP) of the current bar by ATR20.
A=ATR(20);
RP=(RANGE*100/A);
//3. Calculate the ADX for the Filter length (ADX14).
//4. Calculate the 50-bar moving average (MA50).
//5. Calculate the historic volatility for the Filter length (HV14).
//CON6= Ref (HHV( High, -14 ));
//CON7=Ref( LLV (Low, -14));
//HV14 = CON6-CON7;
//Entry Rules
//1. Narrow Range Condition = True
CON8 = CON1 OR CON2 OR CON3 OR CON4 OR RR;
//2. Range <=RP*ATR20
CON9 = RANGE < RP*ATR(20);
//3. Close > 20
//4. ADX14 >=18
CON10 = ADX(14)>18;
//5. HV14>=0.5
//CON11= HV14 > 0.5;
//6. Retracement Bars >= 2
CON12 = Ref( LLV( Low, 2 ), -1 ) > Low AND Ref( LLV( High, 2 ), -1 ) > High;
//7. Median Price > MA50
//CON13=((High-Range*0.5)> MA(50));
//8. Buy the next bar at OR above the High + (EntryFactor * ATR20)
Buy = CON8 AND CON9 AND CON10 AND CON12 ;//AND CON12 AND CON13;
Filter = Buy;
Sell=Short=Ref( LLV( RR, 7 ), -1 ) > RR AND RR<0.7;
Cover=0;
AddColumn (C, "");
AddColumn (RR,"RR");