Libraries: Symbol - page 5

 
Viktar Dzemikhau:
I am wondering why custom symbols are needed?

tick history - not MT5. You can immediately understand how well the source fits your TS in terms of trading conditions.

  • You can synchronise price histories from different symbols to avoid false arbitrage situations.
  • You can run statistical Expert Advisors in the tester on different price histories and compare trading conditions.
  • You can compare lags between different feeds.
  • You can remove obvious errors in the price history, fill holes.
  • You can generate your own price history with the necessary statistical data - Monte Carli TC.
  • You can generate price history of synthetic symbols and run TC on them.
  • ...
  • Some things are implemented in this branch.

     
    fxsaber:

    In MT5 tester, as a rule (forex, for example), limit orders have positive slippage, which leads to Call ExpertRemove when the corresponding event has occurred. Thereby speeding up Optimisation significantly.

    It is especially important for custom symbols, as there transactions are made even with negative balance.

    Simple ExpertRemove will not do, because it is forced closing of current positions at zero last-price in case there is no data on it in custom symbols (most often).


    Therefore, to still get out of the backtest without poker, you should do the following before ExpertRemove

    // Closes positions via limit orders
    bool CloseAll()
    {
      bool Res = true;
      
      for (int i = OrdersTotal() - 1; i >= 0; i--)
        if (OrderSelect(i, SELECT_BY_POS))
          Res &= (OrderType() > OP_SELL) ? OrderDelete(OrderTicket())
                                         : OrderSend(OrderSymbol(), OrderType() ? OP_BUYLIMIT : OP_SELLLIMIT , OrderLots(), OrderClosePrice(), 100, 0, 0) && false;
        
      return(Res);
    }
    
    void OnTick( void )
    {
      if (IsRemove() && CloseAll())
        ExpertRemove();
    }


    Note that closing on the current tick will be only on the netting (where the original task of removing slippages of limit orders is implemented), since the closing on the current tick will be only on the netting (where the original task of removing slippages of limit orders is implemented).

    Forum on trading, automated trading systems and testing trading strategies.

    Libraries: Symbol

    fxsaber, 2018.04.06 16:43

    Limit orders at the current price on exchange symbols Netting accounts will be executed (and in Tester) immediately, without waiting for the next tick.


    Note that it is not just the stock symbol that is important, but also the netting account. For example, you can take a MOEX symbol on a Hedge-MQ-Demo, but it will not execute the same way (and in the Tester) as on the same Netting-MQ-Demo.

    This is one of the reasons why backtests on the same completely identical MOEX-symbols can be different, depending on the account type.

    So sometimes you have to wait for the next tick.


    That's the kind of dancing.

     

    Forum on trading, automated trading systems and testing trading strategies

    Libraries: Symbol

    fxsaber, 2018.04.07 22:37

    Summary

    On real ticks, the number of ticks decreased by 16 times (the lightest filter), the speed of Optimisation increased by 14 times, the quality did not suffer at all (analysis that did not enter here). Of course, this can be done only when writing the TS in a certain way. In particular, with the absence of bar analysis.

    The previous free universal acceleration gave only a twofold increase. The current one is also free (the quality does not suffer), but less universal. However, the return is more than an order of magnitude. Now I optimise TC only in this way. No mistake.

    Since the topic concerns acceleration, here is another recipe for acceleration

    Forum on trading, automated trading systems and testing trading strategies.

    Errors, bugs, questions

    fxsaber, 2018.09.11 17:15

    Tester folder moved to 5Gb RAMDisk and in the MT5 directory executed

    mklink /j Tester z:\Tester


    Now SSD sleeps peacefully, Optimisation became ~1.5 times (by eye) faster, for free!

    At the same time SSD is not killed.

     
    fxsaber:

    simple ExpertRemove cannot be used, because the current positions are forced to be closed at the zero last-price if there is no data on it in custom symbols (most often).


    These are such dances.

    The crutches are also in another

    Forum on trading, automated trading systems and testing trading strategies

    Errors, bugs, questions

    fxsaber, 2018.09.12 18:30

    In the video

    Exchange instrument on real ticks. Bars are built by Bid, no flipper data, BUY position is open. It can be clearly seen that the current closing price of the position

    PositionGetDouble(POSITION_PRICE_CURRENT)

    is constantly equal to zero, despite the fact that Bid is changing all the time. How can I explain to the Tester that a stock symbol should close a BUY position by Bid? Right now, even equity is not calculated.


    So for now the only solution is to make (Bid+Ask)/2.

     
    fxsaber:

    Since the topic concerns acceleration

    Tester's "real ticks" walkthrough for three months (8 million ticks) takes 100 ms (4000 OrderSend, 800 trades + EA logic). The recipe is custom symbols.

     

    Thanks for the code. I've created something for myself based on it... However, I slightly modified the cloning method so that it was possible to load a certain part of the history. Otherwise, if there are a lot of ticks, it consumes a lot of RAM.

    bool CiCustomSymbol::Clone(const string _src_symbol,const ulong _from_msc=0,const ulong _to_msc=LONG_MAX)
    
     
    Denis Kirichenko:

    slightly tweaked the cloning method to allow loading a certain part of the history. Otherwise, if there are a lot of ticks, it consumes a lot of RAM.

    I've updated it taking into account your comment, Thank you.

     

    I have also created 2 methods to load a custom history from a file . Let's say there are 2 files with ticks and minutes. The task is to load them into the ticks and quotes database of the selected symbol.

    bool              LoadTicks(const string _src_file_name);
    bool              LoadRates(const string _src_file_name);
     
    Denis Kirichenko:

    I have also created 2 methods to load a custom history from a file . Let's say there are 2 files with ticks and minutes. The task is to load them into the ticks and quotes database of the selected symbol.

    So the format is not defined in general case.

     
    fxsaber:

    So the format is not generally defined.

    Yes, but we need to think about it. But I have archives of ticks with a specified format, and I have made it for now. Simple enough: <DATE>,<TIME>,<BID>,<ASK>.