How to give if signal stays more than few seconds
-
https://fxdreema.com/shared/U5IC7A0C
The indicator iam using gives buy/sell arrows which are repainted many times before confirming.
Here i want to give a condition before buy & sell - if indicator is visible continuoesly more than 3 seconds perform buy or sell
Here i used delay (3) which doesnot work. once indicator visible(2) passes it goes to delay(3) wait for 3sec goes to indicator visible(4) and take trade then if indicator starts repaiting canot control the trades.
So i need to give a simple condition since my indicator blinks buy,sell,buy,sell...at the time of changeover, **IF INDICATOR VISIBLE MORE THAN 3SECONDS I WANT TO PERFORM ACTION **
Plz help me out iam aunable to find solutuin for this -
@jithin You can use the 'on timer' tab this way:
https://fxdreema.com/shared/VczmUsYFb
However, depending on the action required you will need a second variable to move the action bact to the 'on tick' tab.
-
If you stop the timer, I think it stops forever... I mean until you start it from somewhere else. But yes, the Timer is the most accurate in this case, if we really care about the time. Because we can look at the ticks, but they can come very fast or too slow.
But there is another way to measure the time. If you have datetime variable and you save some time in it, which actually looks like this: https://www.epochconverter.com/, then in the future you can calculate what is the difference between the current time and that old saved time. The difference will be in seconds. I think it was seconds in MQL, because sometimes it could be in milliseconds (x1000).
In MQL you can use the TimeCurrent() or TimeLocal() function if it's easier for calculations.