Download MetaTrader 5

Value of the spread

To add comments, please log in or register

Hello there.

Im trying to create a function that calculates the value in the deposit currency of the spread of each trade open and this function should be calculated differently in each broker, because they have different characteristics.

So I downloaded a blank mt4 terminal from and I introduced external data there. I use this terminal in offline mode and the data is at Default Folder then data comes with a spread of 1. So what it happens is that in this terminal when I run:


It retusn the value 0. Anybody knows why it is?

Also have anybody done this function before?

What I ideally im looking for is something like this:

Return_Money_value(double lots) ---> Return the value of the the spread in deposit currency for the number of lots passed.
Fernando Carreiro
Fernando Carreiro  

MarketInfo() as the name implies, returns values of the current state of the Market currently in use at the Broker.

So, obviously, if you are not connect to the broker (which I assume from your statement of "terminal in offline mode"), you will not get valid results for the function.

And if you want to get the value of the spread
double valuePerLot = (Ask - Bid) * MarketInfo(_Symbol,MODE_TICKVALUE) / MarketInfo(_Symbol,MODE_TICKSIZE);
Do NOT use TickValue by itself:
  • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
  • Account Balance * percent = RISK = |OrderOpenPrice - OrderStopLoss| * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
  • Do NOT use TickValue by itself - DeltaPerlot
  • You must normalize lots properly and check against min and max.
  • You must also check FreeMargin to avoid stop out
To add comments, please log in or register