Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy real life trading vs view on chart not the same.

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

    Strategy real life trading vs view on chart not the same.


    Hi there

    I tested trading with a strategy friday - and i saw some trades happening - and then today i restartet ninja trader - and enabled the stratyegy - and the trades are now "different" - so they are not the same as it appeared in real life.

    I have the strategy set to "on bar close" - im trading MNQ - with 1000 tick on the chart.
    I had idea that analyzer can produce "different" results - but i also though that the buy/sell icons on the charts where representing "exact" trades?


    in the log file i can see that it bought 2 orders - at 16.33.07 and 16.33.31 - and it hit a stop loss limit - and sold them again wihting 16.33.
    Then it bough one more within 16.33.45 - and this hit the stop loss at 16.36

    Wihch means that these trades all where negative.

    But in the screenshot - i see that the strategy actually performed ok/better - if running like that.

    Click image for larger version

Name:	2020-08-29 10_00_22-Chart - MNQ 09-20.jpg
Views:	96
Size:	244.9 KB
ID:	1116077



    The strategy calculates stop loss all the time.



    It happens again a few times - where log file shows seling the long order that I was in - at 19.43 - but the strategy on chart tells me it was sold at 19.45.

    At 20.36 - the strategy on chart shows a great buy long - and this is not present at all in log file.

    at 20.57 and 59 - chart and log file are consistent - but chart tells me it sold the one long at 21.05 - bvut log tells me it sold both at 21.20

    And last thing - on another strategy - on another chart (MES) - it entered a long trade at 22.37 - shown in the log - but it is not shown on chart.

    Should i just post the log info here about the orders? or should i send it somewhere?

    Thanks.


    #2
    Hello KarstenKafl,

    There can be differences between real-time and historical.
    Adding intra-bar granularity can help increase the accuracy of historical orders.

    Below is a link to a forum post that details this.
    https://ninjatrader.com/support/foru...377#post773377

    To find out exactly what is different, I recommend writing the data and condition information to a text file.
    Below is a link to an example script.
    https://ninjatrader.com/support/foru...nce#post100192
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea

      Thank you for all the info.

      I have tried my best reading thorugh all the info - and watching the videos etc.
      IT gives an understanding of some of what i experience - but I have some different issues i believe. I understand the slipage - that is caused by timing - and in my setup sometimes the slipage actually works in my advantage. But i stil have issues.

      Now to test how to get the strategy in real life – to behave the same as in the analyzer – I now tried to add the 1 tick, series.
      Im using a 2000 tick chart as the 0 time frame – which is used for all calculations – and then entiering on the 1. Tick series.
      But the problem is that it basically performs worse in this way – than if it was performing like before.
      Im going with OnBarClose – and I “Just” want it to behave like that… to only do what it should – on bar close.
      I have some stoplosses – which I assume was calculated on each bar close before – but in reality (and in now analyzer) – is acting the second it hits that price.

      So im considering – maybe I have to calculate all the stop loss myself – and then try to test that with historical playback. To see it behaving ok. ? Is that the only/best way?

      But then I saw one thing that I did not understand.
      One of my exit rules is running with comparing MACD – but I use MACD(open, 12, 26, 9) – and for some reason using open shows different results in reality than in backtest….so that exit rule is not enabled in some trades in reality – but it is enabled in backtest.
      What could be a solution for these issues? - again - i wish to get reality to behave like the backtest - but then also to be able to test that - in backtest - without having different results...

      I hope it makes sense
      Thanks,

      Comment


        #4
        Hello KarstenKafl,

        The orders can be submitted while BarsInProgress 0 (the primary series) is processing, but the order submission method should use the overload with BarsInProgress 1 to submit the order to the 1 tick series for more accurate fill prices.

        Set methods (such as SetStopLoss() and SetProfitTarget()) unfortunately cannot be submitted to a 1 tick added series, and will always use the primary series for fills and movement for SetTrailStop(). Exit orders would need to be used for the exits to have accurate fill prices as well.

        The 'Backtesting NinjaScript Strategies with an intrabar granularity' linked in the help guide is a working reference sample that shows how to add intra-bar granularity for accurate order fills.


        The MACD uses the bar information. If the values during backtest are different than real-time, this would imply the data series is different or the parameters are different.
        Are you supplying Opens[0] of the primary series as the input series or Opens[1]?

        Are you printing the values to the output window or are you writing these values to a text file?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea

          Thanks for eplaining - it cleared up some of my confusion about the stoploss - I thought i was actually running on the series that the order was applied to? and not the "main" series?

          For the MACD values - i use MACD(open, 12, 26, 9) -
          i dont understand what you write about Opens[0] or 1 but I use it on the primary series - barsinprogress = 0.

          Im not printing out the values - because i have just now found out that this was the issue.

          But i debugged it (by disabling different parts) and found that it was because of this one MACD condition that was only valid in realtime - but not in historical bars.

          But i can write out the values of the MACD - if that will help?

          Comment


            #6
            Hello KarstenKafl,

            Opens[0] would be the open series for the primary bars, Opens[1] would be the open series for the added series (BarsInProgress 1).
            https://ninjatrader.com/support/help.../nt8/opens.htm

            Yes, print the time of the bar and the value of the MACD, and save this to a text file.

            I am directly including the link to using prints to understand behavior that is in the previous forum post linked on comparing results.
            https://ninjatrader.com/support/foru...121#post791121

            I am happy to assist with analyzing the output.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by hdge4u, Today, 09:09 PM
            0 responses
            15 views
            0 likes
            Last Post hdge4u
            by hdge4u
             
            Started by hdge4u, Today, 09:02 PM
            0 responses
            8 views
            0 likes
            Last Post hdge4u
            by hdge4u
             
            Started by stormcloudseven, Today, 08:41 PM
            1 response
            9 views
            0 likes
            Last Post DavidTrades  
            Started by GussJ, Today, 01:24 PM
            0 responses
            23 views
            0 likes
            Last Post GussJ
            by GussJ
             
            Started by frslvr, Today, 12:40 PM
            0 responses
            16 views
            0 likes
            Last Post frslvr
            by frslvr
             
            Working...
            X