**jafferwilson:**

Check this program I am trying to get the values of the Stochastic

Here is the output I got:

The above values represents Array elements as 0th, 1st,2nd,3rd & 4th

What is the 0th in the initial print will become the previous for the next and will be placed at the 1st position in the next print.

But I see the values has changed and is drastic.

Previously the iStochastic() was giving the right and correct values. But it was working OnTick()and hence was giving the output for every change. I only need the values when the bar is complete or after minute. So, I tried the solution from the community. Here is the link: solution for newbar

But the output is infront and is changing the equation of my trade which is why I am losing it.

Please help me. How I can make it work for me?

Here are the files needed: Lib CisNewBar.mqh

Placed the same questioon here: https://stackoverflow.com/questions/49550100/isnewbar-not-producing-the-right-time-stochastic-value-ontick-mql5

Stochastic calculation to be done at each tick, data retrieve at each new bar :

#include <Lib CisNewBar.mqh> CisNewBar current_chart; // instance of the CisNewBar class: detect new tick candlestick double K[],D[]; // declare it once void OnInit() { int stoch = iStochastic(_Symbol,PERIOD_M1,5,3,3,MODE_SMA,STO_LOWHIGH); // load it once !!!!! ArraySetAsSeries(K,true); // set it once ArraySetAsSeries(D,true); // set it once } void OnTick() { CopyBuffer(stoch,0,0,5,K); // there CopyBuffer(stoch,1,0,5,D); if(current_chart.isNewBar() > 0) { CopyBuffer(stoch,0,0,5,K); // or there ... CopyBuffer(stoch,1,0,5,D); ArrayPrint(K); // ask for value at each new bar } }

Check this program I am trying to get the values of the Stochastic

Here is the output I got:

The above values represents Array elements as 0th, 1st,2nd,3rd & 4th

What is the 0th in the initial print will become the previous for the next and will be placed at the 1st position in the next print.

But I see the values has changed and is drastic.

Previously the iStochastic() was giving the right and correct values. But it was working OnTick()and hence was giving the output for every change. I only need the values when the bar is complete or after minute. So, I tried the solution from the community. Here is the link: solution for newbar

But the output is infront and is changing the equation of my trade which is why I am losing it.

Please help me. How I can make it work for me?

Here are the files needed: Lib CisNewBar.mqh

Placed the same questioon here: https://stackoverflow.com/questions/49550100/isnewbar-not-producing-the-right-time-stochastic-value-ontick-mql5