0

Have a look at the code:

input ENUM_TIMEFRAMES TimePeriod = PERIOD_M1; // Set the timeframe for the stochastic.
void OnInit()
{
 int stochastic_output = iStochastic(_Symbol,TimePeriod,5,3,3,MODE_SMA,STO_LOWHIGH);//initialize the value for Stochastic calculator in Handle.

   if(!ChartIndicatorAdd(0,(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL),stochastic_output)) //Plot initial chart
   {
   Comment("Stochastic Cannot be plotted");
   }
}

I am trying to run the expert that will display the stochastic graph for the particular timeframe as mentioned in the run time.

For 1 minute the graph is working fine but after changing the time to 2 minutes the graph is not displayed or if displayed then it is for the 1 minute. The same is the situation for 5 minutes and so on.

James Z
  • 12,209
  • 10
  • 24
  • 44
Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139

1 Answers1

0

I am afraid you need a multi-timeframe version of the indicator for the opposite task, and probably nothing with help you for what you want.

Multitimeframe indicators are usually displaying global trends, e.g., you have M1 chart open, and you see a H1 moving average on it. for all M1 candles inside any particular hour the values are same, it is a horizontal line that jumps up or down at the beginning of the next hour. What you want is the opposite: you want to have M1 chart at a higher chart. If it could work at M1/M2 then it might work with M1/D1 too, right? then the platform would not know which of the 1440 bars to show, it has only one bar (D1) and has to inject 1440 values there. Probably that is not possible. If we proved it is not possible M1/D1, then it becomes obvious it is not possible with M1/M2 too because of the same reason. If you want to show just last minute candles (16:01,16:03,16:05 that will match with M2 16:00-16:01:59 etc) or the first candle of the period, you have to code your own indicator.

Daniel Kniaz
  • 4,603
  • 2
  • 14
  • 20