forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

Create and Test Forex Strategies

You are not logged in. Please login or register.


Forex Software → Expert Advisor Studio → Bug: Swap Type Misinterpretation in Metatrader 5 Data Export Script

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 2

Topic: Bug: Swap Type Misinterpretation in Metatrader 5 Data Export Script

Hey Mr. Popov,

I've stumbled upon a little hiccup in the Data Export script for Metatrader 5 (Data Export.mq5).

Here's the scoop: it seems like there's a bug where the script misinterprets the swap type. For those familiar, the enumeration of swap types in Metatrader 4 is quite different from that in Metatrader 5.

In Metatrader 4, the values are as follows:
- 0 - in points
- 1 - in the symbol's base currency
- 2 - by interest
- 3 - in the margin currency

You can check it out here: https://book.mql4.com/appendix/marketinfo

Expert Advisor Studio aligns with this interpretation in its Symbol settings too.

Now, in Metatrader 5, the swap types are enumerated differently:
- 0 - Swaps disabled (no swaps)
- 1 - Swaps are charged in points
- 2 - Swaps are charged in money in the base currency of the symbol
- 3 - Swaps are charged in money in the margin currency of the symbol
- 4 - Swaps are charged in money, in client deposit currency
....
And so on... For the full list, visit: https://www.mql5.com/en/docs/constants/ … _swap_mode

This disparity leads to incorrect swap modes being exported in the Metatrader 5 Data Export script. Given these differences in enumeration, the Data Export script for MQ5 should ideally incorporate mappings to align swap types correctly with those in Metatrader 4 and Expert Advisor Studio.

Thanks for looking into this, and as always, happy trading, everyone!

Cheers!

Re: Bug: Swap Type Misinterpretation in Metatrader 5 Data Export Script

A function like this could be used to fix the issue:

int MapSwapModeToMT4(int mt5SwapMode) 
{
   switch (mt5SwapMode) 
   {
      case SYMBOL_SWAP_MODE_POINTS:
         return 0; // Same as MT4 'in points'
      case SYMBOL_SWAP_MODE_CURRENCY_SYMBOL:
         return 1; // Same as MT4 'in the symbol base currency'
      case SYMBOL_SWAP_MODE_INTEREST_CURRENT:
         return 2; // Matches 'by interest' conceptually
      case SYMBOL_SWAP_MODE_CURRENCY_MARGIN:
         return 3; // Same as MT4 'in the margin currency'
      // Any other cases unique to MT5
      default:
         return 0; // Default to 0 if no MT4 equivalent
   }
}

Posts: 2

Pages 1

You must login or register to post a reply

Forex Software → Expert Advisor Studio → Bug: Swap Type Misinterpretation in Metatrader 5 Data Export Script

Similar topics in this forum