Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Inappropriate range on macd parameter
 Post subject: Inappropriate range on macd parameter Post rating: 0   New post Posted: Fri 17 Oct, 2014, 12:45 

User rating: 1
Joined: Tue 14 Jan, 2014, 16:13
Posts: 21
Location: United KingdomUnited Kingdom
Attempting to use the inbuilt macd indicator from an indicator of mine, I got error message which I tracked down to an inappropriate restriction of the first optInputParameter to values >=2. 1 is a perfectly legitimate value for the first parameter: making the indicator useful for comparing the current price to an EMA, a very useful operation.

Please can this range be changed to include 1?

Note that it may be necessary to change the range for EMA as well, depending on how MACD is implemented (I haven't checked). I see that there are unnecessary restrictions on all of the other types of moving averages as well. While moving averages with length set to 1 are the same as the most recent price, it is useful to include length 1 so that software that varies the parameter can use this option. Might these ranges be altered as well for this eventuality? [I am thinking of EMA, SMA, LWMA, but this surely applies to other moving averages as well].

Meanwhile, I now need to write a little more code to do the calculation that Macd would have done for me if it would accept the length 1 ...

[Admin: please feel free to move this to feature requests or even to bug reports. It was careless of me to put it here.]


 
 Post subject: Re: Inappropriate range on macd parameter Post rating: 0   New post Posted: Fri 17 Oct, 2014, 13:25 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
If MA is called with time period 1, then indicator's outputs are going to be equal to it's inputs. Therefore MA(1) is meaningless.
MACD looks at differences between two MAs. In case when one MA has time period 1, whole MACD indicator can be substituted with single MA and original price value.
Requested changes would not only require additional work but also introduce unnecessary complexity into MACD indicator.


 
 Post subject: Re: Inappropriate range on macd parameter Post rating: 0   New post Posted: Fri 17 Oct, 2014, 17:44 

User rating: 1
Joined: Tue 14 Jan, 2014, 16:13
Posts: 21
Location: United KingdomUnited Kingdom
Firstly, I will point out that I am familiar with several other trading platforms over the last 15 years and that in every one of them both moving averages and MACDs permit the value 1 as a input, and I have used this option (for moving averages it makes coding simpler where the input is varied but might sometimes take the value 1). Having also occasionally implemented such calculations from scratch I have not had any problems incorporating the value 1 as a scale. It's safe to say there is no increase in complexity. Yes, there is the need for a minor tweak to code now, but that is because of a completely unnecessary built in limitation when the indicator was originally written.

My main point is concerning MACD. It may not be obvious to you, but the difference of the current price and an EMA is of particular significance because the current price is the most up to date and is available for trading. If you need more convincing, note that the popular CCI indicator incorporates the difference of the current price (traditionally (H+L+C)/3 is used, providing a tiny amount of smoothing and lag) against an SMA and then normalises this. It would be an error to think that comparing a 2 period moving average to another moving average is somehow more meaningful than comparing price to a moving average: they are just slightly different.

Yes it can be calculated by hand by a user by using an EMA and then writing their own indicator code to calculate the difference between a price and and EMA, but that is not a good argument for not allowing the MACD indicator to do this calculation directly, as an indicator output. Indeed you could just as well say MACD should never have been implemented because users could easily just subtract two EMAs themselves, etc. ;)

Seriously, this is a tiny suggested edit involving no increase in complexity, and would be worth scheduling in order to ensure Dukascopy indicators have the same scope as those on other platforms.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com