It's giving me the same value on any timeframe so maybe it's the TFMigrate() function.
ENUM_TIMEFRAMES result[]={PERIOD_H1,PERIOD_H3,PERIOD_H6}; for(int l=ArraySize(result)-1;l>=0;l--) { int to_copy=2; double StoMain[],StoSignal[]; int Sto_Handle=iStochastic(Symbol(),result[l],7,3,3,MODE_SMA,STO_LOWHIGH); if(CopyBuffer(Sto_Handle,MAIN_LINE,0,to_copy,StoMain)<=0)return(0); if(CopyBuffer(Sto_Handle,SIGNAL_LINE,0,to_copy,StoSignal)<=0)return(0); ArraySetAsSeries(StoMain,true); ArraySetAsSeries(StoSignal,true); if((int)result[l]==16387 /*&& i==4*/) printf("Timeframe:%s StochMain:%f",EnumToString(result[l]),StoMain[1]); if(StoMain[1]< StoSignal[1]) { //ObjectSetInteger(0,"TC"+IntegerToString(i+1)+results[l],OBJPROP_BGCOLOR,clrRed); //ObjectSetInteger(0,"TC"+IntegerToString(i+1)+results[l],OBJPROP_COLOR,clrRed); } if(StoMain[1]>= StoSignal[1]) { //ObjectSetInteger(0,"TC"+IntegerToString(i+1)+results[l],OBJPROP_BGCOLOR,clrGreen); //ObjectSetInteger(0,"TC"+IntegerToString(i+1)+results[l],OBJPROP_COLOR,clrGreen); } }
Ernst Van Der Merwe:
It's giving me the same value on any timeframe so maybe it's the TFMigrate() function.
Thanks Ernst, you were correct it was an issue with the TFMigrate().
Regard
Richard

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I have the below piece of code, which is supposed to read the values of the stochastic at different timeframes. When the chart is on the same timeframe as the requested stochastic timeframe, it gives the correct reading, however when it is on a different timeframe to the one requested it generates incorrect values. What am I doing wrong? result[] caries the different timeframe values, candle represents 1.