Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
Find Out More Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

MHJ multi_model/improved MACD for Amibroker (AFL)

Rating:
3 / 5 (Votes 2)
Tags:
oscillator, amibroker

Salaam;

this is a multi_model/improved MACD.
the idea is to use regression (somewhere) instead of moving average.
some models are using division instead of minus sign that improves the working of MACD and also shows it by percentage!!!

there is no plotting or signal alarm instructions. and you may write it by yourself… (or tell me to do it for you.)

hope enjoy.

Indicator / Formula

Copy & Paste Friendly
//In the name of Allah the compassionate the merciful بسم الله الرحمن الرحيم
//by MHJ محمد حسين
//MACD - Moving Average Convergence Divergence

//==========================================================================
//=================================مکدي=====================================
//==========================================================================
_SECTION_BEGIN( "Macd" );
Var_Fast_Period = Param( "fast period", 12, 1, 200, 1 );
Var_Slow_Period = Param( "slow period", 26, 1, 200, 1 );
Param_macd_kind = ParamList( "گونه", "AVG-AVG|REG-AVG|REG-REG|REG-AVG REG|REG/REG|AVG/AVG|REG/AVG REG|macd", 0 );

if( Param_macd_kind == "AVG-AVG" )
    show_var = ma( C, Var_Fast_Period ) - MA( C, Var_Slow_Period );

if( Param_macd_kind == "REG-AVG" )
    show_var = LinearReg( C, Var_Fast_Period ) - MA( C, Var_Fast_Period );

if( Param_macd_kind == "REG-REG" )
    show_var = LinearReg( C, Var_Fast_Period ) - LinearReg( C, Var_Slow_Period );

if( Param_macd_kind == "REG-AVG REG" )
    show_var = LinearReg( C, Var_Fast_Period ) - MA( LinearReg( C, Var_Fast_Period ), Var_Fast_Period );

if( Param_macd_kind == "REG/AVG REG" )
    show_var = 100 * ( LinearReg( C, ( Var_Fast_Period ) / MA( LinearReg( C, Var_Fast_Period ), Var_Fast_Period ) - 1 ) );

if( Param_macd_kind == "AVG/AVG" )
    show_var = 100 * ( ( ma( C, Var_Fast_Period ) / MA( C, Var_Slow_Period ) ) - 1 );

if( Param_macd_kind == "REG/REG" )
    show_var = 100 * ( ( LinearReg( C, Var_Fast_Period ) / LinearReg( C, Var_Slow_Period ) ) - 1 );

if( Param_macd_kind == "MACD" )
    show_var = ema( C, Var_Fast_Period ) - eMA( C, Var_Slow_Period ); //show_var=MACD(Var_Fast_Period,Var_Slow_Period);

_SECTION_END();

Title = StrFormat(
            EncodeColor( colorred ) + "MACD(%g,%g)=  " + NumToStr( show_var, 1.0 )
            + EncodeColor( colordarkred ) + "   Model  " + Param_macd_kind + "   "
            , Var_Fast_Period, Var_Slow_Period
        );




/*



here you may paste your buy/sell strategies 
or plotting instructions...



*/

12 comments

1. vjvijay88

thanks for kind help sir, can add any buy/sell strategies best suite for intraday

2. shon

Sir, this is not working for me, I used amibroker version 6, what can i do now?

3. val2004

Same for me.

Nothing plotted

4. mhjwisestocktrader

salam;
I can’t edit my post,
add this to the end of codes for seeing results:

//
//
Color_Usual_Highdown = IIf( show_var > show_middle, Color_High, Color_Low );
            Plot( show_var, _DEFAULT_NAME(), Color_Usual_Highdown , styleline | styleNoTitle , Null, Null, 0, 0);
            PlotOHLC( show_var, show_var, 0, 0, "", IIf( show_var > 0, Colorred, Colorgreen ), styleCloud | styleClipMinMax | styleNoTitle | styleNoLabel , show_middle, show_middle );

//
//
5. mhjwisestocktrader

for buy/sell signals add these to the end of your codes:

//
//
Buy_condition_5 = show_var > Ref( show_var, -1 ) AND Ref( show_var, -1 ) < Ref( show_var, -2 );
Buy_condition_6 = show_var < ( MA( IIf(show_var>0,0,show_var) , 100 ) * 1.5 );


Sell_Condition_5 = show_var > Ref( show_var, -1 ) AND Ref( show_var, -1 ) < Ref( show_var, -2 );
Sell_Condition_6 = show_var > ( MA( IIf(show_var<0,show_var,0) , 100 ) * 1.5 );


Buy = Buy_condition_5 AND Buy_condition_6;
Sell = Sell_Condition_5 AND Sell_Condition_6;
//
//
6. shon

I hope you will post new version of this afl,until some problem with this afl.

7. mhjwisestocktrader

whats the problem? I’m working with/on this indicator.

8. val2004

Can you post a complete code with plot and signal that works

tks a lot

9. Mohamed AMARRAGY

It is not working with me

10. hotaro3

variables color_high, Color_Low and show_middle used with previous definition therfor no plot at all, please check your code mohammad hossien jan

11. morgen

I don’t see nothing!
Sorry……

12. mhjwisestocktrader

Salam;
I’m so sorry for these problems. I will write a better one and will share it’s link here (soon)
======
(the problem was from here that I have several included files of my older AFLs for showing my indicators… and I have not bring them all here… so I need time to somehow partially add them to this AFL… and also the parameters selection descriptions are in Persian language that I should change them to english, so it takes time)
======
the output of this AFL (I mean… next AFL) is not great when using alone. (without combining with other AFLs) so this afl is not good for amateur users.
the power of this AFL is when it combines with other trading system that is up to you!
==
هتاروی عزیز، میتونی بیای به جستار من تا با هم تو کارگاه من کار کنیم. اینجا:
http://forums.boursy.com/showthread.php?t=3454&p=706279&viewfull=1#post706279
یا علی

Leave Comment

Please login here to leave a comment.

Back