Hi guys, basically i have built a simple ea that only trades at the start times i specify, sometimes it works well and other times i think theres lag because the time on the market watch is slow, its slow to kick it.
I have tried to change the time from currentbartime to TimeLocal and then add in a seconds function as i would like to have the option to input seconds. Now i have posted a copy of the original ea and then a copy of the version
i tried to edit just adding pieces of mql4 reference. I think i have completely wrecked it now. So in short i want it to use TimeLocal to help prevent lag instead of waiting for a new tick to come in.
Example start time 10:29:57 instead of currently i can only go 10:30 and then if no tick comes straight away it lags and i miss price movement. Im only fresh when it comes to programming, but any advice would be helpful guys!!
Thanks
It does not lag.
start() function is executed when new tick arrives - meaning market price changed.
That can happen several times per second, but it also can have longer gaps (seconds, even minutes when the market is slow).
If you want to execute your orders at the exact time, you have to use timer and OnTimer() function.
You might want to replace old function calls (init(), start()) with new ones (OnInit(), OnTick()). Old ones are obsoleted three years ago.
CtCapitalFx: So in short i want it to use TimeLocal to help prevent lag instead of waiting for a new tick to come in.
|
|
Thanks guys for your information
In regards to the old functions i take that into consideration and I'm now making those changes to the event handling functions as this ea was constructed using an ea builder more so then from scratch and I'm a clean skin when it comes to programming.
In regards to the normalizedouble area, it never seemed to have any issues with different pairs, it worked live on aususd, usdcad, usdjpy, and I've had several successful trades with gold.
Forgive me for my lack on knowledge but I'm confused at several parts of your response whroeder1, i understand where your coming from with the asian session and new incoming ticks hence why i thought maybe more of a strict timer function that i can include seconds would be much more appropriate instead of server time because by the time the new tick comes in (if delayed), the ea does the calculations and then places orders on the chart the price movement I'm trying to catch is already underway and then i get the error invalid stop or tp because my order could not be placed in time for the move or spike. This doesn't happen all the time only when there is a large volatile spike, but normal intraday price both orders are places, its more in times of NFP and such.
CtCapitalFx:
this ea was constructed using an ea builder more so then from scratch and I'm a clean skin when it comes to programming. In regards to the normalizedouble area, it never seemed to have any issues with different pairs, the new tick comes in (if delayed), .. its more in times of NFP and such. |
|
This is basic Indicator skeleton with OnTimer() event handler:
#property version "1.00" #property strict #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- Create 2 seconds timer EventSetTimer(2); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- Print( " ", __FUNCTION__, " TimeCurrent()= ", TimeCurrent(), " TimeLocal()= ", TimeLocal()); } //+------------------------------------------------------------------+
Run this and check Experts tab log messages.
Im experimenting with the example you gave, by trying to create a code so for example if: time = 10:29 then: EventSetTimer (57) so theres a countdown before the ea can actually place orders.
Thanks for your help
@Drazen Penic
- 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 guys, basically i have built a simple ea that only trades at the start times i specify, sometimes it works well and other times i think theres lag because the time on the market watch is slow, its slow to kick it.
I have tried to change the time from currentbartime to TimeLocal and then add in a seconds function as i would like to have the option to input seconds. Now i have posted a copy of the original ea and then a copy of the version
i tried to edit just adding pieces of mql4 reference. I think i have completely wrecked it now. So in short i want it to use TimeLocal to help prevent lag instead of waiting for a new tick to come in.
Example start time 10:29:57 instead of currently i can only go 10:30 and then if no tick comes straight away it lags and i miss price movement. Im only fresh when it comes to programming, but any advice would be helpful guys!!
Thanks