Content directory
- Overview
- The concept of point
- Point value
- Spread costs
- Output the spread costs of all Forex symbols
- Test
- Conclusion
Test
The test method is: making a real trading, then comparing the real spread cost with the calculated spread cost.
1. Test parameters
- Platform: MT5
- Server: IMPACT-Demo
- Account type: USD account, GBP account
- Trading lot size: 1 standard lot
- Trading currency pairs: EURUSD,CADJPY,EURGBP,XAUEUR,EURHKD
- Trading Periods: Asian time periods or time periods when spread left unchanged
The idea of choosing a test currency pair is:
1). In USD account, EURUSD corresponds to formula (6) "profit currency is account currency", CADJPY and EURHKD correspond to formula (5) "base currency of direct currency pair for profit currency is account currency", EURGBP, XAUEUR corresponding to formula (7), "base currency of the direct currency pair for profit currency is non-account currency", the three formula conditions of the spread cost have been included.
2). In GBP account, EURGBP corresponds to formula (6) "profit currency is account currency", EURUSD, CADJPY corresponds to formula (5) "base currency of direct currency pair for profit currency is account currency", XAUEUR corresponding to formula (7), "base currency of the direct currency pair for profit currency is non-account currency", the three formula conditions of the spread cost have been included. The currency pairs with GBP and HKD does not exist in the server IMPACT-Demo, therefore choose EURHKD as the test currency pair.
Note: When using the test EA, it is best to choose Asian time periods or time periods that spread left unchanged.
2. Test results
1). USD account
Symbols | Spread in calculating | Spread in real trading | Calculated spread cost | Spread cost in real trading |
---|---|---|---|---|
EURUSD | 5 | 5 | 5.00(USD/1 lot) | 5.00(USD/1 lot) |
CADJPY | 13 | 13 | 11.96(USD/1 lot) | 11.96(USD/1 lot) |
EURGBP | 6 | 6 | 8.48(USD/1 lot) | 8.48(USD/1 lot) |
XAUEUR | 57 | 57 | 70.79(USD/1 lot) | 70.79(USD/1 lot) |
EURHKD | 67 | 67 | 8.57(USD/1 lot) | 8.57(USD/1 lot) |
2). GBP account
Symbols | Spread in calculating | Spread in real trading | Calculated spread cost | Spread cost in real trading |
---|---|---|---|---|
EURUSD | 6 | 6 | 4.24(GBP/1 lot) | 4.24(GBP/1 lot) |
CADJPY | 12 | 12 | 7.81(GBP/1 lot) | 7.81(GBP/1 lot) |
EURGBP | 9 | 9 | 9.00(GBP/1 lot) | 9.00(GBP/1 lot) |
XAUEUR | 57 | 57 | 50.09(GBP/1 lot) | 50.09(GBP/1 lot) |
EURHKD | 67 | 67 | 6.07(GBP/1 lot) | 6.07(GBP/1 lot) |
It is found that in USD account and GBP account, the calculated spread cost is exactly the same as the spread cost obtained from the real trading by comparison. Due to price fluctuations, the spread cost may differ slightly from the real spread cost.
3. Test EA code
#include "SpreadCost.mqh" #include <Trade\Trade.mqh> //+------------------------------------------------------------------+ //| Global var | //+------------------------------------------------------------------+ const double TestLots = 1.0; string g_symbols[] = {"EURUSD","CADJPY","EURGBP","XAUEUR","EURHKD"}; int g_totalnum = 5; int g_spread_output[5]; //output spread double g_cost_output[5];//output cost int g_spread_test[5]; //test spread by trade double g_cost_test[5]; //test cost by trade CTrade otrade; CSpreadCost oSpreadCost(TestLots); int OnInit() { oSpreadCost.GetSymbolsSpreadCost(g_symbols,g_spread_output,g_cost_output); TradeSymbols(); PrintInfo(); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Print spread and Trade Cost Info | //+------------------------------------------------------------------+ void PrintInfo() { string AccountCurrency = "USD"; for(int i=0;i<g_totalnum;i++) { AccountCurrency = AccountInfoString(ACCOUNT_CURRENCY); Print(i+1,". ",g_symbols[i]," OutputSpread is:",g_spread_output[i],", TestSpread is:",g_spread_test[i], ", OutputCost is:",DoubleToString(g_cost_output[i],2),"(",AccountCurrency,"), TestCost is:", DoubleToString(g_cost_test[i],2),"(",AccountCurrency,")!!"); } return; } //+------------------------------------------------------------------+ //| Trade get test cost | //+------------------------------------------------------------------+ void TradeSymbols() { MqlTick latest_price; for(int i = 0; i < g_totalnum; i++) { otrade.Buy(TestLots,g_symbols[i],latest_price.ask); PositionSelect(g_symbols[i]); g_spread_test[i] = (int)SymbolInfoInteger(g_symbols[i],SYMBOL_SPREAD); g_cost_test[i] = MathAbs(PositionGetDouble(POSITION_PROFIT)); otrade.PositionClose(g_symbols[i],g_spread_output[i]*2); } }
Conclusion
After reading the full text completely, we understand the concepts of point, point value and their calculation formulas in different account types, also the concept of spread, formulas for calculation of spread cost, and how to output the spread cost of all foreign exchange currency pairs in the platform. By comparing with test results, it is found that the outputted spread cost is the same as the spread cost obtained from the real trading.