Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

removing previous draw object

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

    removing previous draw object

    Hi I am drawing lines ok but I want to onlly keep last drawn line. in this screnshot I have several redlines. I want to have only last one. I tried to remove them but its not working, i am doing something wrong.


    string flagBearLabel = "BearFlag"+CurrentBar;
    string flagBullLabel = "BullFlag"+CurrentBar;
    RemoveDrawObject(flagBearLabel);
    RemoveDrawObject(flagBullLabel);
    if(BullBearFlag)
    {

    isLowSequence = true;
    for (int i = 0; i < lookbackPeriod-1; i++)
    {
    if (Low[i] <= Low[i + 1])
    {
    isLowSequence = false;
    break;
    }
    }

    if (isLowSequence && trendDirection == -1 && Low[0] < Close[0])
    double slope = (Low[0] - Low[lookbackPeriod -1] ) / lookbackPeriod;
    trendlineValueUp = Low[0] - (slope * 0);
    Draw.Line(this, flagBearLabel, true, lookbackPeriod, Low[lookbackPeriod -1], 0, Low[0], Brushes.Aqua, DashStyleHelper.Solid, 2);
    Alert("Alert", Priority.High, "Up trend line broken", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Reve rsing.wav", 10, Brushes.Transparent, Brushes.Transparent);
    bearFlag = true;

    }

    ​​Click image for larger version

Name:	image.png
Views:	38
Size:	35.8 KB
ID:	1318037

    #2
    I would want to keep currentbar to make those lilnes unique so lines stay on the chart historiacally.

    Comment


      #3
      like on this short video, if i remove currentbar then it removes lines from the chart and only keeps the last one occured. I want lines to stay on the chart but only last ones from the signal

      Comment


        #4
        Hello tkaboris,

        It is not clear from your description what you want. The following two statements contradict each other.

        but I want to onlly keep last drawn line. in this screnshot I have several redlines. I want to have only last one.
        I would want to keep currentbar to make those lilnes unique so lines stay on the chart historiacally.

        If you only keep the last drawn line you will never have any historical lines. You will only have a single line on the chart at the position where it was last drawn. That object can be updated to new bars but there will only ever be a single line on the chart.

        If you want to keep using CurrentBar for the tag so its unique and on the chart historically then you won't have the option to only keep the last drawn line. You will have historical lines unless you later remove them.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Use a counter instead of CurrentBar. Use Draw.Line(this, "BearFlag" + BearCtr, ... and then increment the counter: BearCtr++.
          If you want to remove the previous line use this: RemoveDrawObject("BearFlag" +(BearCtr-1));
          If you don't want to remove it skip the removal process and proceed to the next line and counter incrementing.
          You can just remove this stuff:
          string flagBearLabel = "BearFlag"+CurrentBar;
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment


            #6
            How I reposition a line that was created with Draw.Line.without removing it and recreating it which I imagine is slow.?
            I mean, I created one with myline = Draw.Line(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush).
            Then I would like to reposition it with an imaginary command like: myline.AlterPosition(startBarsAgo, startY, endBarsAgo, endY). I don't see a command similar to this anywhere in the documentation or forum.
            What is correct and simple way to do it (if it is worth the computing effeciency)
            Or Else which one the simple suggested way to obtain the same result? Or should I remove the object and recreate it ? (Which I guess it's slow)
            Best
            Gio

            Comment


              #7
              Hello giogio1,

              To reposition a line you just have to call the draw method again with new values and the same tag to update the existing object.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by giogio1, Yesterday, 03:18 AM
              4 responses
              17 views
              0 likes
              Last Post giogio1
              by giogio1
               
              Started by jkop123, Today, 07:05 PM
              0 responses
              2 views
              0 likes
              Last Post jkop123
              by jkop123
               
              Started by jkop123, Today, 07:04 PM
              0 responses
              2 views
              0 likes
              Last Post jkop123
              by jkop123
               
              Started by DayTradingDEMON, 09-08-2024, 11:25 PM
              12 responses
              359 views
              0 likes
              Last Post defa0009  
              Started by thedude, 11-14-2021, 08:44 AM
              5 responses
              532 views
              0 likes
              Last Post jmschmidt357  
              Working...
              X