I need your help. I am new to developing EAs and I have troubles debugging my code.
If I use the debugging tool, after defining my breakpoints and start the tool, the application doesn't do anything: it runs (I can pause it or stop it), but it doesn't go to the any breakpoint or finish by itself (the step into, over and out are disabled).
And if I try to debug it using Print and Alert messages running the code through the Strategy Tester, the messages displayed in the journal are inconsistent: not all messages are displayed (even if I put one after another, the second can print but not the first one), and there are runs where the messages displayed differ from the previous run, even without changing the code, symbol or period (the only change is an extra compilation).
Additionally, during the run, the system opened a position without displaying the message I put before the code requests it (same issue specified above), and what is even worse is that the opened position didn't have the stop loss value I specified (it is 0 and therefore it stays open for longer), so it would seem it is opening by itself without running my code.
What can I do? I am getting frustrated.
Thanks in advance,
I have the same issue regarding debugging and print in testing, so can't help there :(.
Regarding SL and TP, MT5 does not accept (and therefore will not execute) SL and TP. So, instead SL and TP, use opposite pending orders as TP and SL, for example, if we open buy 1 lot, then also open 1 lot sell limit as TP and 1 lot sell stop as SL.
Yes I just tried that with MetaQuotes server. MQ must be enable SL and TP in this new build (my MT is actually downloading new MT5 build 773). My Alpari UK does not have SL/TP fields in order window when pressing F9.
My Alpari UK does not have SL/TP fields in order window when pressing F9.
1) Breakpoints work, however they are triggered on live price action, so you have to wait for events
2) you have to check the printouts in logs, journals keeps only shorter list of logs
3) different brokers work in different ways. some don't allow setting SL/TP on opening deal, so you have to set them later. You can check MqlTradeRequest and ENUM_SYMBOL_TRADE_EXECUTION to recognize the use case from program. MigBank e.g. was most problematical to me as it had a different setup needed for opening orders, as it was returning a strange fault. Try using the CTrade class, maybe it will suite you.
4) i didn't have any issues with SL/TP not working and i don't believe this to be true. the moment SL/TP is set, it gets executed.
Previous poster was correct, some brokers allow SL & TP to be set at time of trade others do not.
Best thing is to always set them after the trade has been opened this way there is less likelihood of any problems and it will work with all brokers.
Remember that brokers each have different minimum distances for these things so make sure you check the symbol info for the correct levels.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.