0

On each new bar/tick, my variable is re-initialed, I am trying to execute a trade once per signal, the problem is that once TP is achieved, if same trends continues, it triggers another trade. I am thinking to store variable in Text file. So just wondering what would the best way to handle such variable. Sorry I don't have code.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
user1582596
  • 503
  • 2
  • 5
  • 16

1 Answers1

1

MT4 Global Variable objects

While MT4 supports somehow ghost-alike semi-persistent objects called "Global Variables", that can survive between MT4 Terminal re-runs for about several weeks, these ghosts are rather complicated to be used for your sketched purposes.

GlobalVariableCheck()
GlobalVariableSet()
GlobalVariableSetOnCondition()
GlobalVariableGet()

FileSystem Text-File

While doable, this ought be a last resort only option, as this is the slowest and the least manageable part, once running several units, several tens, several hundreds of MT4 Terminal instances in the same environment, the risk of fileIO collisions is clearly visible.


Solution?

Try to create & maintain a singleton-pattern to avoid multiple re-entries into a trend you have already put one trade into.

Try to setup also a clear definition for trend reversals, which stop / reset the singleton-pattern once a new trend was formed.

user3666197
  • 1
  • 6
  • 50
  • 92