Download MetaTrader 5

Difference in mt5 values compared to mt4

To add comments, please log in or register
bhongya
11
bhongya  

I have a mql4 and a mql5 indicator which does nothing but displays spread , swapshort and swaplong value on screen. I noticed that 

mql5 displays different values than mql4. I am confused. Which one is right? I am using alpari uk demo account for both mt4 and mt5.

Here's  my mt5 indicator:

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

   double Ask,Bid;

   int Spread;

   double swapshort, swaplong;

   Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);

   Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);

   Spread=SymbolInfoInteger(Symbol(),SYMBOL_SPREAD);

   swapshort=SymbolInfoDouble(Symbol(),SYMBOL_SWAP_SHORT);

   swaplong=SymbolInfoDouble(Symbol(),SYMBOL_SWAP_LONG);

   Comment(StringFormat("Show prices\nAsk = %G\nBid = %G\nSpread = %d\nSwap Long = %G\nSwap short = %G",Ask,Bid,Spread,swaplong,swapshort));

   return(rates_total);

  }

 

 

and here is the mt4 script

int start()

  {

   double Ask1,Bid1;

   int spread;

   double swapshort, swaplong;

   Ask1=MarketInfo(Symbol(), MODE_ASK); 

   Bid1=MarketInfo(Symbol(), MODE_BID);    

   swapshort=MarketInfo(Symbol(), MODE_SWAPSHORT); 

   swaplong=MarketInfo(Symbol(), MODE_SWAPLONG); 

   spread = MarketInfo(Symbol(), MODE_SPREAD); 

    Comment ("Show prices\nAsk = ",Ask1, "\nBid = ",Bid1, "\nSpread = ",spread,"\nSwap Long = ", swaplong, "\nSwap short = ",swapshort);

   return(0);

  }

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
onewithzachy
2271
onewithzachy  

Hi bhongya,

1. bhongya, would you please use SRC button to post your code

 

2. Alpari UK has different server for MT4 and MT5, they may come from different banks which may also give different pricing (Ask, Bid, Spread, etc) for traded symbol.

3. WTF = Welcome To Forex, bhongya :D 

To add comments, please log in or register