MACD Histogram Last Value

Created at 27 Jan 2014, 04:19
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MRCR's avatar

MRCR

Joined 08.01.2014

MACD Histogram Last Value
27 Jan 2014, 04:19


Hello there, this is my first post :)

I'm very new to C# and to API's in general, but i like to learn not only by reading but by doing. I've started to develop a simple bot to compute the difference in MACD Main Histogram values, but i got some weird results.

Then I debugged it using:

        protected override void OnBar()
        {
            Print(_macd.Histogram.LastValue);
        }

And the type of values appearing are nothing I expected while reading the normal histogram main values at the chart, I want to see 0.00005 and I see -6,18447259341792E-05 at the log, am I missing something? Do I need to do some sort of conversion or mathematical calculation?

Thank you,

I hope to start contributing to this community as soon as possible, for now bare with my noobness :)


@MRCR
Replies

MRCR
27 Jan 2014, 12:31

RE:

anyone? I just need a hint... 


@MRCR

Old Account
27 Jan 2014, 15:45

  Print("{0}", _macd.Histogram.LastValue);


@Old Account

daemon
27 Jan 2014, 16:27

Which values are you looking at exactly on the chart? You can use the market snapshot tool and look at the value for the Histogram Main. The signal would be the line not the histogram.  Maybe test the previous value since the last value would be the current value which constantly changes with new ticks. You can confirm the price by testing the previous bar value. 


@daemon

MRCR
27 Jan 2014, 23:07

RE:

MRSV said:

  Print("{0}", _macd.Histogram.LastValue);

Hi MRSV the result is the same, since I'm printing the result of the variable straight away. But thank you.


@MRCR

MRCR
27 Jan 2014, 23:25 ( Updated at: 21 Dec 2023, 09:20 )

RE:

daemon said:

Which values are you looking at exactly on the chart? You can use the market snapshot tool and look at the value for the Histogram Main. The signal would be the line not the histogram.  Maybe test the previous value since the last value would be the current value which constantly changes with new ticks. You can confirm the price by testing the previous bar value. 

Hi daemon, thank you for replying, I'll try to explain the best I can.

As you can see in the image above, The result from Print("{0}", _macd.Histogram.LastValue); has nothing to do with the value from the chart MACD Histogram Main, this is what i want, I want to be able to access the same value the Chart gives me, the -00013 not the -7.36039...

I'm not trying to trade the MACD signal but the histogram itself. My question for you or any spotware dev is: How can I access the -00013 instead of the -7.36039, do I need to normalize the result somehow? Do I need to calculate something extra?

BTW the data you see in both red squares are both @ 18:40h so they should be identical.

Thank you very much so far for the feedback. :)


@MRCR

Old Account
28 Jan 2014, 00:27

Well its not -7.36039, It's -0,0000736039. 

-7.36039-E05 = -7.36039*10^-5 <=> -0,0000736039.


@Old Account

MRCR
28 Jan 2014, 06:24

RE:

MRSV said:

Well its not -7.36039, It's -0,0000736039. 

-7.36039-E05 = -7.36039*10^-5 <=> -0,0000736039.

Thank you, since your reply i got to search how to convert from scientific notation to decimal, and I have the numbers I wanted :)
Let the next hundred problems begin.


@MRCR

Researcher
28 Jan 2014, 07:02

  Print("{0:0.00000}", _macd.Histogram.LastValue);

or

double value = Math.Round( _macd.Histogram.LastValue, 5);
Print(value);

 


@Researcher