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

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 wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                26 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                32 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, Yesterday, 09:53 PM
                2 responses
                49 views
                0 likes
                Last Post wzgy0920  
                Started by Kensonprib, 04-28-2021, 10:11 AM
                5 responses
                191 views
                0 likes
                Last Post Hasadafa  
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,230 views
                0 likes
                Last Post xiinteractive  
                Working...
                X