2 Color MACD Histogram

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Re: 2 Color MACD Histogram

Postby arunaa » Sun Dec 27, 2009 6:22 pm

Hi Tony,
That MACD works amazing..CAn you code a crossover similar to that but works like this..

1)the short moving average which gives the (highest high+lowest low)/2 for the past 9 periods
2)the longer moving average which gives the (highest high+lowest low)/2 for the past 26 periods

The crossover of the two line is very powerful..i tried coding it but it did not work..it uses the formulas of the tenkan-sen and kijun-sen of the ichimoku indicator..

highest high is the topmost part of any candle..
lowest low is the lowest part of the candle..

Arun
arunaa
FXCodeBase: Confirmed User
 
Posts: 19
Joined: Tue Dec 15, 2009 1:27 pm

Re: 2 Color MACD Histogram

Postby TonyMod » Mon Dec 28, 2009 1:16 pm

arunaa wrote:Hi Tony,
That MACD works amazing..CAn you code a crossover similar to that but works like this..

1)the short moving average which gives the (highest high+lowest low)/2 for the past 9 periods
2)the longer moving average which gives the (highest high+lowest low)/2 for the past 26 periods

The crossover of the two line is very powerful..i tried coding it but it did not work..it uses the formulas of the tenkan-sen and kijun-sen of the ichimoku indicator..

highest high is the topmost part of any candle..
lowest low is the lowest part of the candle..

Arun


I'm not sure if i understand correctly, but from what you wrote i think you want regular moving average lines? One line is short for 9 periods and another one is long for 26 periods?

I've recoded current one to use simple moving average (MVA or SMA as some call it) instead of exponential moving average, i tested it and it seems to work.

MACD2 with SMA-MVA.lua
MACD that uses simple moving average instead of exponential moving average. Download in .LUA.
(5.18 KiB) Downloaded 1581 times


If i misunderstood let me know.

EDIT: By the way, i might as well explain what i did so you can have little more control with your LUA indicators in future.

FROM> indicator:name("MACD1");
TO>indicator:name("MACD with MVA instead of EMA");
(This is just a display name of the indicator)

FROM> indicator.parameters:addInteger("SN", "Short EMA", "(SN)No Description", 12, 2, 1000);
FROM> indicator.parameters:addInteger("LN", "Long EMA", "(LN)No Description", 26, 2, 1000);
TO> indicator.parameters:addInteger("SN", "Short MVA", "(SN)No Description", 12, 2, 1000);
TO> indicator.parameters:addInteger("LN", "Long MVA", "(LN)No Description", 26, 2, 1000);
(Here i changed parameter names, RED: Those are parameters for actual periods, you can change them here or inside of MarketScope. Right click indicator line when you see it selected go to "Change Indicator", OR you can do this at creation time.)

FROM> EMAS = core.indicators:create("EMA", source, SN);
FROM> EMAL = core.indicators:create("EMA", source, LN);
TO> EMAS = core.indicators:create("MVA", source, SN);
TO> EMAL = core.indicators:create("MVA", source, LN);
(This is the actual place where you tell Indicore to create MVA indicators lines instead of EMA, you can specify here any indicators that are available in your installation, you specify them by their name.)

Hope it helps some. If not, let me know i'll do my best to get your problem solved.
Best Regards,

"TonyMod"
(FXCodeBase.com Forum Moderator)
TonyMod
FXCodeBase: Site Admin
 
Posts: 70
Joined: Wed Oct 21, 2009 1:57 pm
Location: New Jersey

Re: 2 Color MACD Histogram

Postby arunaa » Mon Dec 28, 2009 4:54 pm

Dear Tony,
I am sorry not to have explained it properly..

I want 2 lines
the first line is the (highest high+lowest low)/2 for the past 9 periods
the second line is the (highest high+lowest low)/2 for the past 26 periods

These two lines need to be plotted below the price curve..
These line are exactly the same as the Tenkan-Sen and the Kijun-Sen for the Ichimoku indicator...
CAn you modify ichimoku-indicator to display only these 2 lines(ignoring the other 3 lines) below the price curve(right now ichimoku is plotted on the price curve)..

By the way the new Macd works great..
Arun
arunaa
FXCodeBase: Confirmed User
 
Posts: 19
Joined: Tue Dec 15, 2009 1:27 pm

Re: 2 Color MACD Histogram

Postby TonyMod » Tue Dec 29, 2009 11:56 am

arunaa wrote:Dear Tony,
I am sorry not to have explained it properly..

I want 2 lines
the first line is the (highest high+lowest low)/2 for the past 9 periods
the second line is the (highest high+lowest low)/2 for the past 26 periods

These two lines need to be plotted below the price curve..
These line are exactly the same as the Tenkan-Sen and the Kijun-Sen for the Ichimoku indicator...
CAn you modify ichimoku-indicator to display only these 2 lines(ignoring the other 3 lines) below the price curve(right now ichimoku is plotted on the price curve)..

By the way the new Macd works great..
Arun


OK, sorry that i didn't understand the first time. I'll get this done for you as soon as i can.
Little clarification though (just to make sure), do you need it on top of this MACD colored indicator or as separate instance completely?
Best Regards,

"TonyMod"
(FXCodeBase.com Forum Moderator)
TonyMod
FXCodeBase: Site Admin
 
Posts: 70
Joined: Wed Oct 21, 2009 1:57 pm
Location: New Jersey

Re: 2 Color MACD Histogram

Postby arunaa » Tue Dec 29, 2009 1:06 pm

Hi Tony,

This would be a separate indicator by itself..(not on top of the MACD)..The histogram would be same as MACD and the red and green colors same as the new MACD (red for decreasing and green for increasing), but the lines are the two lines defined below.

line 1) (highest high+lowest low)/2 for the past 9 periods
line 2) (highest high+lowest low)/2 for the past 26 periods

Arun
arunaa
FXCodeBase: Confirmed User
 
Posts: 19
Joined: Tue Dec 15, 2009 1:27 pm

Re: 2 Color MACD Histogram

Postby TonyMod » Wed Dec 30, 2009 10:33 am

arunaa wrote:Hi Tony,

This would be a separate indicator by itself..(not on top of the MACD)..The histogram would be same as MACD and the red and green colors same as the new MACD (red for decreasing and green for increasing), but the lines are the two lines defined below.

line 1) (highest high+lowest low)/2 for the past 9 periods
line 2) (highest high+lowest low)/2 for the past 26 periods

Arun


Ok Arun thanks,

I understand, let me get this thing done for you. I'll try to do this as quick as i can, but it being holiday starting today, mostly likely i wont have time to get this done until work starts again next Monday approximately.

I'll post it as soon as it is done.

Cheers and Happy New Year!
Best Regards,

"TonyMod"
(FXCodeBase.com Forum Moderator)
TonyMod
FXCodeBase: Site Admin
 
Posts: 70
Joined: Wed Oct 21, 2009 1:57 pm
Location: New Jersey

Re: 2 Color MACD Histogram

Postby TonyMod » Mon Jan 04, 2010 3:23 pm

arunaa wrote:Hi Tony,

This would be a separate indicator by itself..(not on top of the MACD)..The histogram would be same as MACD and the red and green colors same as the new MACD (red for decreasing and green for increasing), but the lines are the two lines defined below.

line 1) (highest high+lowest low)/2 for the past 9 periods
line 2) (highest high+lowest low)/2 for the past 26 periods

Arun


Ok Arun,

There have been some problems with your request as is. See when TenkunSen and KijunSen lines are applied to a Oscillator, lines and histogram have too much difference between them. This is how it turns out looking:
2-combined.gif
TenkunSen and KijunSen lines and their Histogram on top of Oscillator.

Reason for that is that histogram numbers go around 0, so -1.24 or 1.43, thats the difference.. So as you understand those 2 ichimoku lines are always positive and in high numbers, around the actual price so to say.

I thought for a little bit, and figured that best way to get you the functionality you desire is to make 2 indicators and run them at the same time. One would be a histogram oscillator and other would be a ichimoku indicator but only with those 2 lines you need. Here is how it looks when you run those 2 indicators:
2-separate.gif
2 separate indicators run at the same time. This is the better version in my opinion.


Here are 2 files you need to run in MarketScope:
ICH-indicator-TenkunSen-KijunSen.lua
Download: Custom Ichimoku indicator. Tenkun-Sen and Kijun-Sen lines only.
(1.97 KiB) Downloaded 1591 times

ICH-oscillator-TenkunSen-KinjunSen Histogram.lua
Download: Custom Ichimoku oscillator. Tenkun-Sen and Kijun-Sen difference. (Histogram = TenkunSen - KenjunSen)
(2.92 KiB) Downloaded 1608 times


Calculation for histogram is following: Histogram Bar = TenkunSen - KijunSen.
If you need it be other way around let me know i'll change it.

Let me know if it works for you.
Best Regards,

"TonyMod"
(FXCodeBase.com Forum Moderator)
TonyMod
FXCodeBase: Site Admin
 
Posts: 70
Joined: Wed Oct 21, 2009 1:57 pm
Location: New Jersey

Re: 2 Color MACD Histogram

Postby arunaa » Mon Jan 04, 2010 5:03 pm

Hi tony,
That oscillator histogram is amazing and perfect..

Well done and thank you for helping us.

Arun
arunaa
FXCodeBase: Confirmed User
 
Posts: 19
Joined: Tue Dec 15, 2009 1:27 pm

Re: 2 Color MACD Histogram

Postby TonyMod » Mon Jan 04, 2010 5:35 pm

arunaa wrote:Hi tony,
That oscillator histogram is amazing and perfect..

Well done and thank you for helping us.

Arun


No problem. Ichimoku lines are correct since i added ICH indicator on top of them, and it seemed to cover it perfectly. But i wanted to make sure that histogram and histogram's coloring is correct. If you find that it is inverted please let me know i'll get it fixed.

Cheers.
Best Regards,

"TonyMod"
(FXCodeBase.com Forum Moderator)
TonyMod
FXCodeBase: Site Admin
 
Posts: 70
Joined: Wed Oct 21, 2009 1:57 pm
Location: New Jersey

Re: 2 Color MACD Histogram

Postby Jerry77 » Mon Jan 04, 2010 11:04 pm

Thanks guys, that was spot on !!! God Bless and happy trading.
Jerry77
FXCodeBase: Confirmed User
 
Posts: 8
Joined: Thu Dec 03, 2009 1:00 am

PreviousNext

Return to Discussions

Who is online

Users browsing this forum: No registered users and 2 guests