- elieserra: but I cannot make it works.
“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
How To Ask Questions The Smart Way. (2004)
When asking about code
Be precise and informative about your problem -
Stop trying to change the chart in the tester. Just read the prices of the period you want.
-
“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
How To Ask Questions The Smart Way. (2004)
When asking about code
Be precise and informative about your problem -
Stop trying to change the chart in the tester. Just read the prices of the period you want.
Sorry but when I say "it does not work" I mean it does not change timeframe on the tester.
Actually what I'm trying to do is to use the time frame as a parameter so that I can optimize it with the others EA parameters.
I suggest then that you read the thread from beginning to end again.
And in the case that your issue is different to the OP's, then describe it in detail.
You don't; it runs on the tester's timeframe. You have it trade all timeframes. Timeseries and Indicators Access
You don't; it runs on the tester's timeframe. You have it trade all timeframes. Timeseries and Indicators Access
Thank You for the response.
I still did not get you.
If you could explain with an example or a testable solution, it would be helpful.
Thanks.
input int Magic=20221109; #define MAGIC_END (Magic+ST_COUNT) void OnTick(){ for(int iPos=PositionsTotal()-1; iPos>=0; --iPos) if( PositionGetSymbol(iPos) == _Symbol ){ int mn = PositionGetInteger(POSITION_MAGIC); if(Magic <= mn && mn < MAGIC_END){ Standard_TF tf = mn - Magic; trail_position(period[tf]); return; } } // No open positions. for(Standard_TF tf=ST_FIRST; tf <= ST_COUNT; ++tf){ int mn = Magic + tf; if(open(period[tf], mn) ) break; } } bool open(ENUM_TIMEFRAMES period, int mn){ while(!download_history(period)) Sleep(5); if(is_new_bar(period)){ double c1=iClose(_Symbol, period, 1); double c2=iClose(_Symbol, period, 2); if(c1 > c2) return Buy(mn); } return false; }Not compiled, not tested, just typed.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone!
I've been working on a price action EA and I would like to optimize on strategy tester different timeframes (i.e. from PERIOD_M1 to PERIOD_D1) but I cannot make it works.
I created a input variable for timeframe in the Input Variables
and tested it on every test event (OnTester, OnTesterInit, OnTesterPass and OnTesterDeinit) with the code beneath
...none of them work!
If I use the code above on the OnInit() event it works, but with this I just can force the EA to use the timeframe inputed, it is not actually what I need.
Has anybody any idea to help?