Is it possible?

 
Hi all,
i want my EA to trade on a 5mins chart, but part of its signal comes from 30mins chart, so i want to know if it is possible get the value of the stochastic signal below,when the code is actually attached to a 5mins chart.thanks for any comment.

(iStochastic(NULL,PERIOD_30,5,3,3,MODE_SMA,0,MODE_MAIN,0)

 

There's no reason why it shouldn't work, though I think it's supposed to be:

(iStochastic(NULL,PERIOD_M30,5,3,3,MODE_SMA,0,MODE_MAIN,0);
But test it, if you haven't.
You can put a print statement saying:
Print("30 Min Stochastic = "+(iStochastic(NULL,PERIOD_M30,5,3,3,MODE_SMA,0,MODE_MAIN,0));
Then run Strategy Tester and compare the value in the logs with the one on the chart to be sure it's working correctly. It may not be exact because 1) the data source may not be the same as the source your chart uses and 2) Stochastics change throughout the candle, but it should be close enough to determine whether or not it's working correctly.
 
In the tester you can not get bar zero of other timeframes. so iStochastic(...0) will not work. (...1) should.
 
WHRoeder:
In the tester you can not get bar zero of other timeframes. so iStochastic(...0) will not work. (...1) should.

Really?

Adapting joetrader's code, the following appears to work for me if I backtest it on e.g. M15. It appears to deliver the correct in-progress value for the partially complete M30 bar. It's well known that you can't query a different symbol in the backtester, but I'm not aware that you don't have access to other timeframes on the same symbol.

int start() {Comment("30 Min Stochastic = " + iStochastic(NULL,PERIOD_M30,5,3,3,MODE_SMA,0,MODE_MAIN,0));}
 

I forgot to mention that I usually test whatever I'm writing in a script first, because it's easier to see if something's working. So you could use this script and test it this way first, then put it in your EA and test it there:

int start()
   {      
   MessageBox("30 Min Stochastic = "+(iStochastic(NULL,PERIOD_M30,5,3,3,MODE_SMA,0,MODE_MAIN,0)));   
   }

Reason: