Download MetaTrader 5
To add comments, please log in or register
Share your program via Code Base. Gain access to millions of traders!
ben
39
ben 2015.03.05 22:21 

Hi all, 

I'm trying to calculate how much I would lose in my deposit currency (GBP) if my stop gets hit. MT4 (using FXCM) does this automatically when you drag a stoploss, I want to replicate this in code.

I try to use MarketInfo(Symbol(),MODE_TICKVALUE) , which is the  'Tick value in the deposit currency'.  The problem I'm having is that it seems to return an incorrect value for XXXJPY pairs.

For example at this current moment MODE_TICKVALUE for EURUSD is returning 0.65631. This can be calculated by 1 / GBPUSD rate of 1.52383 = 0.65624. Close enough.

However, for the USDJPY the MODE_TICKVALUE is 0.54594. But when you work it out yourself by getting the value of 1 JPY expressed in GBP. ie  1 / GBPJPY rate of 183.160 = 0.0054597.

As you can see MODE_TICKVALUE is giving a value 100 times larger than I would expect. WHY?

Do I just need to make a special check for yen pairs and multiply MODE_TICKVALUE by 100. Seems like a bit of work around.


I would love to hear from anyone who has faced this particular issue before and how you deal with it.

Miguel
29
Miguel 2015.03.06 01:35  
double valuePerPip = MarketInfo(Symbol(), MODE_TICKVALUE);
if (Digits%2 != 0) valuePerPip *= 10;
double money = orderLots*stopLoss*valuePerPip;

 where stopLoss is in pips (not pipettes: http://www.babypips.com/school/preschool/how-to-trade-forex/pips-and-pipettes.html)

 Regards.

Jaume Torne
89
Jaume Torne 2015.03.06 05:54  

Some brokers supply wrong TICKVALUE.

If you tell them, they use to answer unbelievable things.

Anyway if this is your case, move to another broker.

After:

Lots=AccountEquity()*MaxRisk/Stop*TickSize/TickValue;

I have set a safety filter in my systems: in case TICKVALUE is 100 times lower, for instance, the lot size will be 100 times bigger and it will use too much margin, then the system will display "Running out of Margin".

Keith Watford
Moderator
7887
Keith Watford 2015.03.06 06:12  
Forex_cellence:


However, for the USDJPY the MODE_TICKVALUE is 0.54594. But when you work it out yourself by getting the value of 1 JPY expressed in GBP. ie  1 / GBPJPY rate of 183.160 = 0.0054597. 

 1 Lot is usually 100,000 units

Profit/loss for 1 tick will be 100,000*TickSize.

In the case of EURUSD, that will be 100,000* 0.00001=1 USD 

In the case of USDJPY, that will be 100,000* 0.001=100 yen

So divide 100 by the GBPJPY rate, not 1. 

whroeder1
13596
whroeder1 2015.03.06 13:35  
jtcash: Some brokers supply wrong TICKVALUE.
Do not use tick value by itself, only as a ratio.
Baby Blue
20
Baby Blue 2015.03.06 15:48  
You better calculate it by yourself, because the pip value is often variable and you'll set wrong the stop/limit orders. Watch this: https://www.youtube.com/watch?v=KrjHYNG2SR4
ben
39
ben 2015.03.07 18:50  

A big thank you for all the answers. GumRai, I think your explanation hits the nail on the head and helps me to understand something that I've been confused by forever.

Basically, the smallest increment of price change for a 1 lot position is 1 unit of the quote currency for USD type pairs, and 100 units of the quote currency for JPY pairs. Bingo!

/
To add comments, please log in or register