Help with the EA Strategy tester

 

As soon a trade opens in the strategy tester, the test stop .   There no error window or note in the journal when it stops.


Here is the part of my code that create this problem. The rest has nothing to do with this.


Also, i have this message in my scrypt:     return value of "OrderSend' Should be checked


OutPut S or B is a number between 1 and 0,    if B is 0.85, than S is 0.15


The problem occur when a void fct is called


Thanks a lot for any help!!!!!!!!

Files:
Capture.JPG  30 kb
Capture1.JPG  58 kb
Capture3.JPG  142 kb
Capture4.JPG  38 kb
 

Don't post images of code copy and paste using the code button (Alt + S).

Please edit your post.

EDIT your original post, please do not just post the code properly in a new post.

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

 
Olivier Barmettler: As soon a trade opens in the strategy tester, the test stop .   There no error window or note in the journal when it stops.
  1. Don't post pictures of code, they are too hard to read.

    Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. In picture 3 your variable starts at zero. If the type is not a buy, you skip the close and then you decrement it (-1). Then the for loop increments it (0). Infinite loop.

    In the presence of multiple orders (one EA multiple charts, multiple EAs, manual trading), while you are waiting for the current operation (closing, deleting, modifying) to complete, any number of other operations on other orders could have concurrently happened and changed the position indexing:

    1. For non-FIFO (non-US brokers), (or the EA only opens one order per symbol), you can simply count down, in a position loop, and you won't miss orders. Get in the habit of always counting down.
                Loops and Closing or Deleting Orders - MQL4 programming forum
    2. For In First Out (FIFO rules — US brokers), and you (potentially) process multiple orders per symbol, you must find the earliest order (count up), close it, and on a successful operation, reprocess all positions.
                CloseOrders by FIFO Rules - Strategy Tester - MQL4 programming forum - Page 2 #16
                MetaTrader 5 platform beta build 2155: MQL5 scope, global Strategy Tester and built-in Virtual Hosting updates - Best Expert Advisors - General - MQL5 programming forum #1.11 ACCOUNT_FIFO_CLOSE

    3. and check OrderSelect in case later positions were deleted.
                What are Function return values ? How do I use them ? - MQL4 programming forum
                Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    4. and if you (potentially) process multiple orders, must call RefreshRates() after server calls if you want to use, on the next order / server call, the Predefined Variables (Bid/Ask.) Or instead, be direction independent and just use OrderClosePrice().

Reason: