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

Doesn't See the Doji

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

    Doesn't See the Doji

    Hello,

    I'm trying to create a strategy that looks for a Doji, then enters a trade either long or short depending on what the next/current bar does. When I run the strategy the results show zero trades even though I can see plenty of Dojis on the chart. I have attached the strategy and a screenshot of the results. Any idea what I'm doing wrong?

    Thank you
    Attached Files
    Last edited by rt61968; 03-13-2017, 07:33 PM.

    #2
    Hello rt61968,

    Thanks for your post and welcome to the forums!

    The strategy is testing for equality of the HAClose and the HAOpen. The Heiken-Ashi indicator is calculating the HAOpen and the HAClose. These calculations might produce results for example like: 1234.56777777 compared to 1234.56780000 which are not equal and that is what is happening, the strategy is not finding equality.

    To make this work, you would need to unlock your strategy code and use a roundtoticksize method. Reference: http://ninjatrader.com/support/helpG...trument_ro.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_Paul,

      Thanks for the quick response. I'm new at this and not sure where to put that method in my code.
      Perhaps you or another trader would give me a little more guidance. I would greatly appreciate it.

      Here is my code.

      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Strategy;
      #endregion

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Enter the description of your strategy here
      /// </summary>
      [Description("Enter the description of your strategy here")]
      public class HADoji : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int quantity = 1; // Default setting for Quantity
      private int trail = 8; // Default setting for Trail
      private int stop = 8; // Default setting for Stop
      private int target = 20; // Default setting for Target
      // User defined variables (add any user defined variables below)
      private double price = 0;
      #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()
      {
      SetTrailStop("Sell", CalculationMode.Ticks, Trail, true);
      SetTrailStop("Buy", CalculationMode.Ticks, Trail, true);

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()

      {
      // Condition set 1
      if (HeikenAshi().HAClose[0] < HeikenAshi().HAOpen[0]
      && HeikenAshi().HAClose[0] < IchiCloud(10, 34, 100).SenkouSpanB[0]
      && HeikenAshi().HAOpen[1] == HeikenAshi().HAClose[1])
      {
      EnterShort(Quantity, "Sell");
      }

      // Condition set 2
      if (HeikenAshi().HAClose[0] > HeikenAshi().HAOpen[0]
      && HeikenAshi().HAClose[0] > IchiCloud(10, 34, 100).SenkouSpanB[0]
      && HeikenAshi().HAOpen[1] == HeikenAshi().HAClose[1])
      {
      EnterLong(Quantity, "Buy");
      }
      }

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

      [Description("")]
      [GridCategory("Parameters")]
      public int Trail
      {
      get { return trail; }
      set { trail = Math.Max(1, value); }
      }

      [Description("")]
      [GridCategory("Parameters")]
      public int Stop
      {
      get { return stop; }
      set { stop = Math.Max(1, value); }
      }

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

      Thank you

      Comment


        #4
        Hello rt61968,

        Thanks for your reply.

        You would need to enclose the value you wish to round to the ticksize of the instrument. You would only need to do this for the 2 values you are testing for equality, in each set. For example:

        (Instrument.MasterInstrument.Round2TickSize(Heiken Ashi().HAOpen[1]) == Instrument.MasterInstrument.Round2TickSize(HeikenA shi().HAClose[1]))

        Note: The example shows only the parenthesis for the example, if you replace into your code you will still need an additional close ")".
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Excellent!! It works. Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by RookieTrader, Today, 09:37 AM
          4 responses
          17 views
          0 likes
          Last Post RookieTrader  
          Started by PaulMohn, Today, 12:36 PM
          0 responses
          5 views
          0 likes
          Last Post PaulMohn  
          Started by love2code2trade, 04-17-2024, 01:45 PM
          4 responses
          40 views
          0 likes
          Last Post love2code2trade  
          Started by junkone, Today, 11:37 AM
          3 responses
          23 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X