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 pibrew, Today, 06:37 AM
      0 responses
      0 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      12 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Working...
      X