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

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"


    Handlar
    NinjaTrader Ecosystem Vendor - Handlar

    #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.
    Kate W.NinjaTrader Customer Service

    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?
      Handlar
      NinjaTrader Ecosystem Vendor - Handlar

      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 trilliantrader, Yesterday, 03:01 PM
        3 responses
        29 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        4 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Brevo, Today, 01:45 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        74 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by suroot, 04-10-2017, 02:18 AM
        5 responses
        3,022 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X