Custom symbols. Errors, bugs, questions, suggestions. - page 20

 

Solution to the problem of automatic change of custom symbol currencies after a Terminal restart.

// Сервис корректирует валюты всех кастомных символов.
#property service

bool CorrectCurrency( const string Symb, const string Currency )
{  
  return(SymbolInfoInteger(Symb, SYMBOL_CUSTOM) && 
         CustomSymbolSetString(Symb, SYMBOL_CURRENCY_BASE, Currency) &&
         CustomSymbolSetString(Symb, SYMBOL_CURRENCY_MARGIN, Currency) &&
         CustomSymbolSetString(Symb, SYMBOL_CURRENCY_PROFIT, Currency));
}

void CorrectSymbols( void )
{
  const string Currency = AccountInfoString(ACCOUNT_CURRENCY);
  
  for (int i = SymbolsTotal(false) - 1; i >= 0; i--)
    CorrectCurrency(SymbolName(i, false), Currency);
    
  return;
}

void OnStart()
{
  CorrectSymbols();
}
 
When testing a custom symbol, is the tick price simulated for it or not?
 
Irek Gilmutdinov:
Can you tell me, when testing a custom symbol, is the tick price for it simulated or not?

Should simulate. It's quicker to check.

 
It's not modelling for me, that's why I'm asking.
 
Can anyone say anything about the problem I raised?
 
jaffer wilson:
Can anyone say anything about the problem I raised?

Have you checked on build 2145?

 

Tick price is not simulated in the tester on the custom symbol.

MT5 build 2145.

I create custom GBPCAD_s, all fields are inherited from GBPCAD:

I load custom minute history into it.

Then I backtest on 100 000 USD deposit and open prices.

A simple Expert Advisor interrogates the price of a tick and opens one position:

void OnTick()
  {
//---
  static bool bOnce = true;
  datetime dtTime[1];
  if (bOnce && CopyTime(NULL, 0, 0, 1, dtTime) == 1 && dtTime[0] % 86400 == 0)
    {
    MqlTick stcTick;
    MqlTradeRequest stcRequest;
    MqlTradeResult  stcResult;
    ZeroMemory(stcRequest);
    ZeroMemory(stcResult);
    SymbolInfoTick(_Symbol, stcTick);
    stcRequest.symbol = _Symbol;
    stcRequest.type = ORDER_TYPE_BUY;
    stcRequest.action = TRADE_ACTION_DEAL;
    stcRequest.price = stcTick.ask;
    stcRequest.volume = 1;
    bool bSent = OrderSend(stcRequest, stcResult);
    
    bOnce = false;
    }
  
  PrintFormat("tv=%.5f, USDCAD=%.5f",SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE), 1/SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE));
  }

The tick price does not change at all and does not match the USDCAD rate at that time.

GBPUSD and USDCAD history is loaded only after the position is opened, but the tick price is not affected.

In the screenshot, the tick price corresponds to USDCAD = 1.3300, while it should be = 1.0230:


 
Irek Gilmutdinov:

Tick price is not simulated in the tester on the custom symbol.

MT5 build 2145.

I create custom GBPCAD_s, all fields are inherited from GBPCAD:

I load custom minute history into it.

Then I backtest on 100 000 USD deposit and open prices.

A simple Expert Advisor interrogates the price of a tick and opens one position:

The tick price does not change at all and does not match the USDCAD rate at that time.

GBPUSD and USDCAD history is loaded only after the position is opened, but the tick price is not affected.

In the screenshot, the tick price corresponds to USDCAD = 1.3300, while it should be = 1.0230:


It's most likely a matter of downloading the history of the minutes, not the ticks.
Load the ticks!

 
There are no tics, testing is done at opening prices.
 
fxsaber:

Solution to the problem of automatic change of custom symbol currencies after a Terminal restart.

Isn't it necessary to check and wait for the terminal to connect to the server? I remember there were cases that without connection the deposit currency is unknown.

Why make a return at the end, where it happens by itself? It makes no sense and is not comical.