logMACD

Questions about MultiCharts and user contributed studies.
dieten
Posts: 3
Joined: 19 Jan 2015
Has thanked: 1 time

logMACD

Postby dieten » 19 Jan 2015

I want to add a logmacd study to multicharts. The lenghts of the 3 timeseries has to be adjustable and the signal based on changing color of the bars (at min en max lenghts of the bars = ? differnce of the 2 basiclines). I know from other platform only about .tas scripts. They are available on the internet. But how to find a study-script for MC ? Does anybody have logmacd for me or can somebody explain what kind of text I can copy to the Power Language editor ? (I can't write such a text myself, I don't understand a thing of Java.) Thanks. Ferdinand

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: logMACD

Postby JoshM » 21 Jan 2015

I want to add a logmacd study to multicharts.
Open the original MACD indicator for the code:

Code: Select all

inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;

Plot1( var0, "MACD" ) ;
Plot2( var1, "MACDAvg" ) ;
Plot3( var2, "MACDDiff" ) ;
Plot4( 0, "ZeroLine" ) ;
Copy that to a new indicator, and use the Log() keyword to calculate the log value. Since you didn't specify of what value you wanted to take the logarithmic value of, let's assume it's the close. The code then becomes:

Code: Select all

inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = MACD( Log(Close), FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;

Plot1( var0, "MACD" ) ;
Plot2( var1, "MACDAvg" ) ;
Plot3( var2, "MACDDiff" ) ;
Plot4( 0, "ZeroLine" ) ;
The lenghts of the 3 timeseries has to be adjustable
The length of the functions can be set in the default settings of the MACD indicator (see code above: FastLength, SlowLength, MACDLength). But with 'time series' you mean you want three (different?) data series? (Like symbol A, B, and C)
and the signal based on changing color of the bars (at min en max lenghts of the bars = ? differnce of the 2 basiclines).
A signal cannot colour price bars in MultiCharts.
(I can't write such a text myself, I don't understand a thing of Java.)
Luckily, PowerLanguage is much easier than Java, so don't worry. :)

dieten
Posts: 3
Joined: 19 Jan 2015
Has thanked: 1 time

Re: logMACD

Postby dieten » 21 Jan 2015

Thanks JoshM
Now I can compare this script with the one I used in another platform and see whether I can combine it my own version. I will post the result if it works.

dieten
Posts: 3
Joined: 19 Jan 2015
Has thanked: 1 time

Re: logMACD

Postby dieten » 23 Jan 2015

Dear Josh,

It works, but not as I hope for. Adding Log() does not change the result of the indicator , only the values. the logmacd study - I'm used too - has a really different pattern. Only I have it only as DLL, the unreadable compiled version in my other platform.
Thanks for trying .

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: logMACD

Postby orion » 23 Jan 2015

Without knowing what is in the DLL on your other platform, three other things to try out.

1. Try taking log of the sum of price changes over a certain window and not the log of the price. Typically when you take logs, you take logs of price ratios and not price itself. So try do following:

Code: Select all

// original code commented out and new code below
// var0 = MACD( Log(Close), FastLength, SlowLength ) ;
// var1 = XAverage( var0, MACDLength ) ;
// var2 = var0 - var1 ;
var0 = xaverage(Log(close/close[1]), FastLength) - xaverage(Log(close/close[1]), SlowLength ) ;
2. Your other platform may also be referring to the PPO (percentage price oscillator) as log MACD. Google PPO on the web. It takes only 2 lines of PL code.


Return to “MultiCharts”