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

Convert Ray in Line

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

    Convert Ray in Line

    Hi !!

    I'm plotting RayLines but on a specific moment the lines should end. (I know the Tag at that moment)
    How can I convert this rayline into a line and change it endtime / endbarsago ??

    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.Tag.StartsWith("line5") && draw is ILine)
    {
    ILine globalLine = (ILine) draw;

    First store the old start to use it later with the line:

    globalLine.StartTime

    Then convert it to a line and set another endtime:
    globalLine.DrawType = DrawType.Line;
    globalLine.EndTime;

    OR
    Remove the drawobject
    DrawLine with new values

    }
    }

    Or can I forget the FOREACH and change it directly because I know it's TAG ? Something like:
    DrawObjects["someTag"].DrawType = DrawType.Line


    Hope someone can help me out or give me tips/examples....

    #2
    I am almost certain that you cannot do it that way.

    Here is how I would suggest that you do it.
    1. Find the tag of the ray you want to replace
    2. Get its start parameter
    3. Delete the Ray
    4. Draw a Line with the correct parameters.

    Comment


      #3
      steps

      Any ideas how to replace the NOW ?? to a datetime value?
      ----------------------------
      Step one two and three gives me good results, but can't seem to get the DrawLine correct...




      foreach (IDrawObject draw in DrawObjects)
      {
      if (draw.Tag.StartsWith("line5") && draw is ILine)
      {
      ILine globalLine = (ILine) draw;
      DrawLine(CurrentBar.ToString() + "line5", false, globalLine.StartTime , 1230, NOW ?? , 1230, vpcColor, DashStyle.Solid, vpcHeight);
      }
      }

      RemoveDrawObject(vpclist[i].ToString()+"vpc");
      vpclist.Remove(vpclist[i]);

      Koganam, thx for replying!

      Comment


        #4
        Originally posted by Creamers View Post
        Any ideas how to replace the NOW ?? to a datetime value?
        ----------------------------
        Step one two and three gives me good results, but can't seem to get the DrawLine correct...




        foreach (IDrawObject draw in DrawObjects)
        {
        if (draw.Tag.StartsWith("line5") && draw is ILine)
        {
        ILine globalLine = (ILine) draw;
        DrawLine(CurrentBar.ToString() + "line5", false, globalLine.StartTime , 1230, NOW ?? , 1230, vpcColor, DashStyle.Solid, vpcHeight);
        }
        }

        RemoveDrawObject(vpclist[i].ToString()+"vpc");
        vpclist.Remove(vpclist[i]);

        Koganam, thx for replying!
        If you want the line to end on the CurrentBar, as at the time of the drawing, you want that to be Time[0].

        To specify this exact time, you want DateTime.Now. That is not what you want in this case, because DateTime.Now does not depend on the chart bar time, it depends on the calendar time as at when you are viewing/refreshing the chart.

        Comment


          #5
          from rayline to line with and end

          koganam Thank you very much!!

          Two things I did wrong, but don't know why:

          DrawLine only worked outside the ForEach
          I had to use variables to make Drawline work



          One technical question:

          Is it possible to simplify this:


          foreach (IDrawObject draw in DrawObjects)
          {
          if (draw.Tag.StartsWith(vpclist[i].ToString()) && draw is ILine)
          {
          ILine globalLine = (ILine) draw;
          begintijd = globalLine.StartTime;
          }
          }


          into one sentence because I already know the Tag ? ( line.Tag("tag").startTime ??)

          Comment


            #6
            Originally posted by Creamers View Post
            koganam Thank you very much!!

            Two things I did wrong, but don't know why:

            DrawLine only worked outside the ForEach
            I had to use variables to make Drawline work



            One technical question:

            Is it possible to simplify this:


            foreach (IDrawObject draw in DrawObjects)
            {
            if (draw.Tag.StartsWith(vpclist[i].ToString()) && draw is ILine)
            {
            ILine globalLine = (ILine) draw;
            begintijd = globalLine.StartTime;
            }
            }


            into one sentence because I already know the Tag ? ( line.Tag("tag").startTime ??)
            It looks like you should just be able to write:
            Code:
            begintijd = draw.StartTime;

            Comment


              #7
              shorter

              Hi,

              Than it would be:

              foreach (IDrawObject draw in DrawObjects)
              {
              if (draw.Tag.StartsWith(vpclist[i].ToString()) && draw is ILine)
              {
              begintijd = draw.StartTime;
              }
              }

              But do I really have to foreach everything to find a object with a specific tag when i know the tag? Or is it possible to get the StartTime from a specific draw("tag") ?

              Anyhow, it works but maybe it's less overhead without foreach,

              Thanks for you help

              Comment


                #8
                Originally posted by Creamers View Post
                Hi,

                Than it would be:

                foreach (IDrawObject draw in DrawObjects)
                {
                if (draw.Tag.StartsWith(vpclist[i].ToString()) && draw is ILine)
                {
                begintijd = draw.StartTime;
                }
                }

                But do I really have to foreach everything to find a object with a specific tag when i know the tag? Or is it possible to get the StartTime from a specific draw("tag") ?

                Anyhow, it works but maybe it's less overhead without foreach,

                Thanks for you help
                I was kind of wondering why you were doing that search if you already know the tag. So , the answer is to just use the information if you already know it.

                Comment


                  #9
                  simplify

                  Hi!

                  I know the Tag in advance, cause I gave a horizontal rayline in history the tag of a price. I used the price as tag, and as soon price hits this rayline I want to give a new line an ending.
                  What I don´t know is where this line started in history.!

                  How can I retreive (without a foreach) this rayline beginTime variable using the rayline Tag ?

                  So I know the information in advance, but the only thing I don't know in advance is the beginTime of the rayline that I drew in history ....

                  thanks again!

                  Comment


                    #10
                    Originally posted by Creamers View Post
                    Hi!

                    I know the Tag in advance, cause I gave a horizontal rayline in history the tag of a price. I used the price as tag, and as soon price hits this rayline I want to give a new line an ending.
                    What I don´t know is where this line started in history.!

                    How can I retreive (without a foreach) this rayline beginTime variable using the rayline Tag ?

                    So I know the information in advance, but the only thing I don't know in advance is the beginTime of the rayline that I drew in history ....

                    thanks again!
                    To retrieve any other parameters, given only the tag would require so many preparatory steps, involving parsing to create unique names; creating structures to hold those matched parameters et.c., that, I think that a foreach search may actually be more efficient

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Stanfillirenfro, Today, 07:23 AM
                    5 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by DayTradingDEMON, Today, 09:28 AM
                    1 response
                    14 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    8 responses
                    31 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by helpwanted, Today, 03:06 AM
                    2 responses
                    22 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by navyguy06, Today, 09:28 AM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X