How many bars since the last trade was opened
-
I have created an working ea and a part of it is that it counts how many bars have passed since a trade has entered, but when I turn it off and turn it back on it looses the stored value and starts at 1 again. How can I write something in the "on Init" so it checks upon starting the ea. Basically if there are any open trades it counts how many bars it has been since it was opened
-
Can you work with the age of the trade, which is time between now and the time it was created? In this case you are using values that stay in MetaTrader even if the whole PC restarts.
There can be other tricks, like using Terminal Variables (they are stored in some file) or even objects on the chart. But if you can just work with the age, that will be best.
-
@fxDreema Thank you for your quick reply. I actually tried to use the check age and it does work to a degree, but once it comes across a weekend where we skip two days, it miscalculates. I know how to create an object once a trade has been entered, but can you please show me how I would reference to it? I basically need it to check "if it has been over 10 bars since the latest trade has been entered"
-
Here is about the objects, I tried to explain them via those 2 examples https://fxdreema.com/examples#Chart-Objects