how to get the highest value of standard deviation for last 2 hours

 

I'm trying to develop an ea, so far I can understand and write this which will place orders when a new bar opens.

int BarsCount = 0;
 
int start()
{
 
if (Bars > BarsCount)
{

 OrderSend(Symbol(),OP_BUY,0.01,Ask,2,NULL,NULL);
                                     
    BarsCount = Bars;
 }
 
  return(0);

how to get the highest value of standard deviation for last 2 hours to a variable?

eg: lets say the EA runs in a 30 mins chart and the bar1 has the standard deviation value 0.003, and bar2 has 0.001, bar3 has 0.004 and bar4 has 0.001. 
So, the highest value for past 4 hours is bar3 which has the value of 0.004, so how to get that value to a variable?

I'm trying to make the EA place orders when this formula is true "((current value of standard deviation/highest value of standard deviation for last 2 hours)*100 ) > 10" 

 
  1. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 forum.) Always use time. New candle - MQL4 forum
    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
  2. Check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  3. How did you come up with 0.004? Code it exactly the same way. We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem. No free help. urgent help.
Reason: