Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to make Draw.Ray visible on all timeframes programmatically?

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

    How to make Draw.Ray visible on all timeframes programmatically?

    Hi,
    If I want to add, for example, resistance or support level on M15 timeframe and see it on M1 timeframe, manually I do next:
    1. Add a new drawing object on M15
    2. Change the option "Properties > General > Attach to" from "CL 03-22 15 Minute" to "CL 03-22 (All charts)"
    3. Now I can see this added object on any timeframe for CL 03-22, for example
    But, if I add a new Draw.Ray() programmatically on M15 timeframe, how can I change "Attach to" property to see I programmatically added Draw.Ray() on all timeframes?
    I add a new ray like this:
    Code:
    NinjaTrader.NinjaScript.DrawingTools.Ray ray;
    ray = Draw.Ray(this,"level_ray_"+ Time[0], false, 1, levelPrice, 0, levelPrice, Brushes.Green, DashStyleHelper.Solid, 4);
    And what next?
    Code:
    ray.AttachedTo.AttachedToType = AttachedToType.GlobalInstrument
    - doesn't work, because "Property or indexer 'NinjaTrader.NinjaScript.DrawingTools.DrawingToolA ttachedTo.AttachedToType' cannot be assigned to -- it is read only"



    #2
    Hello Handlar,

    Thank you for your post.

    You can use one of these two overloads that takes an "isGlobal" boolean and a templateName. Using this will cause the ray to be drawn on all charts of the same instrument. Note that you must first draw a ray manually, then enter its properties and save it as a template. You will supply that template name to the templateName string.

    Draw.Ray(NinjaScriptBase owner, string tag, int st artBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)
    Draw.Ray(NinjaScriptBase owner, string tag, DateTime startTime, double startY, DateTime endTime, double endY, bool isGlobal, string templateName)

    https://ninjatrader.com/support/helpGuides/nt8/draw_ray.htm

    Please let me know if I can assist further.

    Comment


      #3
      Kate, thank you so much! It was so easy?
      One more question: I correctly understood that "templateName" means my own templates I created before?

      Comment


        #4
        Hello Handlar,

        A simple example:

        string mytag = "myRay";
        DateTime myDT2 = DateTime.Now;
        DateTime myDT1 = myDT2.AddHours(-10);
        double myPrice1 = GetCurrentAsk();
        double myPrice2 = myPrice1 +10;
        string template = ""; //"" for default

        var myRay = Draw.Ray(this, mytag, myDT1, myPrice1, myDT2, myPrice2, true, "");
        myRay.DrawnBy=null; //== user drwan
        myRay.IsLocked = false;

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        601 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        559 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X