PDA

View Full Version : Using MACD indicator in Server side script



nhasan
10-08-2014, 08:26 AM
Hello
I need to use MACD indicator in a server side script
So I am testing the sample code given in this article: http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3067
But I can't get three values of the MACD indicator
Three values of MACD on GOLD Day chart as shown for today on the chart are -
1. MACD: -13.39
2. MACD Histogram: 2.02
3. MACD Signal : -15.51

From the code I can get two values as -
1.
i = DB.getRecordCount
output = output & CSTR(_indRecord.getValue(_indRecord.getName(1), i) ) & vbcrlf
it returns: -52.04
And 2.
i = DB.getRecordCount
output = output & CSTR(_indRecord.getValue(_indRecord.getName(2), i) ) & vbcrlf
it returns: -13.35

None of the value getting from code is exactly equal to any value shown on chart

Can you please help me in getting exactly same 3 values of the MACD indicator from server side code that shown on chart?

nhasan
10-08-2014, 08:34 AM
357
Here is the screenshot of MACD indicator on daily GOLD chart for today

Hassan-HS
10-08-2014, 02:57 PM
Hello Naem,


Make sure you calculate the MacD for the same numbers of bars.

nhasan
10-09-2014, 04:04 AM
Setting for the indicator attached on the chart is default values, Fast EMA: 12, Slow EMA: 26, Signal Line: 9
And in the code variable _recordCount = 100
Function Call: osc.MACD(DB,m_Recordset,9)
It makes one value almost equal i.e. MACD main value 13.39 and 13.35
But what about other values? MACD Signal and MACD Histogram?
How can we get them from code?

nhasan
10-09-2014, 04:39 AM
Another issue, how can we get MACD indicator's value in previous candles?
If I set
i = DB.getRecordCount -1 and execute the following code
output = output & CSTR(_indRecord.getValue(_indRecord.getName(2), i) ) & vbcrlf
that returns: -3.68
But MACD value for the last day was -13.21 as shown on the chart

Hassan-HS
10-09-2014, 12:56 PM
Hello,

Change this line
CSTR(_indRecord.getValue(_indRecord.getName(1), i) ) to be
CSTR(_indRecord.getValue(_indRecord.getName(2), i) ) to get MACD Signal, note that currently you cant get the histogram.

Hassan-HS
10-09-2014, 12:58 PM
output = output & CSTR(_indRecord.getValue(_indRecord.getName(2), i) ) & vbcrlf

This instruction returns the MACD Signal not the MACD value.

Please try this

output = output & CSTR(_indRecord.getValue(_indRecord.getName(1), i) ) & vbcrlf

nhasan
10-12-2014, 04:23 AM
Thanks for detail answer
I noticed that _indRecord.getName(1) and _indRecord.getName(2) return two different value
But none of them are exactly the value of Signal and MACD Value shown on the chart for the same instrument, same time frame.
And most important issue is getting MACD Value for the previous candles, how can we get them ?

Hassan-HS
10-12-2014, 06:21 AM
welcome hasan,


I'll open a ticket with this issue to our development team to check it.

Please standby

Hassan-HS
10-28-2014, 09:01 AM
Dear Hasan,

Our development team is working to solve this issue.
I will keep you posted, please standby.

the ticket number is #96374.

Hassan-HS
12-09-2014, 01:32 PM
Dear Hasan,

This issue has been solved :D