Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Different results in simulated account and in real account.

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

    Different results in simulated account and in real account.

    I have a strategy running, that buys with a limit order, if the RSI (3,1)[0] is under 10 and sells if the RSI(3,1)[0] is over 90. If I simulate this on a NT chart it works execatly how I like.

    But if I run it via Interactive Brokers I get sometimes other executions. It buys sometimes if the RSI is by 12 or sells if the RSI is by 80. The thing is it works not exactly how it should.

    #2
    Welcome to our forums - how do you determine the different RSI values used in realtime in the strategy logic? It would use what you programmed in to use, it's a logical condition it would evaluate that could be either returning true or false, there's no ambiguity here. Please add a visual confirmation to your script on the bar before the order would be placed, so you can exactly check off the RSI values here.

    Another common issues seen is different parameters being used and another CalculateOnBarClose setting in realtime runs compared to backtest. Please check off those items as well.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      if (Low[0] > SMA(200)[0] && ((RSI(3, 1)[0] + RSI (3, 1)[1]) <= 20))// Einstieg Long
      {
      EnterLongLimit(DefaultQuantity, Close[0], "EinstiegLong");
      double value = MAX(ATR(20), 900)[0];
      value = Close [0] - (value * 5);
      SetStopLoss("EinstiegLong", CalculationMode.Price, value, false);

      Thats the code for the entry. It should buy only, if the cumulativ Rsi is under 20. But that is not the case on the chart.
      Attached Files

      Comment


        #4
        How do you determine that it's not the case? Your lower line is not right on the 20 in case you compare to it for debugging.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Ok, my strategy is a little different. I wanted to make it easier. Sorry for that.

          I want a buy, if the cumulativ RSI from the last two bars, is under 20. Thats the code I posted. And on the chart you can see I got a buy, and the cumulativ RSI is higher than 20. I set the line to 10 that you can see, the cumulativ Rsi from the last two bars is not under 20.

          Comment


            #6
            How do you determine the cumulative value is not <= 20?

            Please print the value you calculate in the strategy to doublecheck it's not just a precision issue for example. Visually you can run into conditions that appear to be true / false but when examining the underlying values there's a slight differences that would have not been spotted just by eyesight...
            BertrandNinjaTrader Customer Service

            Comment


              #7
              The Rsi value from the entry bar is 14,07.
              The Rsi value from the bar before the entry bar is 22,47.
              The strategy runs on CalculateOnBarClose = true

              The sum of this bars is greater than 20. But I get an execution.

              Comment


                #8
                You would need to sum the 2 bars before the entry is shown on the chart. Since the bar before the entry shows is the bar you submit the order on.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Yes I know that, but if one bar is over 20 the sum of two bars cannot be under 20.
                  Rsi from the first bar before the entry bar = 22,47
                  Rsi from the second bar before the entry bar = 28,05

                  Comment


                    #10
                    You would really need to print this value from your strategy to determine then why the rule does trigger when you don't expect it. Comparing this to charted values will only go this far, the rule triggers as programmed in, you would need to debug why it does trigger at the point indicated.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      How do you mean I should print this value?

                      Comment


                        #12
                        Please see this tip here - http://www.ninjatrader.com/support/f...ead.php?t=3418

                        With the Print() command you can print to the output window for doublechecking of calcuated value and / or the flow / event sequence of your script.

                        For example best approach would be storing the cumulative RSI to a variable and then printing / using the double or float variable in your condition, this will simplify the debug process for you.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          I think that is not my problem. I tested the strategy, and it works fine on a simulated account. If I test the strategy and put it on a chart everything is correct.

                          The thing what is confusing me is, if I let the strategy run on an account from IB, and check it after on the chart, the values from the chart are not matching the values from my strategy. Like on the chart that I posted.

                          Comment


                            #14
                            If you tested on the simulated account, what datafeed was the data taken from? IB as well?
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Yes IB as well.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by wzgy0920, 04-20-2024, 06:09 PM
                              2 responses
                              26 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, 02-22-2024, 01:11 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, Yesterday, 09:53 PM
                              2 responses
                              49 views
                              0 likes
                              Last Post wzgy0920  
                              Started by Kensonprib, 04-28-2021, 10:11 AM
                              5 responses
                              191 views
                              0 likes
                              Last Post Hasadafa  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              11 responses
                              3,232 views
                              0 likes
                              Last Post xiinteractive  
                              Working...
                              X