Measure difference between MA/EMA and Market price

Created at 10 Mar 2015, 08:11
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!
DA

davidp13

Joined 06.05.2014

Measure difference between MA/EMA and Market price
10 Mar 2015, 08:11


Hi. Hope someone can help me. I'm looking for a method to measure the pip difference between a MA and Market Price and allocate that to a variable. What would the code look like to do something like that?

Thanks


@davidp13
Replies

davidp13
11 Mar 2015, 09:16

RE:

Any help pls...

davidp13 said:

Hi. Hope someone can help me. I'm looking for a method to measure the pip difference between a MA and Market Price and allocate that to a variable. What would the code look like to do something like that?

Thanks

 


@davidp13

modarkat
12 Mar 2015, 17:51

Difference in pips between SMA and Bid price:

        SimpleMovingAverage sma;

        protected override void OnStart()
        {
            sma = Indicators.SimpleMovingAverage(MarketSeries.Close, 14);
        }

        protected override void OnTick()
        {
            var pipsDifference = (Symbol.Bid - sma.Result.LastValue) / Symbol.PipSize;
        }

 


@modarkat