Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Doji line placement

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

    Doji line placement

    Hi,

    I am trying to make a indicator that would put lines above and below a doji candle. Would like a green one above and red below. I have a script that compiles but not sure if it works. Is there a indicator I could modify
    Attached Files

    #2
    Hello,

    I'm not aware of an existing indicator which accomplishes this.

    What type of line would you like drawn? A horizontal or vertical? How long would you like the line to be?

    Perhaps if you could make a mock up of what you want the indicator to display, we would be happy to point you in the right direction to program it.
    MatthewNinjaTrader Product Management

    Comment


      #3
      I would like a horizontial line at the high and low, green at the high and red at the low. Line length of at least 10-50 bars I am trying to modify the candlestickpatternall indicator so it would label the doji but I am green at this. I would appreciate any help.

      Thanks

      Comment


        #4
        Using the logic from the CandleStickPattern indicator, we can draw a line when this condition is true. I'm not clear exactly how you want the the line displayed, but this should help get you started

        Code:
                    //ensures we have enough bars on the chart to draw the line 10 bars back
        	    if(CurrentBar<10) 
        		return;
                    // When close of doji candle, draw a line at top and bottom 
                    // plot green line above doji and red below it.
        
                    if (Math.Abs(Close[0] - Open[0]) <= (High[0] - Low[0]) * 0.07)
                    {
        
                        DrawLine("greenline"+CurrentBar, false, 0, High[0], 10, High[0], Color.Green, DashStyle.Solid, 1);
                        DrawLine("redline"+CurrentBar, false, 0, Low[0], 10, Low[0], Color.Red, DashStyle.Solid, 1);
                    }
        Please have a look at the DrawLine() functoin for more information on how this works.



        Currently I have it set to draw from the current bar where the Doji is found to 10 bars back. You can set this to whatever you like, but make sure to increase the current bars check to match the max number of bars you're drawing back. Keep an eye on the Log tab of the Control Center for any errors if the lines do not plot



        Hope that helps.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Cool, I will try this and let you know.

          Thanks,
          All the best

          Comment


            #6
            Indicator

            Hi that file isn't working right. Could you give me an example of one starting out or use my file.

            Thanks again

            Comment


              #7
              Yes, that's a txt file - I'm not sure where you obtained that, but you should be able to rename it to a .cs file.

              Or you can download the attached which I used to write your example yesterday.
              Attached Files
              MatthewNinjaTrader Product Management

              Comment


                #8
                I'm sorry. I might be confusing you. I tried change the candlepatternall file with no help. I was wondering if you could use the mydojiindicator file or write one I could use as a template.

                Comment


                  #9
                  In post #7 I included a template .cs file with the code I offered in post #4

                  You should be able to download and save this in (My) Documents\NinjaTrader 7\bin\Custom\Indicator

                  Then open the indicator and compile the script and you should be able to add it to the chart. Then you can make whatever changes you need.
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    Hi, I get an error about Namespace "Ninjatrader indicator" already contains the definition do I need to worry about it?

                    Comment


                      #11
                      Do you have another indicator file named DojiIndicator or MyDojiIndicator? If so, delete it and recompile.
                      MatthewNinjaTrader Product Management

                      Comment


                        #12
                        Reset

                        Hi,

                        Is there a way to reset the indicator after 15 bars

                        Comment


                          #13
                          What exactly are you looking to reset?
                          MatthewNinjaTrader Product Management

                          Comment


                            #14
                            I have my indicator drawing Horizontal lines but would like them to expire in 15 mins or bar equivalant

                            Comment


                              #15
                              My Scriprt

                              protected override void Initialize()
                              {
                              Add(PeriodType.Minute, 5);
                              Overlay = false;
                              }

                              /// <summary>
                              /// Called on each bar update event (incoming tick)
                              /// </summary>
                              protected override void OnBarUpdate()
                              {
                              // Use this method for calculating your indicator values. Assign a value to each
                              // plot below by replacing 'Close[0]' with your own formula.
                              if (Open [0] == Close[0] &&
                              BarsInProgress == 0);
                              DrawHorizontalLine("Doji Long",High [0], Color.DarkGreen);
                              DrawHorizontalLine("Doji Short",Low [0], Color.Red);
                              if (BarsInProgress == 3);
                              RemoveDrawObject("Doji Long");
                              RemoveDrawObject("Doji Short");


                              Let know what you think

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              571 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              331 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              549 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              549 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X