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

draw line from strategy to several panels on chart

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

    draw line from strategy to several panels on chart

    how can i make a strategy to draw a horitzontal line on all loaded panel of the chart?

    i guess this is not supported but i just need the right direction to where drawing methods like RemoveDrawObjects and DrawHorizontalLine are located at and how to have them called to a specific panel of the chart.

    i have a feeling it is somewhere aroung ChartControl.BarsArray[n].something but i couldn't get anywhere from there.

    btw, i don't want to load the script to every panel or to use an indicator. i really want the strategy to draw lines on all panels by itself, after loading it to only one DS object.

    #2
    Hello savekad,
    Thanks for your post.

    Say you have added a SMA on the separate panel and want to add a line on the SMA, then please use the below code to do it.

    //In Initialize
    Code:
    Add(RSI(14, 3));   //Add a RSI
    Add(SMA(14));     //Add a SMA
    
    //Set property for the SMA
    SMA(14).Panel = 2;
    SMA(14).DrawOnPricePanel = false;
    You can then draw an object on the 2nd panel as

    //in OnBarUpdate
    Code:
    SMA(14).DrawLine("line", true,10, SMA(14)[0], 0, SMA(14)[0], Color.Blue, DashStyle.Dot, 2);
    Last edited by NinjaTrader_Joydeep; 01-03-2013, 05:08 AM.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      thanks Joydeep but please consider the following:

      what if i would like to use only the script i wrote, and to have it loaded only one time.

      something like this:

      Code:
      protected override void Initialize()
      {
       for (int n = 1; n < ChartControl.BarsArray.Length; n++)
       {
        Add(ChartControl.BarsArray[n].Instrument.FullName, ChartControl.BarsArray[n].Period.Id, ChartControl.BarsArray[n].Period.Value);
       }
      }
      protected override void OnBarUpdate()
      {
       for (int n = 1; n < BarsArray.Length; n++)
       {
        DrawHorizontalLine(BarsArray[n], Close[0]);  // totally made that one up just to emphesize the point
       }
      }
      the goal is to open a chart with, lets say, 2 instruments (in two panels), load a script to one panel and have the script draw lines on both panels using no other indicator or another script load.

      Comment


        #4
        Hello savekad,
        Unfortunately the BarsArray does not have Draw Object property.

        You can create a dummy indicator and assign it to the necessary panel and then draw the Horizontal Line.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          i imagined it can't be done with BarsArray. but what other options are available for me without calling an indicator?

          i just want one script to draw objects on different panels. without calling other scripts.

          Comment


            #6
            Hello savekad,
            Unfortunately I am not aware of any other methods.
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            1 view
            0 likes
            Last Post dustydbayer  
            Started by inanazsocial, Today, 01:15 AM
            0 responses
            2 views
            0 likes
            Last Post inanazsocial  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            5 responses
            22 views
            0 likes
            Last Post trilliantrader  
            Started by Davidtowleii, Today, 12:15 AM
            0 responses
            3 views
            0 likes
            Last Post Davidtowleii  
            Started by guillembm, Yesterday, 11:25 AM
            2 responses
            10 views
            0 likes
            Last Post guillembm  
            Working...
            X