Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Heiken-Ashi Close - Open

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

    Heiken-Ashi Close - Open

    I have downloaded the heikenashi8 indicator and applied it to a chart. It works very well. Now I'm trying to calculate the difference between the haclose and the haopen. I think this would require a new indicator, but I can't figure out how to do it. Any help would be appreciated.

    #2
    Hello Cliffg26,

    Thanks for your post.

    This could be possible to accomplish in either a new indicator or by modifying the HeikenAshi8 indicator.

    If you are modifying the HeikenAshi8 indicator and want to calculate the HAHigh value - the HALow value, you could create that calculation in the script and draw the calculated value on the chart using Draw.TextFixed().

    For example, you could create a class-level double variable called something like 'HADiff', assign the HAHigh[0] - HALow[0] to the HADiff variable, and use that variable in the Draw.TextFixed() method to draw it on a chart.

    The code might look something like this.

    Code:
    //class level variable
    private double HADiff;
    
    //OnBarUpdate
    protected override void OnBarUpdate()
    {
    [I]...some code here[/I]
    
        HADiff = HAHigh[0] - HALow[0];
        Draw.TextFixed(this, "myTextFixed", HADiff.ToString(), TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Blue,  Brushes.Transparent, 0);
    }

    See the help guide documentation below for more information.

    Draw.TextFixed: https://ninjatrader.com/support/help..._textfixed.htm

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Many thanks for your help, but I'm new to Ninjatrader, and I don't know how to write that kind of code. I tried to create an indicator, but it doesn't work. Code is below.

      Code:
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class CFHeikenAshiLength02 : Indicator
      {
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "CFHeikenAshiLength02";
      Calculate = Calculate.OnPriceChange;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      AddPlot(Brushes.Orange, "HeikenAshiLength");
      }
      else if (State == State.Configure)
      {
      AddDataSeries(Data.BarsPeriodType.Minute, 1);
      }
      }
      
      protected override void OnBarUpdate()
      {
      //Add your custom indicator logic here.
      Value = HAHigh - HALow;
      }

      Comment


        #4
        Hello Cliffg26,

        Thanks for your note.

        Unfortunately, in the support department at NinjaTrader, it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services in our support. This is so that we can maintain a high level of service for all of our clients as well as our partners.

        It would be up to you to study the NinjaScript items, example code, and help guide documentation mentioned in posts and create the indicator yourself.

        If you have any specific NinjaScript questions as you create or modify your indicator, we would be happy to provide assistance with those specific questions.

        Note that if you are making a new NinjaScript indicator that accesses the HeikenAshi8 indicator, you cannot just use HAHigh and HALow.

        You would first create a class-level HeikenAshi8 variable and a variable to hold the difference of those values, such as HADiff.

        //class level variable
        private HeikenAshi8 myHeikenAshi8;
        private double HADiff;


        Then, you would instantiate the variable within OnStateChange() when the State == State.DataLoaded.

        else if (State == State.DataLoaded)
        {
        myHeikenAshi8 = HeikenAshi8(Close);
        }


        Once you instantiate the indicator, you could access the HAHigh and HALow values from the myHeikenAshi8 variable and draw the text on the chart using the Draw.TextFixed() method. Note this would be done in the OnBarUpdate() method.

        protected override void OnBarUpdate()
        {
        HADiff = myHeikenAshi8.HAHigh[0] - myHeikenAshi8.HALow[0];

        Draw.TextFixed(this, "myTextFixed", HADiff.ToString(), TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Blue, Brushes.Transparent, 0);
        }


        The C# programming language is used for developing NinjaScript indicators and strategies.

        Below is a link to a forum post with helpful information about getting started with NinjaScript.
        https://ninjatrader.com/support/foru...040#post786040

        If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first:
        https://ninjatrader.com/support/help...g_concepts.htm

        Let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Okay, thanks for your help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by carnitron, Today, 08:42 PM
          0 responses
          6 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Today, 07:51 PM
          0 responses
          8 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,974 views
          3 likes
          Last Post jhudas88  
          Started by rbeckmann05, Today, 06:48 PM
          0 responses
          9 views
          0 likes
          Last Post rbeckmann05  
          Started by rhyminkevin, Today, 04:58 PM
          4 responses
          58 views
          0 likes
          Last Post dp8282
          by dp8282
           
          Working...
          X