[b136 dev 1] Strategies take up to 2x as many trades in MT5 terminal

EDIT: THE FIX IS IN THE COMMENTS

All the strategies built from this batch take up to 2x as many trades in the MT5 terminal. Probably something about the sqx engine not emulating the 1 bar expiry properly or maybe some of the other non-standard logic highlighted is not working right. The example attached takes 100 extra trades in the MT5 terminal:

//--------------------------------------------------------------------
// Trading rule: Long entry (On Bar Open)
//--------------------------------------------------------------------                   
if ((LongEntrySignal
   and Not LongExitSignal)
   and (MarketPosition("Current", MagicNumber, "") is Not Long))
{
    // Action #1
    Open Long order at (HeikenAshiOpen(Main chart)[1] + (BB Range(Main chart,BBRangePeriod1, 2.12, PRICE_CLOSE)[2] * PriceEntryMult1)) Limit;
        Order valid for 1 bars;
        Duplicate trades: allowed;
        Replacing pending orders: allowed; 
         
        Stop Loss = StopLossCoef1 * ATR(24);

        Exit After ExitAfterBars1 bars;
}


//--------------------------------------------------------------------
// Trading rule: Short entry (On Bar Open)
//--------------------------------------------------------------------                   
if ((ShortEntrySignal
   and Not ShortExitSignal)
   and (MarketPosition("Current", MagicNumber, "") is Not Short))
{
    // Action #1
    Open Short order at (HeikenAshiOpen(Main chart)[1] - (BB Range(Main chart,BBRangePeriod1, 2.12, PRICE_CLOSE)[2] * PriceEntryMult1)) Limit;
        Order valid for 1 bars;
        Duplicate trades: allowed;
        Replacing pending orders: allowed; 
         
        Stop Loss = StopLossCoef1 * ATR(24);

        Exit After ExitAfterBars1 bars;
}


Actually, the MT5 terminal is even running a little shorter amount of data. (same start date. every tick, real tick dukas xauusd)
Attachments
ReportTester-3000031465.html
(2.16 MiB)
Screenshot_29.png
(17.55 KiB)
Screenshot_30.png
(1.55 KiB)
bugged_Strategy 492348.sqx
(736.21 KiB)
  • Votes +4
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

b
#1

bentra

05.05.2022 04:18

Task created

Cc
#2

Cyber

05.05.2022 06:21
Voted for this task.
b
#3

bentra

05.05.2022 08:10

Attachment bugged_Strategy 482341.sqx added

bugged_Strategy 482341.sqx
(1.48 MiB)
This one takes an extra 1k trades in mt5 terminal
E
#4

Emmanuel

05.05.2022 17:59
Voted for this task.
b
#5

bentra

06.05.2022 02:58
Hello, I found another fix for your bug for you because I'm a ninja bug fixer:



//+------------------------------------------------------------------+ bool sqMarketPositionIsShort(int magicNo, string symbol, string comment){    return sqSelectPosition(magicNo, symbol, -1, comment, false); }     //+------------------------------------------------------------------+ bool sqMarketPositionIsNotShort(int magicNo, string symbol, string comment){    if(sqSelectOrder(magicNo, symbol, -1, comment, false)) {       return false; } else return true; }  //+------------------------------------------------------------------+ bool sqMarketPositionIsLong(int magicNo, string symbol, string comment){    return sqSelectPosition(magicNo, symbol, 1, comment, false); }      //+------------------------------------------------------------------+ bool sqMarketPositionIsNotLong(int magicNo, string symbol, string comment){    if(sqSelectOrder(magicNo, symbol, 1, comment, false)) {       return false; } else return true; }  //+------------------------------------------------------------------+ bool sqMarketPositionIsFlat(int magicNo, string symbol, string comment){    return sqGetMarketPosition(symbol, magicNo, comment) == 0; } //+------------------------------------------------------------------+


The not position logic is wrong! sqMarketPositionIsNotxxx is calling sqSelectOrder instead of sqSelectPosition! You're welcome.
b
#6

bentra

01.06.2022 15:21
To be clear fixing the mql code bug I found resolved the entire issue of this ticket.
o
#7

Enric

28.07.2022 19:52
Voted for this task.
g
#8

Lee Guan Chuan

08.09.2022 06:37

Status changed from New to Fixed


Votes: +4

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please