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

ray problem

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

    ray problem

    Hello. I have an indicator that draws lines when certain conditions are met. as I can make those stripes change their style if other conditions are met?
    with possible serious for?
    Thank you

    #2
    Hello julifro,

    Thanks for your post.

    I'm not certain I fully understand the extent of your questions and the answer would depend on the specifics of what you wish to do. Can you provide an example of what you want to do (Chart and or code)?

    To add a screenshot you will need to click on the "go advanced" and then select "manage attachments:"
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I want to do this.
      Thank you
      Attached Files

      Comment


        #4
        Hello julifro,

        Thanks for your reply and screenshot.

        Yes you can change the appearance of the ray however any changes would apply to the entire ray from beginning to end.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          OK. So I want to do. How could it?

          Comment


            #6
            Hello julifro,

            Thanks for your reply.

            As you have not posted any code I can only offer a general example.

            Somewhere in the code is the statement to Draw the ray, it may look like:

            if (some existing conditions...)
            {
            DrawRay("tag1", 10, 1000, 0, 1001, Color.LimeGreen);
            }

            You have new conditions to evaluate and then change the ray color, so it may look like
            if (your new conditions)
            {
            DrawRay("tag1", 10, 1000, 0, 1001, Color.Red);
            }

            Here is a link to the helpguide section on Drawray: http://ninjatrader.com/support/helpG...7/?drawray.htm
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thanks for your answer but that's not the answer I want. I want to do the following:

              If a condition occurs, then a ray is drawn. No problem.

              if two bars close on that earlier this ray changes color.

              Not as referring to the existing ray.

              Thank you.

              Comment


                #8
                Hello julifro,

                Thanks for your post.

                As was previously advised you cannot change a ray color without changing the entire ray. The code example I provided illustrates how to change the color of the ray. When the first condition occurs a LimeGreen ray is drawn. When the 2nd condition occurs, the ray is recolored Red. Please observe that the name of the ray has not changed, nor have the coordinates, only the color has changed, thus creating the ray changing effect you are looking for.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hello. My code is this:

                  if(CurrentBar < 3)
                  return;
                  if (Close[0] > Close[1] &&
                  Close[0] > Close[2]&&
                  Close[0] > Close[3]&&)

                  {
                  DrawTriangleDown(CurrentBar.ToString(), true, 0, High[0]+((TickSize*2)*2), Color.Blue);

                  DrawRay("rayH"+CurrentBar,true, 1, High[0]+((TickSize*2)*2), 0, High[0]+((TickSize*2)*2),Color.Yellow,DashStyle.Dash,2);

                  }

                  it draws me a ray whenever the condition occurs.

                  Next I want (and not how) that if two bars close above some of those who are in the ray that particular ray graphic style change.

                  thank you and excuse my English

                  Comment


                    #10
                    Hello julifro,

                    Thanks for your reply.

                    What you will need to do is to create variables to hold all of the items (except perhaps color and dashstyle) in DrawRay("rayH"+CurrentBar,true, 1, High[0]+((TickSize*2)*2), 0, High[0]+((TickSize*2)*2),Color.Yellow,DashStyle.Dash,2); so that you can recreate the ray with the new style but using the same values as the ray was originally created with.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      bool type variables?
                      Thank you

                      Comment


                        #12
                        Hello julifro,

                        Thanks for your reply. You will need to create variables that match the requirements of the Drawray() method: http://ninjatrader.com/support/helpG...7/?drawray.htm

                        So in your first DrawRay you would save all those settings ("rayH"+CurrentBar,true, 1, High[0]+((TickSize*2)*2), 0, High[0]+((TickSize*2)*2) into appropriate variables.

                        From the help guide, it identifies the variable types for each: DrawRay(string tag, bool autoScale, int anchor1BarsAgo, double anchor1Y, int anchor2BarsAgo, double anchor2Y, Color color, DashStyle dashStyle, int width)
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          thanks for your reply. My skills are few.

                          I just want to write this and do not know how

                          If (close[0] && close[1]) > DrawRay "rayH";

                          Please help.

                          Comment


                            #14
                            Hello julifro,

                            I think perhaps I have been misunderstanding your needs here. I thought you wanted to know how to change the color/style of an existing ray. From your last post I get the impression you are wanting to code a condition to see if price has closed above a ray line?

                            If that is true, when using a ray, the ray might be at an angle other than 0 degrees (horizontal). So if the ray is not horizontal then you would be need to mathematically calculate a rate of rise and project where the ray would be relative to the close price of the current bar.

                            I have created an example that you can use. It ignores all historical data so you must be connected to live (or replay) data to see it work. The example indicator will draw a single ray from the low 5 bars ago to the current bar high once only. The indicator then calculates the Y value of the ray at each bar going forward and places a dot to visually show that the indicator can know where the projected line is. I've attached an example of what this looks like below and have attached the example indicator to import.

                            In your code then you would then be able to incorporate the ideas and be able to test if the Close[0] is greater than the y value that represents where the ray would be at each bar/candle. Note that you will have to adjust your code for the direction of the ray (above horizontal you would add, below horizontal you would subtract the projection. the example only shows up)

                            If you are unable to use or follow this then I would be glad to recommend a 3rd party programmer to assist you.
                            Attached Files
                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks for your effort.
                              My bad English makes me not explain well.
                              I really want to change the color of an existing line.
                              My idea is this:

                              if(CurrentBar < 3)
                              return;
                              if (Close[0] > Close[1] &&
                              Close[0] > Close[2]&&
                              Close[0] > Close[3])
                              {
                              DrawTriangleDown(CurrentBar.ToString(), true, 0, High[0]+((TickSize*2)*2), Color.Blue);

                              DrawRay("rayH",true, 1, High[0]+((TickSize*2)*2), 0, High[0]+((TickSize*2)*2),Color.Yellow,DashStyle.Dash,2);
                              //BarColor = Color.Blue;
                              }

                              me this works correctly.
                              now I want to do this and how to do it

                              if (Close[0] && Close [1]) > "rayH" , "rayH" change Color.Blue.

                              many many thank you very much

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DanielSanMartin, Yesterday, 02:37 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post DanielSanMartin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              12 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by nandhumca, Today, 03:41 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post nandhumca  
                              Started by The_Sec, Today, 03:37 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Working...
                              X