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

Plotting High at begging of a chart

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

    Plotting High at begging of a chart

    Morning,

    I am new trying to plot the high in a variable range of opening bars on a chart if Low[0] < Low[Range of Current bars]

    So something like but with code that works : )

    If (Low[0] < Low[ Range between Low[0] & beginning of chart ]

    {
    DrawDot( "FirstHigh", true, MAX(High, Range between Low[0] & begging of chart), High[MAX(High, Range between Low[0] & begging of chart)], Color.Black)

    }



    The Code is just to convey what im trying to do. I tried a few things but had various overload errors.

    If some one could point me in the right direction I would be most grateful.

    #2
    GKonheiser, unfortunately I guess I'm not exactly on what you're trying to achieve here. When would the plotting of the start High of the chart be triggered? When the current Low value is smaller than the mid of Low and the chart start low?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      What I am looking to do is, when a chart starts and prices are increasing , remember the low, when prices fall back though the low draw a dot on the high in-between the two points.

      IE chart open at 50 rally's up to 75 and the falls back through 50, a dot would appear at the high of 75 once we have broken through 50.


      Does that make sense?

      It is part of something bigger im building.

      Comment


        #4
        Yes, that makes sense - thanks. As a courtesy please find a small example attached that would implement this pretty straightforward by keeping track in variables of the values needed for reference. You see the condition to paint the high by the vertical line, currently the Close price is used but you may change of course.

        This could be further extended to for example reset of each open / session break - however hope this simple example would get you going.
        Attached Files
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Again,

          thanks very much for that, ive written the following code and im getting an error and im not sure why:-

          // This namespace holds all indicators and is required. Do not change it.
          namespace NinjaTrader.Indicator
          {
          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          [Description("Enter the description of your new custom indicator here")]
          public class HiLo : Indicator
          {

          // Wizard generated variables
          private double startLow;
          private double firstHigh;
          private int firstHighBar;
          private bool startBool = true;
          // User defined variables (add any user defined variables below)


          /// <summary>
          /// This method is used to configure the indicator and is called once before any bar data is loaded.
          /// </summary>
          protected override void Initialize()
          {
          Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
          Overlay = false;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          if(startBool)
          {
          if(CurrentBar == 0)
          {
          startLow = Low[0];
          firstHigh = High[0];
          }

          if(High[0] > firstHigh)
          {
          firstHigh = High[0];
          firstHighBar = CurrentBar;
          }

          if(Low[0] < startLow)
          {
          DrawDot("firstHigh", true, firstHighBar, High[firstHighBar],Color.Black);
          startBool = false;
          }

          }


          }


          The error im getting is:-
          NinjaScript File Error Code Line Column
          Strategy\HighLow.cs Cannot implicitly convert type 'int' to 'bool' CS0029 - click for info 44 17
          Strategy\HighLow.cs Cannot implicitly convert type 'int' to 'bool' CS0029 - click for info 50 17

          Comment


            #6
            You're welcome, is the compile error truly coming from this very script? The compiler finds an issue with HighLow, yet yours is called HiLo?

            Just double click on the error generated and it will take directly to the offending script / code part.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Of course, yup your correct. sorted now ; )

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by reynoldsn, Today, 04:40 PM
              0 responses
              3 views
              0 likes
              Last Post reynoldsn  
              Started by Philippe56140, 04-27-2024, 02:35 PM
              6 responses
              54 views
              0 likes
              Last Post bltdavid  
              Started by ETFVoyageur, Yesterday, 06:05 PM
              7 responses
              45 views
              0 likes
              Last Post ETFVoyageur  
              Started by betsuni_123, Today, 04:20 PM
              0 responses
              11 views
              0 likes
              Last Post betsuni_123  
              Started by Aquila_Welokk, 04-29-2024, 01:14 PM
              2 responses
              22 views
              0 likes
              Last Post Aquila_Welokk  
              Working...
              X