English

## Calling the Sto out of another indicator

 315 sunshineh 2016.03.23 00:57   Hi, I am writing an indicator and at each new bar I need the last 10 Stochastic values.For testing I put in my loop the following code in my indicator:    for(int i=1; i
 13006 WHRoeder 2016.03.23 01:28 #   sunshineh: When I put the indicaor on a runing chart (in the strategie tester) I see my time is runnig, but I am getting allways the same value for the stochastic[i]. You are only printing the stochastic of bar 1. Bar 1 has closed, nothing will ever change. The value will NOT change until a new bar forms and there is a new bar 1.
 315 sunshineh 2016.03.23 10:09 #   Here is the hole code from my test indicator. And below are the pictures from testing this indicator at M5 = same Period, and at M1 = Period below Sto-Period. So normaly I think in the second chart must be the Sto-Value always for 5 candles be the same. But it shows the same value for the hole chart?!```//+------------------------------------------------------------------+ int OnInit()   { //--- indicator buffers mapping    //---    return(INIT_SUCCEEDED);   } //+------------------------------------------------------------------+ //| Custom indicator iteration function                              | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total,                 const int prev_calculated,                 const datetime &time[],                 const double &open[],                 const double &high[],                 const double &low[],                 const double &close[],                 const long &tick_volume[],                 const long &volume[],                 const int &spread[])   {     for(int i=1; i
 315 sunshineh 2016.03.23 10:11 #
 19 Sya 2016.03.23 12:16 #   Hello Sunshineh,as far as I see, WHRoeder is completely right. If you need the 10 last Stochastic values, you'll have to make a loop that allows to go back the last 10 finished bars.So change `i==1`to i <= 10and check, if the result fits your request.
 315 sunshineh 2016.03.23 12:26 #   That's clear! I only put "i==1" in this indicator as example to show, that the stochastic value is always the same when I call the sto-value from M5 out of my M1 test.
 315 sunshineh 2016.03.23 12:38 #   In other words, I get in my indicator the Sto-Values from another timeframe to work with it.The Values from another timeframe out of my Expert Advisor is no problem.
 19 Sya 2016.03.23 12:55 #   Would you mind to post the non-functioning code? With something modified it would be more a guessing game.
 315 sunshineh 2016.03.23 14:23 #   Have you tried the indicator about at the strategy-tester? Once at M1 and once at M5 (and put the sto- below the chart).Than you will get the results shown on my screenshots.
 315 sunshineh 2016.03.23 15:00 #   I think, I realized my error.I can't explain,why it is acting that way, but I see, that my testing steps cause this error!That was my way:1.I created an empty EA, for visual testing.2.I started this EA in visual mode 3.I put my programmed indicator on this chart (which is calling the sto from the other timeframe) >>> here I am always getting the same value, as you can see on my error "picture".  Correct way:1.I integrate the indicator into my test EA and start the visual test. Now I get the following correct picture:
 19 Sya 2016.03.25 03:08 #   Great that you found a solution for this strange behaviour. I have no explanation either, but I also haven't yet tested in this special constellation you describe.