Only first instance of chart appears, then disappears with change of TF

 

Hi All,

Please see attached mq4 file.

I have modified this to display charts in 4 TFs at once in the same window, from the original (correctly working) mq4 that only displays one chart at one time, as here: http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?f=45&t=629 no. 2 in Post #1 (Currency Slope Strength.)

I attached this modified indi on a chart on the M1 timeframe, hoping to see all M1, H1, H4 and D1 displays. It only gave me the M1 chart along with the text label column (leftmost.) When I randomly switched the MT4 TF to H1, it displayed a chart where the H1 chart should have been displayed. But after toggling the TFs, both charts disappeared, and I was only left with the text column displayed for M1. Restarting MT4 is no help.

My modifications:

1. All the mods are in the part marked "Main Routine" start() except the input change to MTF.

What I basically did was:

- Bring in the horizontalOffest (for the column text display, as in the routine ShowCurrencyTable) into the main routine, and loop both this and SetIndexShift (for chart plot position).

- Change the extern single TF input to string PeriodsToTrade[4]= {"M1", "H1", H4", "D1"}; then assign, in main routine,

timeFrame = PeriodsToTrade[j] in a loop.

Can anyone help here?

Cheers,

Athar.

Toronto.

Files:
 
atharmian:

Hi All,

Please see attached mq4 file.

I have modified this to display charts in 4 TFs at once in the same window, from the original (correctly working) mq4 that only displays one chart at one time, as here: http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?f=45&t=629 no. 2 in Post #1 (Currency Slope Strength.)

Are all your modifications marked so people can see what you have done ?
 

atharmian: I have modified this to display charts in 4 TFs at once

  for ( i = limit; i >= 0; i-- ){                            // i is the current chart bar
      :                                                      // Current chart's Period()
      calcCSS( userTimeFrame, i );
:
void calcCSS( int tf, int shift ){
   :
   for ( i = 0; i < symbolCount; i++){
      double slope = getSlope(symbolNames[i], tf, shift);   // Shift is for the tf.
:
Can't use shift=i if tf != Period. Go look at some MTF indicators.
 
RaptorUK:
Are all your modifications marked so people can see what you have done ?


Simon,

Thanks for the quick response.

1. All the mods are in the part marked "Main Routine" start(), except for the input change to MTF.

What I basically did was:

- Bring in the horizontalOffest (for the column text display, as in the routine ShowCurrencyTable) into the main routine, and loop both this and SetIndexShift (for chart plot position).

- Change the extern single TF input to string PeriodsToTrade[4]= {"M1", "H1", H4", "D1"}; then assign, in main routine,

timeFrame = PeriodsToTrade[j] in a loop.

2. As a newbie, I need ask: How do you color highlight parts of code? Also there is a w633 editor floating around as a GitHub scite tool; is this a better bet than native, if you know? http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?f=15&t=627

3. If you can help with the code, that'll be great ! I am now going to reply WHRoeder that the mods he suggested are there already... Maybe I have missed something in his answer.

Regards

Athar.

 
WHRoeder:
Can't use shift=i if tf != Period. Go look at some MTF indicators.


William,

I really am amazed at the quick turnaround :) Thanks ...

I looked at your suggestion, but unless I have missed something, all what you proposed is there already !

I am assuming that, above the void calcCSS routine, you were referring to code snippets in the start ("Main routine.")

So what should I do?

It looks like MQL4 has a lot of native tips and tricks to be learned. Any good source besides the official MQL4 page you can suggest as reading?

Regards,

Athar.

 
atharmian: I looked at your suggestion, but unless I have missed something, all what you proposed is there already
I didn't make any suggestion. I told you what was wrong. I told you to look at some MTF indicators to see how they map chart bar index to other TF index (two flavors, iBarShift and ArrayCopySeries) You are NOT doing either.
 
WHRoeder:
I didn't make any suggestion. I told you what was wrong. I told you to look at some MTF indicators to see how they map chart bar index to other TF index (two flavors, iBarShift and ArrayCopySeries) You are NOT doing either.


William,

From your first comment, "I have modified this to display charts in 4 TFs at once," to me meant that you did update code. You did not.

I did look around, but got confused.... e.g., here http://www.forexfactory.com/showthread.php?t=214326, which seemed most helpful.

1. But then should I use, in the start() routine: int shift = iBarShift( NULL, userTimeFrame, Time[i],True)+1;

// +1 is delay to not ask for future price.

and how will above relate to: calcCSS( userTimeFrame, i ) ?

2. Or something else? As I said, I am not a coder, and it will take me long time to read up and understand, which I why I am posting this problem !


Regards,

Athar.

int start()

  {
   int i, shift, counted_bars=IndicatorCounted();
   i = Bars-counted_bars-1;
   while(i>=0)
   {
     shift     = iBarShift(NULL,TimeFrame,Time[i],True)+1;
     Buffer[i] = iMA(NULL,0,MaPeriod,0,MaMethod,AppliedPrice,i);
     MTFBuffer[i] = iMA(NULL,TimeFrame,MaPeriod,0,MaMethod,AppliedPrice,shift);
     i--;
   }
   return(0);
  }