Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issue: Real-Time Vs Backtesting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Issue: Real-Time Vs Backtesting

    I'm pretty aware about your explanation-warning in the help guide about the typical discrepancies when the same strategy works different depending if it's under backtest or real-time. I've been working in a strategy that is having this problem. The Strategy is pretty simple with basic calculations BUT it must work with two DataSeries simultaneously: Bid and Ask ( in this case the $EURUSD ) . Let me give you a simple description of its logic:

    Code:
    if (BarsInProgress == 0)
    			{	
    				// Simple math calculations	and get a signal 
    			}
    if (BarsInProgress == 1)
    			{	
    				// Simple math calculations	and get a signal
    			}
    // Evaluate signals from DataSeries 0 and DataSeries 1. 
    // If the same Signal then set an order needed otherwise wait for new OnBarUpdate
    When I backtest this Strategy, the calculations, signals, evaluations and executions match the expected behavior.
    When I run it in Real-Time, that's another story. I've set all kind of evaluations to research it. such as: Output windows with key variable prints to see where are the differences.
    After thorough research for possible causes of these discrepancies, I can tell:

    DISCARD CAUSES:
    - Executions filling prices or fillings quantities
    - Both processes ( Backtest or Real-Time ) are under Tick-by-Tick

    POSSIBLE CAUSE
    - Bad filtering of data. It seems that there must be some trouble receiving, filtering and processing events that come pretty fast ( few milliseconds of difference )
    The most clear example that I can give is this:
    for the same event, registered at the same time, in the backtest there's just 1 but in Real-Time there're more, sometimes the double or more, without any logic.

    This issue has stopped all my work, and I'd like some help, new ideas, suggestions...etc

    Thanks in advance

    #2
    Hello pstrusi,

    May we test the strategy or a version that reproduces the matter?
    Can you also detail some specifics on what is occurring?

    Comment


      #3
      Hi Patrick, thanks for your attention.

      This is simple:
      - As you can see in the code, I filter the event for DataSeries: bid or ask;
      - it's done the simple calculations to that event to get a signal value for that DataSeries;
      - the Strategy evaluates the very last current signal values for bid and ask
      - If signals are equal , an order is submitted, otherwise return

      In order to monitoring how events are occurring and their calculations, I print in the Output windows the main variables with the exact time, so I can see if all events are in sync with that chart. Here is when I realize that for example, without any occurence, I have printouts that don't appears in the chart, basically price variation that don't exist.

      I'm trying to do some trials looking for filtering events that don't belong to index 0 or 1 throught this:

      Code:
      if ( BarsInProgress != 0 && BarsInProgress != 1 )
      			{
      				return;
      			}
      So far, printouts are matching. If this solves the issue, this means logically that OnBarUpdate is triggering with events out of index 0 or 1.

      What do you think?
      Last edited by pstrusi; 12-15-2015, 04:24 PM.

      Comment


        #4
        I've found a solution for the issue, filtering OnBarUpdates events that don't belong to DataSeries 0 and 1 ( Last and Ask in my example ) of the Strategy, as I wrote in the earlier post.
        in spite of that in Forex, Last=Bid, OnBarUpdates triggers with any Last, Bid, or Ask coming tick. I supposed wrongly that since Last=Bid it should be just one OnBarUpdate event and it's not during a Real-Time.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by elirion, Today, 01:36 AM
        0 responses
        3 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        9 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        391 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        34 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Working...
        X