DomGilberto:
So I have touched on this before briefly in a fairly old thread but I am not wanting to come up with an efficient solution to this issue. [...]
The FXCM gold contract changes in value by $1 for each $1 move in the price, or by 1 US cent for each cent move in the price. (Other brokers have contracts which are e.g. 100 times larger but where you can trade fractions of a lot such as 0.01; a 1.00 lot trade on FXCM gold is equivalent to a 0.01 lot trade on these other brokers.)
Therefore, the tick-value and tick-size look correct... except that they are not being converted to the deposit currency.
The true gold tick-value on a GBP account should therefore be MarketInfo("XAUUSD", MODE_TICKVALUE) / MarketInfo("GBPUSD", MODE_BID)
Forex symbols (unsurprisingly) work correctly and don't need adjustment.
Other CFDs such as UK100 are similarly reported in the instrument's base currency, not the deposit currency. UK100 should be calculated correctly on your GBP account without needing to manipulate the tick-value, but would require modification on a USD account.
The true gold tick-value on a GBP account should therefore be MarketInfo("XAUUSD", MODE_TICKVALUE) / MarketInfo("GBPUSD", MODE_BID)
If you want something which doesn't involve hard-coding of the rules for particular symbols, and which probably works on all brokers, then you can do the following:
Check MarketInfo(..., MODE_PROFITCALCMODE). It it is 0 or 1, then use the MODE_TICKVALUE reported by the platform. [This assumes that the tick-value is correctly converted to the deposit currency if the profit-calc mode is forex or CFDs, and that there is only a problem if the mode = 2 = "futures").
If MODE_PROFITCALCMODE = 2 then get the symbol's base currency using SymbolInfoString(Symbol(), SYMBOL_CURRENCY_BASE)
If the symbol's base currency is the same as the deposit currency, then use the MODE_TICKVALUE reported by the platform.
Otherwise, convert the tick-value from the symbol's base currency to the deposit currency. But this isn't always straightforward. Firstly, you have to find the appropriate symbol while adjusting for any suffixes used by the broker in their symbol names. Secondly, if you are trading something like the Hang Seng (HKG33) on a GBP account, then there is no GBP/HKD pair in order to do a single translation of the tick-value. You would have to do something such as triangulating via USD or JPY.
Thank you kindly for your response. This is what I am now using (see below). I realised just a second ago about how I was creating the custom tick that the "pip" size was too large, therefore my lot sizing was huge!
//Risk applied per trade -------------- risk_amount = AccountBalance( )*RiskPercent/100; double GBPUSD_BID = MarketInfo( "GBPUSD", MODE_BID); // Find GBPUSD current bid price double CustomTickValue = ( MarketInfo("XAUUSD", MODE_TICKSIZE) / GBPUSD_BID * minlot ) Print(" CustomTickValue is custom: ( ", 0.01, " / ", GBPUSD_BID, " * ", minlot, " ) = ", CustomTickValue); //What is loss for 1 lot if tick DOES NOT return a true value - use custom below! double loss_for_1_lot = ( pips_to_bsl * 10 ) * ( CustomTickValue / minlot );//needed to multiply pips_to_bsl by 10 else it is wrong calculations Print("loss_for_1_lot == ( ", pips_to_bsl," * ", 10, " ( ", CustomTickValue, " / ", minlot," ) = ", loss_for_1_lot); //Get Lot Size calculations for all FOUR Trades double LotSize_Buy = MathFloor( risk_amount / loss_for_1_lot/ Lot_Step) * Lot_Step, Print("LotSize_Buy == ", risk_amount," / ", loss_for_1_lot, " / ", Lot_Step, " ) * ", Lot_Step, " = ", LotSize_Buy); ...
Only thing different from what your saying is TICKVALUE should be surely TICKSIZE though, right...? (if for some bizarre reason the broker updates their information correctly, using TICKVALUE could mess this up in the future)
Only thing different from what your saying is TICKVALUE should be surely TICKSIZE though, right...?
No, the MODE_TICKSIZE is correct; the minimum movement of XAUUSD on an FXCM account is always 0.01, e.g. from 1170.08 to 1170.09
It's the value of that movement, MODE_TICKVALUE, which is not correct. It is reported as 0.01 regardless of the deposit currency. On a GBP account, the tick-size remains 0.01 but the value of that movement is about 0.00625, not 0.01 - i.e. $0.01 converted to GBP at a rate of approximately 1.6.
Okl thanks
Should I be doing this part - multiplying by 10 is wrong, but then multiplying by 0.01 is wrong too? (confusing myself now :P)
//What is loss for 1 lot if tick DOES NOT return a true value - use custom below! double loss_for_1_lot = ( pips_to_bsl * 10 ) * ( CustomTickValue / minlot );//needed to multiply pips_to_bsl by 10 else it is wrong calculations Print("loss_for_1_lot == ( ", pips_to_bsl," * ", 10, " ( ", CustomTickValue, " / ", minlot," ) = ", loss_for_1_lot);
//What is loss for 1 lot if tick DOES NOT return a true value - use custom below! double loss_for_1_lot = ( pips_to_bsl / MarketInfo("XAUUSD", MODE_TICKSIZE) ) * ( CustomTickValue / minlot );
2014.11.03 08:28:40.626 TF - v2.4.1 - XAUUSD XAUUSD,H1: LotSize_Sell == 16.4532 / 20.30475881070342 / 1.0 ) * 1.0 = 0.0 2014.11.03 08:28:40.626 TF - v2.4.1 - XAUUSD XAUUSD,H1: loss_for_1_lot1 == ( 32.5 / 0.01 ( 0.06247618095601052 / 1.0 ) = 20.30475881070342 2014.11.03 08:28:40.611 TF - v2.4.1 - XAUUSD XAUUSD,H1: sell_tp_price1 == 1157.9 - 32.5 = 1125.4 2014.11.03 08:28:40.611 TF - v2.4.1 - XAUUSD XAUUSD,H1: pips_to_ssl == 1190.4 - 1157.9 = 32.5
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
But as you can see from the Prints, there is nothing hidden past the 2nd decimal place...
So I need to synthetically produce TICKVALUE... At the moment this is what I have but the lot sizing is too large:
The minimum lot size with FXCM on XAUUSD is "1.00" which is $0.01 per PIP (pip being 0.01) value...
Here is what the prints looked like when a demo trade was placed (notice "pips_to_ssl" - 35.85 pips... it should be 358.5 pips, right?):