Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with my Strategy on CL

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

    Problem with my Strategy on CL

    Hello,

    Today in live trading another unexpected trade was triggered in CL.

    What could be the problem? The code works fine on other instruments and in backtesting!

    Thanks.

    - I deleted unrelevant information -
    Last edited by Nick88; 06-19-2008, 12:33 PM.

    #2
    Unfortunately from this information I would not be able to suggest anything other than debugging the live script to see what is actually happening.

    You have likely seen this before but I will past it in case you have not.

    RayNinjaTrader Customer Service

    Comment


      #3
      Hi Ray,

      Thanks. I commented out the trading rules and made a Print line to see what the value of the average in my strategy is:

      protectedoverridevoid Initialize()
      {
      CalculateOnBarClose = false;
      }
      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid OnBarUpdate()
      {
      double Trend=EMA(Close,200)[0];

      Print(Trend);
      }

      First I notice that the value of 'Trend' is not written to the output window on every tick (I set CalcalateOnClose to false?) but only at the BarClose.

      Second, the value of Trend wich is written to the output window is 135.10. When I insert an EMA 200 indicator in the chart window, its value is 134.59.

      This explains why my strategy generates orders which do not correspond with what I expect by looking at the chart.

      I took care that Session begin/end and interval of the chart and strategy are the same.

      Did I do something wrong in my code?
      Last edited by Nick88; 06-19-2008, 12:25 PM.

      Comment


        #4
        - When you run the strategy, you can set the calculate on bar close property, this is likely still set to true.

        - MA's are displayed rounded to the same number of signficant digits as the underlying instrument tick size for display purposes, programattically, it will return the true double value

        - The easiest way to compare is to run the strategy bar by bar and compare the values to the one on them chart.

        You can ensure you are looking at the same indicator by adding it in Initialize() in the strategy.

        Add(EMA(Close, 200));
        RayNinjaTrader Customer Service

        Comment


          #5
          Hi Ray,

          1) I now have the Strategy writing to the output window the value of 'Trend' on every tick.

          2)

          My new code is:

          protectedoverridevoid Initialize()
          {
          CalculateOnBarClose = false;
          Add(EMA(Close, 200));
          }protectedoverridevoid OnBarUpdate()
          {
          double Trend=EMA(Close,200)[0];

          Print(Trend);
          }

          When I add this Strategy to the Chart Window of CL 'Trend' is plotted on the chart and its value is correct. The values that are written to the output Window are also correct.

          When I start the Strategy from the Strategies tab, 'Trend' is not plotted in the Chart Window. This is as expected I think.

          More importantly, the values for Trend that are written to the output Window are NOT correct, they differ 0.23%! So where it should print 134.79, it now prints 135.11. This cannot be a rounding problem.

          What is that about: when I start the Strategy from the Chart Window everything works fine, if I start the same Strategy from the Strategies Tab, my value for Trend has an offset?

          Update: I just added the Strategy to the CL Chart Window. A few minutes ago an entry was executed correctly.
          Last edited by Nick88; 06-20-2008, 07:13 AM.

          Comment


            #6
            Then likely the underlying data set the strategy is running on in the two instances are different. I would double check to ensure that the days back, session times etc.. are identical between the starting the strategy in the tab vs the chart.
            RayNinjaTrader Customer Service

            Comment


              #7
              Hi Ray,

              For the last two weeks I attached my strategies directly to the chart window and now everything runs just as expected.

              On the Strategies tab one can set the session begin/end time, but not the number of days to look back. I expect the NT 'default value', which is unknown to me, to be too short for my EMA to stabilize.

              Best regards

              Comment


                #8
                >> which is unknown to me
                Please see Tools->Options->Data->Lookback

                Comment


                  #9
                  Thanks Dierk. The standard lookback for minute bars is 10 days. In my strategies I use at least 15 days to get the EMA to stabilize.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Spiderbird, Today, 12:15 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Started by FrazMann, Today, 11:21 AM
                  1 response
                  6 views
                  0 likes
                  Last Post FrazMann  
                  Started by lorem, Yesterday, 09:18 AM
                  5 responses
                  18 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by cmtjoancolmenero, Yesterday, 03:58 PM
                  12 responses
                  42 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by geddyisodin, Yesterday, 05:20 AM
                  8 responses
                  52 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Working...
                  X