Expert Advisors on different timeframes

 
I whould like to know exactly how does an Expert Advisor work. My Question: Does an Expert Advisor that is loaded on a H1 chart read the data from the M1 chart to triger the signals or not? The reason why I'm asking is because I wrote an Expert Advisor with three moving averages on a H1 chart and it seems that the EA reads its data from the M1 chart and not from the H1 chart to triger the trade signals.

Should I use: double FMA = iMA(NULL,PERIOD_H1,FMA_Period,0,MODE_EMA,PRICE_CLOSE,0);
or double FMA = iMA(NULL,0,FMA_Period,0,MODE_EMA,PRICE_CLOSE,0);
 
What you really want do is FMA = iMA(NULL,0,FMA_Period,0,MODE_EMA,PRICE_CLOSE, 1);
Otherwise, you are using in fact ticks data on the current bar. You can have a lot of false signals before the bar compleate.
 
If You need data from another time-frame You need to open appropriate chart before. Otherwise after the first call iMA(NULL,<another_period>...) You will get error 4066. And your attempt after this error should be repeated in 10-20 seconds
 
Michal:
What you really want do is FMA = iMA(NULL,0,FMA_Period,0,MODE_EMA,PRICE_CLOSE, 1);
Otherwise, you are using in fact ticks data on the current bar. You can have a lot of false signals before the bar compleate.
I understand what you say. If I use previuos bar the entry will be to late. I agree that using the "0" is actually wasting time.
 
I have different question looselly coupled to timeframes and EA. I am trying to program Expert Advisor for 4h graph which is making computation with EMA on weekly graph.
I have tried iMA(NULL, PERIOD_W1, 5, 0, MODE_EMA, PRICE_MEDIAN,xxx) but the graph is something completelly different than original graph on weekly chart (I draw 1w chart with period 5, timeframe 0 and compared it visually and by values at the end of the weeks...) .

Does anybody have information how to tackle this mistery (at least to me) - setting proper timeframe, period or other things for iMA and possibly for other indicators??

>>>>>>>>>>>>
Mystery solved - the last parameter "xxx" - shift with indicator is counted on the timeframe set in function. In another words while using it with indicator you have to recount shift according to used period.
Something like: i / (PERIOD_W1 / Period()
 
stringo:
If You need data from another time-frame You need to open appropriate chart before. Otherwise after the first call iMA(NULL,<another_period>...) You will get error 4066. And your attempt after this error should be repeated in 10-20 seconds
Strange, I never noticed this error before, and I use a lot of EAs on different timeframes. Like TSD, it uses a lot of pairs and timeframes, but it is attached only to one frame. What should I grep in logs to see it. When I grep for 4066 I don't see nothing. Please explain.
 
Roets:
Michal:
What you really want do is FMA = iMA(NULL,0,FMA_Period,0,MODE_EMA,PRICE_CLOSE, 1);
Otherwise, you are using in fact ticks data on the current bar. You can have a lot of false signals before the bar compleate.
I understand what you say. If I use previuos bar the entry will be to late. I agree that using the "0" is actually wasting time.
"0" with PRICE_CLOSE is not a good idea, but with e.g. PRICE_HIGH, or any other that does not change with every tick it can give good results.
 
one related question is:
does open,close,high,low of a bar come from Bid or Ask or the middle price of the quotes? or Close[0] refers to the current Ask,or Bid or Middle of them?
 
Close[0] is current Bid
 
stringo:
If You need data from another time-frame You need to open appropriate chart before. Otherwise after the first call iMA(NULL,<another_period>...) You will get error 4066. And your attempt after this error should be repeated in 10-20 seconds
Hi Stringo,

I have programmed a lot before using things like VB. Currently I am trading but would love to backtest properly. I have gone through a host of documentation on MQL4 but just am missing something. I would really appreciate liaising with someone who knows what they're doing for a little while so that I can get started. Would you be prepared to help me ? if so...I can post a contact email address ?

thanks

John