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

Need some help with drawing rays

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

    Need some help with drawing rays

    Hi,

    This is the code I have:-

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]
    if (Low[1]<Low[0] && Low[1]<Low[2])
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]  {
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]   DemandPoint.Set(Low[1]);
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]   DrawSquare("DP1"+CurrentBar, true, 1, Low[1], Color.Red);
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]  }
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    What I would like to do is to DrawRay points identified in the DemandPoint DataSeries IF the newer points at the right of the chart are greater than their older counterparts.

    How would I go about doing that?

    Regards

    Kay Wai

    #2
    Hello,

    Thanks for the note.

    You would need to add another if statement on the drawing of the ray for if( DemandPoint[0] > DemandPoint[1])

    Or if you want to check more points back setup a for loop to iterate back through the data series for how many DemandPoints back you want to check.

    for (int i = 0; i > 10; i++)
    {
    if( DemandPoint[0] > DemandPoint[i]){
    isGreaterInTheFuture = true;
    }
    }

    if (isGreaterInTheFuture = true)
    {
    //Draw Ray
    }

    This is just one way you could do it, there are always multiple ways to do things in programming depending on what you need.

    Let me know if I can be of further assistance.


    Then if the condition is true draw your ray.

    Comment


      #3
      Thanks for your prompt reply and the guidance Brett!

      That gives me a great place to start!

      Comment


        #4
        Hi Brett,

        This is trickier than I thought!

        1) If I want to use the 20 most recent Lows in the Dataseries DemandPoints as reference points and 2) compare them against the Lows stored in the same DataSeries which are prior to and also including these reference points. 3) If the Lows are less than any of the reference points or if the reference point Lows are lower than the more recent reference point Lows, I would like to DrawRays from those Lows through those reference points.

        Hope you can assist!

        Best Regards

        Kay Wai

        Comment


          #5
          Kay Wai, unfortunately we can't custom program indicators such as this. It sounds like you'll have to do a for loop to go through each of the last 20 points in your data series and then compare to Low[n] and draw rays where appropriate.

          Code:
          int count = 20;
          for (int i = 1; i < = count; i++)
          {
              if (Low[i] < DemandPoints[i])
               // draw ray
          }
          AustinNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          1 view
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          238 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          383 views
          1 like
          Last Post Gavini
          by Gavini
           
          Started by oviejo, Today, 12:28 AM
          0 responses
          1 view
          0 likes
          Last Post oviejo
          by oviejo
           
          Started by pechtri, 06-22-2023, 02:31 AM
          10 responses
          125 views
          0 likes
          Last Post Leeroy_Jenkins  
          Working...
          X