Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daily pivots on 10 minute chart

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

    Daily pivots on 10 minute chart

    Hi there,

    I am a newbie so please excuse my ignorance. I am trying to get a simple strategy worked. I am trying to plot daily pivots on a 10 minute chart. When the price closes above pivot point on 10 minute chart, I would like to go long and when it closes below, I would like to close the position and go short. I am trying this simple strategy to get my feet wet with programming.

    I was able to download the NT pivots and was able to plot them on the chart. But the strategy is not taking positions on price closing above/below the pivot point. Can anyone help me with this on what I am missing or if I need to do anything special? Thanks for your help in advance.

    #2
    Hello Pstechie,

    Thank you for your post.

    Are you using custom coding or the Strategy Wizard?

    Additionally, what is the current syntax or condition setup that you are currently using?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thank you! Started out as strategy wizard but later customized the code a little bit. Following is the code.

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// 10 min Pivot
      /// </summary>
      [Description("10 min Pivot")]
      public class Pivot : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      #endregion

      /// <summary>
      /// This method is used to configure the strategy and is called once before any strategy method is called.
      /// </summary>
      protected override void Initialize()
      {
      EntriesPerDirection = 1;
      EntryHandling = EntryHandling.UniqueEntries;

      //Add(PeriodType.Day, 1);
      Add(anaPivotsDailyV42(anaSessionCountPD42.Second, anaCalcModePD42.DailyClose, anaPivotStylesPD42.Camarilla, anaSessionTypePD42.DailyBars, false, false, 0, 0, 0));
      Add(anaPivotsDailyV42(anaSessionCountPD42.Second, anaCalcModePD42.DailyClose, anaPivotStylesPD42.Camarilla, anaSessionTypePD42.RTH, false, true, 0, 0, 0));

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (Close[0] > anaPivotsDailyV42(anaSessionCountPD42.Second, anaCalcModePD42.DailyClose, anaPivotStylesPD42.Camarilla, anaSessionTypePD42.DailyBars, false, false, 0, 0, 0).PP[0])
      {
      EnterLong(DefaultQuantity, "");
      ExitShort();
      }

      // Condition set 2
      if (Close[0] < anaPivotsDailyV42(anaSessionCountPD42.Second, anaCalcModePD42.DailyClose, anaPivotStylesPD42.Camarilla, anaSessionTypePD42.RTH, false, true, 0, 0, 0).PP[0])
      {
      EnterShort(DefaultQuantity, "");
      ExitLong();
      }
      }

      #region Properties
      [Description("")]
      [GridCategory("Parameters")]
      public int MyInput0
      {
      get { return myInput0; }
      set { myInput0 = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Comment


        #4
        Pstechie,

        You would want to test for your conditions and see if that are indeed becoming true.

        Try printing out your values and the condition to see if its true -
        Code:
        // This prints out the condition for either True or False
        Print(Close[0] > anaPivotsDailyV42(anaSessionCountPD42.Second, anaCalcModePD42.DailyClose, anaPivotStylesPD42.Camarilla, anaSessionTypePD42.DailyBars, false, false, 0, 0, 0).PP[0]);
        
        // This Prints out the values of the PP and Close[0] 
        Print("Close[0]: " + Close[0] + "  Pivot: " + anaPivotsDailyV42(anaSessionCountPD42.Second, anaCalcModePD42.DailyClose, anaPivotStylesPD42.Camarilla, anaSessionTypePD42.DailyBars, false, false, 0, 0, 0).PP[0]);
        You will need to open the Output Window to see the prints
        Tools -> Output Window
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          The NinjaTrader pivots indicator and the anaPivotsDailyV43 indicators both load daily data asynchronously. This means instead of using the Add() method, the daily data is directly loaded from the historical data base. There are reasons for this approach, and there are some disadvantages, which I will try to explain here:


          Let us start with the disadvantages of asynchronous loading of daily bars:

          (1) You cannot call the indicators via a strategy or the market analyzer, when those indicators load daily bars.

          -> if you use the default Pivots indicator of NinjaTrader, you need to set "PriorDayHLC" to "CalcFromIntradayData"
          -> if you use the anaPivotsDailyV42 indicator, you need to set "Calculate from session" to "Auto", "ETH" or "RTH and further set "Settlement/Close" to "IntradayClose".

          You will find attached a little indicator that allows you to simulate and confirm the problem. That indicator tries to access the NinjaTrader default Pivots indicator, and you will notice that it will display nothing, when you try to access daily data.

          (2) The chart will not update automatically. In the beginning of the new trading day, you will first need to update your historical data base to make sure that the daily data is available. You can do this by opening daily charts for all instruments that you wish to update, or you can alternatively download the data with the Historical Data Manager. Then you need to refresh your chart via F5 and the new daily data will be taken into account by the indicator.

          Workarounds: The first problem can be simply solved by copying the entire indicator (maybe without the custom plot which is not needed) into the strategy. Calling daily data should now work, it only does not work if you call the pivots, which then call the daily, as this causes internal synchronisation issues. This workaround is good, if you only trade intraday, but do not hold positions overnight. If you hold positions overnight, you will be subject to the second problem, which means that you need to stop and restart your strategy to update the daily data which it uses.

          Therefore the only clean solution, is not to use daily data, when running an automated strategy that uses one of the Pivots indicators.


          Now let us come to the advantages:

          The anaPivotsDailyV43 indicator is capable of displaying floor pivots which are calculated from regular session data on a full Globex session (ETH) chart. For this purpose a specific session template is used that divides the full session into the night session, the regular session and the remainin part of the trading day.

          When the Add() method is used with such a template, NinjaTrader does not correctly insert daily data, but dependent on the session template, the data can be inserted earlier or later, even at different times of the trading day. I have attached a chart that shows the problem. This is a leftover of the Ninjatrader 6.5 architecture, which did not clearly make a distinction between trading day and session. The asynchronous loading of daily data itself is a workaround for this problem, but has some limitations.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by gbourque, Today, 06:39 AM
          0 responses
          3 views
          0 likes
          Last Post gbourque  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by benmarkal, Yesterday, 12:52 PM
          3 responses
          23 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by helpwanted, Today, 03:06 AM
          1 response
          20 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          12 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Working...
          X