closed due stop-loss at price

 

Need your advise

If you look at the set files the stop losses should not be generated at this level. How is it possible

2022.09.01 17:27:31.375 '7603884': order #301195982 sell 0.02 EURCAD at 1.30828 closed due stop-loss at price 1.30815

2022.09.01 15:49:10.094 '7603884': order #301194918 sell 0.02 EURUSD at 0.99381 closed due stop-loss at price 0.99370

2022.08.31 23:31:24.525 '7603884': order #301144439 sell 0.01 EURUSD at 1.00495 closed due stop-loss at price 1.00421

2022.08.31 14:52:07.470 '7603884': order #301106586 buy 0.01 USDJPY at 138.472 closed due stop-loss at price 138.537


While running strategy tester everything works fine 

2022.09.01 16:39:32.152 2022.08.30 09:32:00  SQ-SAR-MA-M1-M30-M5 EURUSD,M1: close #91 buy 0.30 EURUSD at 0.99986 sl: 0.99527 tp: 1.00986 at price 0.99991



Files:
 
siakzar1: If you look at the set files the stop losses should not be generated at this level. How is it possible

A set file only set the extern/input parameters of the EA. The EA can do anything or nothing with them.

If you want help with your code, you must provide them.

 
William Roeder #:

A set file only set the extern/input parameters of the EA. The EA can do anything or nothing with them.

If you want help with your code, you must provide them.



EA file was provided.
 
  1. //| Generated by StrategyQuant X Build 135 at 08/21/2022 20:53

    EA builder, EA Builder Pro, EATree, Etasoft forex generator, Forex Strategy Builder, ForexEAdvisor STRATEGY BUILDER, ForexRobotAcademy.com, FX EA Builder, fxDreema, Forex Generator, FxPro, Molanis, Octa-FX Meta Editor, Online Forex Expert Advisor Generator, Strategy Builder FX, Strategy Quant, Visual Trader Studio, MQL5 Wizard, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

    1. Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
      If we tell you what you need, you can't code it.
      If we give you the code, you don't know how to integrate it into yours.
      We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds thousands of lines of code. You are essentially going to be on your own.

    2. EA builder makes bad code counting up while closing multiple orders.
      EA builder makes bad code Bars is unreliable (Max bars in chart), volume is unreliable (miss ticks.) Always use time.
      EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
      EA builder makes bad code, not adjusting for ECN brokers. pre-Build 500)
      EA builder makes bad code, not checking return codes.

    3. EATree uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)

    4. FX EA Builder makes bad code, not checking return codes.
      FX EA Builder makes bad code, loosing open tickets on terminal restart. No recovery (crash/power failure.)
      FX EA Builder makes bad code, not adjusting stops for the spread.
      FX EA Builder makes bad code, using OrdersTotal directly.

    5. FOREXEADVISOR STRATEGY BUILDER makes bad code, non-updateing global variables.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, compilation errors.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, not checking return codes.

    Learn to code it, or pay someone (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum #1 (2019)

  2. _ticket = sqOpenOrder(OP_BUYLIMIT, "Current", mmLots, sqGetBid("Current"), MagicNumber, "", 0, true, false, CLR_NONE);

    There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

      Don't worry about it unless you're scalping M1 or trading news.

    2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

  3.       if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {
             slptValue = price + (SLorPT * value);
          } else {
             slptValue = price - (SLorPT * value);
          }

    You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

      Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
      My GBPJPY shows average spread = 26 points, average maximum spread = 134.
      My EURCHF shows average spread = 18 points, average maximum spread = 106.
      (your broker will be similar).
                Is it reasonable to have such a huge spreads (20 pip spreads) in EURCHF? - General - MQL5 programming forum (2022)

 
siakzar1 #:
EA file was provided.
William Roeder #:

A set file only set the extern/input parameters of the EA. The EA can do anything or nothing with them.

If you want help with your code, you must provide them.

Dear William,

Thanks for all the suggestion. I have taken your recommendation and changed my attitude toward code that are generated.

I am going to apply your solution and greatly appreciate the time you spent to provide such an Indepth solution and reasoning.


Regards

Siakzar

Reason: