Difficulties converting from any symbol's currency to account currency
Hi All,
Hope you are all well. I've gone through some of the topics here to find a few suggestions to solve this problem which I'm sure many have come across.
I'm finding that converting a symbol's profit currency to account currency is way more difficult than expected to be.
I've come across a suggestion by some of the more experienced fellows here regarding using TICKVALUE or it's equivalent in MQL5 (I don't see MODE_TICKVALUE available).
I've come across another suggestion saying that this does not work on all symbols with all brokers so I am left pondering in as to what I can do.
So far, I feel the consideration I have is to just have an array of symbol to symbol and do the calculation like that but I feel this is a little manual and probably not ideal.
I seek to ask for a reliable means to convert profit currency to symbol currency by just knowing a symbol and a price; Where can I start looking to achieve this please? This does not have to; nor will it, depend on an existing position or order.
Thanks
Duncan
//+------------------------------------------------------------------+ //| CURRENCY ADJUSTER | //+------------------------------------------------------------------+ double f_currency_changer(double value){ double ts = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE)*10; double cs = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_CONTRACT_SIZE); if(ts<=0.0 || cs<=0.0) return 0.0; double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); double last= SymbolInfoDouble(_Symbol, SYMBOL_LAST); double open = (ask>0.0 ? ask : (last>0.0 ? last : 0.0)); if(open<=0.0) return 0.0; double close = open + ts; // Usa el mínimo volumen permitido (resultado luego se normaliza por volumen) double vol = fmax(10.0,SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN)); double profit = 0.0; if(!OrderCalcProfit(ORDER_TYPE_BUY, _Symbol, vol, open, close, profit)){ // Fallback: prueba SELL con -ts close = open - ts; if(!OrderCalcProfit(ORDER_TYPE_SELL, _Symbol, vol, open, close, profit)) return value; } double ppl = profit / vol; // PnL en cuenta por lot double r = MathAbs(ppl) / (ts * cs); // account_per_pnl_unit return value / r; }/*++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
Hi All,
Hope you are all well. I've gone through some of the topics here to find a few suggestions to solve this problem which I'm sure many have come across.
I'm finding that converting a symbol's profit currency to account currency is way more difficult than expected to be.
I've come across a suggestion by some of the more experienced fellows here regarding using TICKVALUE or it's equivalent in MQL5 (I don't see MODE_TICKVALUE available).
I've come across another suggestion saying that this does not work on all symbols with all brokers so I am left pondering in as to what I can do.
So far, I feel the consideration I have is to just have an array of symbol to symbol and do the calculation like that but I feel this is a little manual and probably not ideal.
I seek to ask for a reliable means to convert profit currency to symbol currency by just knowing a symbol and a price; Where can I start looking to achieve this please? This does not have to; nor will it, depend on an existing position or order.
Thanks
Duncan