Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

problem using DrawLine

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

    problem using DrawLine

    Hi,

    I have a problem using drawline.
    I would like to plot support/resistance lines on the chart ,the plot would begin at the current bar when some MA crosses above another one and continue until it crosses the other way..etc
    Is there anyone who could help me ?

    #2
    Are you requiring general help? If yes, a NinjaScript consultant may be able to help.



    If you are having a problem with this specific method, please provide more details as to the problem you are having.

    Thanks
    RayNinjaTrader Customer Service

    Comment


      #3
      the thing is that you must precise 'start & end bars ago' parameters when you use
      this method. But the begining and the end of the support/resistance lines l want to draw are defined through crossover signals.
      So each line should start to be plotted at the current bar when a crossover occur and continue until a new crossover...but then how can I fill the 'end bars ago' parameter?
      I don't know if you follow me

      Comment


        #4
        Just keep redrawing it out to endBarAgo = 0 until you reach your new condition. Then stop drawing the moment your new crossover is reached. You will probably need to increment startBarsAgo with this method as each new bar is built. Then on the final drawing just leave it be and it will be set.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I don't understand what you mean. Is it possible to explain a little bit more ?

          Comment


            #6
            You draw line on bar 5 to last bar (say bar 10). Next bar will be bar 11. You will need to redraw that line now from bar 5 to bar 11. You do this by now calling startBarsAgo 6 and the same endBarsAgo 0. When bar 12 comes along you now need to call startBarsAgo 7 and endBarsAgo 0.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              here is part of my script (no problem compliling but when i try to use it, there nothing plotted on chart) :

              Slow.Set(Math.Sin(Math.PI/180*( DCPhase)));
              Fast.Set(Math.Sin( Math.PI/
              180*((DCPhase + 45))) );

              if (CrossAbove(Fast,Slow,0) && HighSetup==false) LowSetup=true;
              if (CrossBelow(Fast,Slow,0) && LowSetup==false) HighSetup=true;

              while (Fast[CurrentBar]>Slow[CurrentBar]) DownStartBarsAgo=DownStartBarsAgo+1;
              while (Fast[CurrentBar]<Slow[CurrentBar]) UpStartBarsAgo=UpStartBarsAgo+1;

              if (Fast[0]>Slow[0] && LowSetup==true && High[0]>High[1])
              {
              SR=MIN(Low,
              2)[0]-TickSize;
              LowSetup=
              false;
              PlotLow=
              true;
              PlotHigh=
              false;
              BreakLow=
              true;
              }

              if (Fast[0]<Slow[0] && HighSetup==true && Low[0]<Low[1])
              {
              SR=MAX(High,
              2)[0]+TickSize;
              LowSetup=
              false;
              PlotLow=
              true;
              PlotHigh=
              false;
              BreakLow=
              true;
              }

              if (PlotLow==true) DrawLine("Support",DownStartBarsAgo,SR,0,SR,Color.Red,DashStyle.Dot,3);
              if (PlotHigh==true) DrawLine("Resistance",UpStartBarsAgo,SR,0,SR,Color.White,DashStyle.Dot,3);
              if (PlotLow==true && Close[0]<SR && Fast[0]>0 && BreakLow==true)
              {
              DrawLine(
              "BreakLow",DownStartBarsAgo,Low[DownStartBarsAgo],0,Low[DownStartBarsAgo],Color.Red,DashStyle.Dot,3);
              DrawDot(
              "BreakL",false,DownStartBarsAgo,Low[DownStartBarsAgo],Color.White);
              }
              if (PlotHigh==true && Close[0]>SR && Fast[0]<0 && BreakHigh==true)
              {
              DrawLine(
              "BreakHigh",UpStartBarsAgo,High[UpStartBarsAgo],0,High[UpStartBarsAgo],Color.Red,DashStyle.Dot,3);
              DrawDot(
              "BreakH",false,UpStartBarsAgo,High[UpStartBarsAgo],Color.White);
              }

              My guess is that it has something to do with my Up&Downstartago.
              Can you tell me why it does not plot anything ?

              Comment


                #8
                If nothing is plotting please check the Control Center logs. You are most likely running into this: http://www.ninjatrader-support.com/v...ead.php?t=3170
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

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