I would like to be able to take the function below which saves a screenshot to a file and attach a listening function that saves a screenshot every 5 minutes or so. What would be the best way to go about this in mql?
<SNIP>
Please edit your post . . . .
Please use this to post code . . . it makes it easier to read.
I would like to be able to take the function below which saves a screenshot to a file and attach a listening function that saves a screenshot every 5 minutes or so. What would be the best way to go about this in mql?
Thanks Raptor,
The issue here is that I need to run this as a script, which is not run tick-wise like an EA. So it seems that for scripts the script() function terminates is only loaded again on the next request not on the next tick.
Raptor, that is exactly that I came up with. Turns out my problems extend beyond this issue, but thank you.
You would not happen to know the state of the art concerning HTTP Posts from Mt4? ;-)
Most solutions out there seem to be broken in one way or another. Has MetaTrader come out with an official approach?
int NextSave; int init() { NextSave=0; } int start() { ...// other code while(TimeCurrent()>NextSave) { ... // code to take screenshot goes where dots are NextSave=TimeCurrent()+300; } //-------------------------------------- return(); }
I would like to be able to take the function below which saves a screenshot to a file and attach a listening function that saves a screenshot every 5 minutes or so. What would be the best way to go about this in mql?
Hi feeblefx
You can use MathMod to do this. Try the following;
//Vars extern string Info = "RunFunctionveryXMins 1 - 60"; extern int RunFunctionveryXMins = 5; bool functionCalled = false; //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- //Reset functionCalled boolean if(MathMod(Minute(),RunFunctionveryXMins)) { functionCalled = false; } // if(functionCalled == false) { if(MathMod(Minute(),RunFunctionveryXMins)) { Print("Don't Run Function"); } else { Print("Call Function"); //Call Your Function Here //Stop Function being called again functionCalled = true; } } } //+------------------------------------------------------------------+
- Shouldn't use MathMod which functions on doubles. Minute is an int; a simple modulo (%) would so.
- It also doesn't handle missing bars (think over the weekend.)
- No need for the boolean if you just convert new bar code to new five (5) minute one:
//Vars extern int RunFunctionveryXMins = 5; //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { datetime now = TimeCurrent(), xMin = now - now % (60*RunFunctionveryXMins); static datetime currXmin=0; datetime prevXmin = currXmin; currXmin=xMin; if(prevXmin != currXmin){ Print("Call Function"); //Call Your Function Here } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I would like to be able to take the function below which saves a screenshot to a file and attach a listening function that saves a screenshot every 5 minutes or so. What would be the best way to go about this in mql?