Simple Coding Help - No Promise.

sr114

Well-Known Member
Momentum Indicator is simply difference of two close prices. It cannot be above 100 for most of the forex currencies, most of the time. Therefore the MT4 formula does not use default Momentum Indicator formula. It had to be amended for forex and you now need to carry forward that amendment.

The appropriate formula from momentum in this case should be translated into Amibroker either as

Code:
momentum = HaClose * 100 / Ref(HaClose, -Param("Period", 10, 1, 100 ) );
OR (if you want to be very accurate)

Code:
momentum = Close * 100 / Ref(Close, -Param("Period", 10, 1, 100 ) );
MM
yes rather than usinh the momentum as diff of 2 pd prices
let it be the ratio - then the momentum >100 will be vails

so momentum = (c/ref(c,-n pd))*100 will be better represented rarger than (c-ref(c,-n pd))*100;

i have taken the 1stinstances of momentum

rgds
 
Sir... I have used 4 AFLs to design this system... Can they be combined and made as one AFL???

This system is Russ Horn's Secret Method which is been designed for MT4...

Sir... If I had OBV, Stoch and CCI Indicators... What are the parameters to be used???

I have put the AFLs used and the information about the system in the link below...

www(dot)mediafire(dot)com/download/in7bsha195qkepg/Strategy+Req(dot)rar

Please help me to get this system in Amibroker with required AFLs so it gives BUY/SELL signals when conditions are met and also would like to get a scan/exploration afl so it scans the stocks for the conditions mentioned......
Yes, you can do that ...

What you need to do is merge all the four files into one and remove Plots and additional or useless parameters. In the example code given below, I do not plot from the Momentum, OsMA and RSI.

Reasons to remove plotting these extra indicators is to keeps chart less confusing. You can use them in formula independent of whether they were plotted or not. If you also want to see them, you can simply add the indicator itself in a separate pane.

Code:
_SECTION_BEGIN("HA Looping ( no AMA() )");
///////////////////////////////////////////////////////////
// Heikin Ashi - Calculated Properly without using AMA
// JF Derzi, December 2012

HaClose[0] = (Open[0]+High[0]+Low[0]+Close[0]) / 4;
HaOpen[0]  = (HaClose[0] + Open[0]) / 2;
HaHigh[0]  = Max( High[0], Max( HaClose[0], HaOpen[0] ) );
HaLow[0]   = Min( Low[0], Min( HaClose[0], HaOpen[0] ) );

for (i = 1; i < BarCount; i++)
{
HaClose[i] = (Open[i]+High[i]+Low[i]+Close[i]) / 4;
Haopen[i]  = (HaClose[i-1] + HaOpen[i-1]) / 2;
// Here is the problem when using Arrays: Haopen always uses its own previous value
HaHigh[i]  = Max( High[i], Max( HaClose[i], HaOpen[i] ) );
Halow[i]   = Min( Low[i], Min( HaClose[i], HaOpen[i] ) );
}

PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", colorBlack, styleCandle);
Title = Name()+" "+Date()+" Heikin Ashi -- HaOpen:"+NumToStr(HaOpen,1.2,True)+" / HaHigh:"+NumToStr(HaHigh,1.2,True)+" / HaLow:"+NumToStr(Halow,1.2,True)+" HaClose:"+NumToStr(Haclose,1.2, True);
_SECTION_END();

_SECTION_BEGIN("MA");
Periods = Param("Periods", 15, 2, 300, 1, 10 );
simpleMA = MA( HaClose, Periods ); 
Plot( simpleMA, "MA2", ParamColor( "Color", colorCycle ), ParamStyle("Style") ); _SECTION_END();
_SECTION_END();

_SECTION_BEGIN("OSMA");
// osma implementation for Amibroker
// version 0.2 (c) 28th April 2011, [email protected] 

FastEma=Param("Fast EMA", 12, 1 , 25, 1);
SlowEma=Param("Slow EMA", 26, 1 , 50, 1);
SignalEma=Param("Signal EMA", 9, 1 , 25, 1);
// signals 
OsMA=MACD( FastEma, SlowEma )-Signal( FastEma, SlowEma, SignalEma );
// Plot removed
_SECTION_END();

_SECTION_BEGIN("Momentum");
momentum = HaClose * 100 / Ref(HaClose, -Param("Period", 10, 1, 100 ) );
// Plot removed
_SECTION_END();

_SECTION_BEGIN("RSIa");
periods = Param("Periods", 15, 1, 200, 1 );
rxRsi =  RSIa( HaClose, periods);
_SECTION_END();

longCond1 = Cross(HaClose, simpleMA);
longCond2 = OsMA > 0;
longCond3 = momentum > 100;
longCond4 = rxRsi > 50;
PlotShapes(longCond1 * shapeDigit1, colorBlue, 0, HaLow - 5);
PlotShapes(longCond2 * shapeDigit2, colorBlue, 0, HaLow - 10);
PlotShapes(longCond3 * shapeDigit3, colorBlue, 0, HaLow - 15);
PlotShapes(longCond4 * shapeDigit4, colorBlue, 0, HaLow - 20);

Buy = ((HaOpen < HaClose) AND Cross(HaClose, simpleMA) AND (OsMA > 0) AND (momentum > 100) AND (rxRsi > 50));
Short = ((HaOpen > HaClose) AND Cross(HaClose, simpleMA) AND (OsMA < 0) AND (momentum < 100) AND (rxRsi < 50));
....
 
Friends,

Please share the afl.
Vinpoor has already uploaded it here

www(dot)mediafire(dot)com/download/in7bsha195qkepg/Strategy+Req(dot)rar
 

Nehal_s143

Well-Known Member
Could you please share coding for this ?

below code is only for TSI, trend lin breakout done manually, seniors help is requested to code trend lined breakout signals

Code:
_SECTION_BEGIN("TSI");
r = Param( "TSI period Length:", 25, 1, 100, 1 );
s = Param( "TSI period Smoothing:", 13, 1, 100, 1 );
sig = Param( "TSI Signal Length:", 7, 1, 100, 1 );
 
Mtm = C - Ref ( C, -1 );
AbsMtm = abs(Mtm);

numT = EMA ( EMA ( Mtm, r ), s );
DenT = EMA ( EMA ( AbsMtm, r ), s );

TSI = 100 * Nz ( numT / DenT );
Plot( TSI, "TSI("+r+","+s+")", colorRed, styleLine);
Plot(EMA(TSI,sig), "", colorLightBlue, styleLine);
sige=EMA(TSI,sig);
Plot(0,"", colorGold, styleDashed);


myc2=IIf(Tsi>0 AND Tsi>sige,colorBlue,
      IIf(Tsi>0 AND Tsi<sige,colorSkyblue,
       IIf(Tsi<0 AND Tsi>sige,colorPink,
        IIf(Tsi<0 AND Tsi<sige,colorRed,31))));

Plot(2, "ribbon", myc2, styleOwnScale| styleArea|styleNoLabel,-0.5,100);

Buy =   Tsi>sige;
Sell =  Tsi<sige;
Short = Tsi<sige;
Cover = Tsi>sige;

Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
  
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);

Filter = Buy OR Sell OR Short OR Cover;
AddColumn(IIf(Buy, BuyPrice, 0),  "Buy", 6.2);
AddColumn(IIf(Sell, SellPrice, 0),  "Sell", 6.2);
AddColumn(IIf(Short, ShortPrice, 0),  "Short", 6.2);
AddColumn(IIf(Cover, CoverPrice, 0),  "Cover", 6.2);
AddColumn(Close,"Close",1.2);
 
_SECTION_END();
 

Similar threads