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

Drawing objects in a multi-timeframe scenario

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

    Drawing objects in a multi-timeframe scenario

    Hi support,

    I am developing a multi-time frame strategy and i need to draw a line when the user clicks at a specific location on the chart. My strategy detects the mouseclick event and try to draw a line using this command:

    Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, DashStyleHelper dashStyle, int width)

    My question is this:
    In a multiframe scenario, how can i tell the command Draw.Line() these two variables startBarsAgo​ and endBarsAgo​ should target the primary time frame or (BarsArray[0])?

    The primary time frame is 1 minute and the secondary time frame is 15 ticks. For example if startBarsAgo​ = 10, i mean 10 bars ago on the primary time frame not 10 bars ago on the secondary time frame. So far, i have not been able to target the primary time frame in my mouseclick event.

    What would you suggest ?

    #2
    Hello trendisyourfriend,

    Thank you for your post.

    What I suggest is to draw the line in OnBarUpdate() when BarsInProgress == 0 to ensure that it is drawn based on the primary series. You could use your mouse click event to toggle a bool and also save any information needed to draw then line into different variables when the click happens. In OnBarUpdate() the condition could check that the bool is true and that the BarsInProgress == 0 before drawing the line (with any saved variables necessary). For more information about working with multi-time frame & instruments, please see the help guide page here:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      The drawing objects always do their indexing relative to BarsArray[0]. So, even if BarsInProgress != 0, as long as you check first that CurrentBars[0] >= 0 meaning there is at least one chart bar you can use the bar index back method to add or update drawing objects. Specify the number of bars back relative to CurrentBars[0] not CurrentBar, if you are not on BarsInProgress == 0.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      1 view
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      1 view
      0 likes
      Last Post 00nevest  
      Started by Jonafare, 12-06-2012, 03:48 PM
      5 responses
      3,986 views
      0 likes
      Last Post rene69851  
      Started by Fitspressorest, Today, 01:38 PM
      0 responses
      2 views
      0 likes
      Last Post Fitspressorest  
      Started by Jonker, Today, 01:19 PM
      0 responses
      2 views
      0 likes
      Last Post Jonker
      by Jonker
       
      Working...
      X