




WHRoeder:
Hi WHRoeder, Thanks for the response, I do appreciate the guidance. My problem was that I'd Read The Fabulous Manual, but didn't understand what the short twoword description of each option meant. The lack of examples and guidance was worrying me. So a few followup questions: In MQL4, is it possible to have the EA look at a 2 Hour timeframe? If I am trying to have it look at 2 hour's worth of 30second bars, it seems then that I'm doing this completely wrong. What would be the right way around? Also  is there a more detailed documentation of the functions and what they mean? I fear that as I'm new to MQL, the short explanations in the help guide don't always mean very much to me.


MelesMeles: In MQL4, is it possible to have the EA look at a 2 Hour timeframe? If I am trying to have it look at 2 hour's worth of 30second bars, it seems then that I'm doing this completely wrong. What would be the right way around? MT4 doesn't have history data more finegrained than M1. The timeframes which it supports are those you can see on the toolbar in the user interface: M1, M5, M15, M30, H1, H4, D1, W1, MN1. You can't do any kind of calculation involving 30second bars because MT4 doesn't have history data of sufficient detail. It would be possible, if cumbersome, to go upwards in terms of timeframes. For example, if you wanted to do a calculation on an unsupported period such as M3 or H2, then you could get the history data for a lower timeframe (e.g. M1 or H1); aggregate the history into the bars you wanted (e.g. combining each three M1 bars into an M3 bar); and then do a calculation such as standard deviation on your own bar data. In some such cases MQL4 would provide a handy function which would do the calculation for you, e.g. iStdDevOnArray() which you could use to calculate standard deviation from your own array of aggregated bar data. In other cases, e.g. ATR, you would have to implement the whole calculation yourself as well because there is no "arrayversion" of the relevant function which you want to use, e.g. no iATROnArray() function. 

jjc: You can't do any kind of calculation involving 30second bars because MT4 doesn't have history data of sufficient detail. [...] if MT4 did have 30second bar data, then the syntax for a standard deviation calculation on "two hours' worth" would be as follows: iStdDev(Symbol(), PERIOD_S30, 240, 0, MODE_SMA, PRICE_CLOSE, 0) ... where 240 is the number of 30second bars in a twohour period. I agree that bare descriptions in the documentation such as "Moving Average period" aren't superhelpful. However, they're perhaps being precise. The documentation could say something like "Number of bars to include" instead of "Moving Average period", but that wouldn't be a strictly accurate description when using a type of moving average such as EMA or SMMA. 

jjc: ... and being very pedantic, the above doesn't necessarily mean "the last 2 hours". It would be saying "do a calculation on the last 240 bars of 30seconds", which isn't guaranteed to be the same thing. If there had been any periods of 30seconds during the last 2 hours when there had been no ticks, then there would be no S30 bars in the history for those quiet periods. Simply going back 240 bars would then extend beyond the last 2 hours.
iStdDev(Symbol(), PERIOD_S30, 240, 0, MODE_SMA, PRICE_CLOSE, 0) 
Hi all,
I've googled quite a bit on this, and am really struggling to understand the iStdDev inputs while creating an EA. Help from the brains of the forum would be most appreciated!
Here's the way I expected iStdDev to work:
For the function call:
double StdDevCurrent = iStdDev(NULL,PERIOD_H2,30,30,0,0,0);
I thought it would do the following:
NULL  On the current symbol
PERIOD_H2  Over the range of the previous two hours
30,30,0,0  Take the value at close every 30 seconds and calculate StdDev using simple arithmetic mean
0  Perform this with 0 offset from the current time
But I'm doubting myself, and would really appreciate if someone could tell me whether I've got this line correct?