Multi TimeFrame how to display different MA

Created at 10 Jun 2014, 15:42
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!
breakermind's avatar

breakermind

Joined 17.07.2013

Multi TimeFrame how to display different MA
10 Jun 2014, 15:42


Hi,

How to change parametr when change chart TimeFrame (if M1 ---> Param = 0;  if M15 param = 100)?

I need display different MA on each timeframe?

Thanks


@breakermind
Replies

Spotware
11 Jun 2014, 09:08

You can check the TimeFrame in the code:

if (TimeFrame == TimeFrame.Minute)
  param = 0;
if (TimeFrame == TimeFrame.Minute15)
  param = 100;

 


@Spotware

breakermind
12 Jun 2014, 09:28

RE:

Hi and thanks,

 

I have this:

        public override void Calculate(int index)
        {

            // access to different series
            var weeklySeries = MarketData.GetSeries(TimeFrame.Weekly);

            // open price bars
            double open = weeklySeries.Open[index];
            Print(open);

            // If first bar is first bar of the day set open
            Week1Open[index] = open;

        }

How get Week open price and draw line on this price ? what is wrong ? 


@breakermind

Spotware
12 Jun 2014, 09:33

RE: RE:

breakermind said:

Hi and thanks,

 

I have this:

        public override void Calculate(int index)
        {

            // access to different series
            var weeklySeries = MarketData.GetSeries(TimeFrame.Weekly);

            // open price bars
            double open = weeklySeries.Open[index];
            Print(open);

            // If first bar is first bar of the day set open
            Week1Open[index] = open;

        }

How get Week open price and draw line on this price ? what is wrong ? 

index is wrong. The weeklySeries object has different indexes.


@Spotware

breakermind
12 Jun 2014, 09:46

RE: RE: RE:

Spotware said:

breakermind said:

Hi and thanks,

 

I have this:

        public override void Calculate(int index)
        {

            // access to different series
            var weeklySeries = MarketData.GetSeries(TimeFrame.Weekly);

            // open price bars
            double open = weeklySeries.Open[index];
            Print(open);

            // If first bar is first bar of the day set open
            Week1Open[index] = open;

        }

How get Week open price and draw line on this price ? what is wrong ? 

index is wrong. The weeklySeries object has different indexes.

Cool,

something is wrong with this spotware cAlgo,

if do not hang it terribly slow ... shows some strange results ... in backtests

Support helpful as usual ...

... defeat.

Bye.

 

 


@breakermind

Spotware
12 Jun 2014, 11:12

something is wrong with this spotware cAlgo,

if do not hang it terribly slow ... shows some strange results ... in backtests

Please try to be more specific. We cannot answer to not clear questions.


@Spotware

aysos75
11 Jul 2015, 15:01

RE: RE: RE: RE:

breakermind said:

Spotware said:

breakermind said:

Hi and thanks,

 

I have this:

        public override void Calculate(int index)
        {

            // access to different series
            var weeklySeries = MarketData.GetSeries(TimeFrame.Weekly);

            // open price bars
            double open = weeklySeries.Open[index];
            Print(open);

            // If first bar is first bar of the day set open
            Week1Open[index] = open;

        }

How get Week open price and draw line on this price ? what is wrong ? 

index is wrong. The weeklySeries object has different indexes.

Cool,

something is wrong with this spotware cAlgo,

if do not hang it terribly slow ... shows some strange results ... in backtests

Support helpful as usual ...

... defeat.

Bye.

 

 

 

 

In the 'Calculate', 'index' is the index of the current timeframe candles eg M1. But if you want to retrieve values OLHC (Open High Low Close) a candle from another timeframe eg H1, we can not do it with 'index' because the index of the two series corresponding to the two timeframes are distinct. We must use the conversion method GetIndexByExactTime ( (MarketSeries.OpenTime [index]) or GetIndexByTime (MarketSeries.OpenTime [index]).


@aysos75