Based currency different from the currency of the traded instrument

 

Hi all,

I am not sure if I am posting this in the correct page. I faced a problem when come to code the risk management module.

My deposit currency is in SGD and the instrument that I traded is in HKD. I like to allocate 2% risk for every trade that I take using MT4. For example, Hang Seng index is HK$50 per pip and it is 1 index point per pip as well. However, if I have SG$100,000 as deposit in my account it means that I can risk SG$2000 per trade. How do I write a code to convert my SGD deposit to HKD by looking at the FX quote before the MT4 initial a trade with the intended contract quantity in Hang Seng Index? 

Thanks in advance.

 
kentaicm:

Hi all,

I am not sure if I am posting this in the correct page. I faced a problem when come to code the risk management module.

My deposit currency is in SGD and the instrument that I traded is in HKD. I like to allocate 2% risk for every trade that I take using MT4. For example, Hang Seng index is HK$50 per pip and it is 1 index point per pip as well. However, if I have SG$100,000 as deposit in my account it means that I can risk SG$2000 per trade. How do I write a code to convert my SGD deposit to HKD by looking at the FX quote before the MT4 initial a trade with the intended contract quantity in Hang Seng Index? 

Thanks in advance.

Did a quick search and found this link: https://www.mql5.com/en/forum/218444 - see if it helps you.

Another MQL4 question on how to calculate pips, pip price, etc
Another MQL4 question on how to calculate pips, pip price, etc
  • 2017.10.31
  • www.mql5.com
I've read a zillion forum threads and there seems to be long and complex discussions over how to calculate in MQL4 an answer to this question: "If...
 
kentaicm: How do I write a code to convert my SGD deposit to HKD
Unnecessary, just get the value (in SGD) of a tick. In code (MT4): Risk depends on your initial stop loss, lot size, and the value of the pair.
  1. 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.
  2. Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
  3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
              MODE_TICKVALUE is not reliable on non-fx instruments with many brokers.
  4. You must normalize lots properly and check against min and max.
  5. You must also check FreeMargin to avoid stop out
Most pairs are worth about $10 per PIP SL is $5/$10/5=0.1 Lots maximum.
Reason: