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

Cant get "Bars since entry" to work

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

    Cant get "Bars since entry" to work

    Hi all and thanks in advance for any help.

    I have done a search of the forum and have found some information but still i am struggling to get this working.

    1. The strategy that i built in the strategy builder is placing trades.
    2. its set to "per tick" so when i take profit on the entry bar another trade is automatically place.
    3 I would like to wait 1 bar after the entry bar before another entry can be placed
    4. I am using "bars since entry" for this. Below are two pictures of how i have this setup
    Click image for larger version

Name:	enter long.png
Views:	514
Size:	15.8 KB
ID:	1089126
    Click image for larger version

Name:	bars since entry.png
Views:	570
Size:	29.3 KB
ID:	1089127

    Is the problem the fact there is no trade to start the process of trades because of this condition? Do i somehow need a separate group that places the first initial trade and only does it once? or do i just have this setup wrong?

    Thanks again for any help with this.
    Jack



    #2
    Hello jmahon,

    Thanks for your post.

    Regarding BarsSinceEntryExecution() if the issue is that you are not getting any entries at all then yes you need to account for the first trade. With reference to the help guide for the method: https://ninjatrader.com/support/help...yexecution.htm You would need to check for a value of -1 OR the number of bars. So -1 means there is no previous entry. You would need to create a "group" in the condition set and the groupd would need to be set to "If Any" and then you would enter the two conditions of checking for 1 bar or checking for a -1. If either of the conditions are true then that group would be true.

    If the issue is that regardless of the BrasSinceEntryExecution() setting that you are getting multiple entries per bar then that is a result of using Calculate.OnEachTick (or Calculate.OnPriceChange), either of those calculate modes allows the strategy to process much faster than the ability to transmit orders and receive their acknowledgement which would then allow BarsSinceEntrytExecution to work. The order process runs asynchronously to the strategy code so this means that you will need to implement your own logic controls to meet your needs. One way that you can do this is to use the current bar number. The Current Bar number changes when a new bar is formed. What you can do is create an int variable type (for example called savedBar) and in the entry conditions you would check if Misc>Current Bar is NOT equal to User Variables>savedBar and if true and your other entry conditions are true then the order is placed. In the order action section you then add the action to assign the current bar to the savedBar which prevents any further orders until the next bar.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello jmahon,

      Thanks for your post.

      Regarding BarsSinceEntryExecution() if the issue is that you are not getting any entries at all then yes you need to account for the first trade. With reference to the help guide for the method: https://ninjatrader.com/support/help...yexecution.htm You would need to check for a value of -1 OR the number of bars. So -1 means there is no previous entry. You would need to create a "group" in the condition set and the groupd would need to be set to "If Any" and then you would enter the two conditions of checking for 1 bar or checking for a -1. If either of the conditions are true then that group would be true.

      If the issue is that regardless of the BrasSinceEntryExecution() setting that you are getting multiple entries per bar then that is a result of using Calculate.OnEachTick (or Calculate.OnPriceChange), either of those calculate modes allows the strategy to process much faster than the ability to transmit orders and receive their acknowledgement which would then allow BarsSinceEntrytExecution to work. The order process runs asynchronously to the strategy code so this means that you will need to implement your own logic controls to meet your needs. One way that you can do this is to use the current bar number. The Current Bar number changes when a new bar is formed. What you can do is create an int variable type (for example called savedBar) and in the entry conditions you would check if Misc>Current Bar is NOT equal to User Variables>savedBar and if true and your other entry conditions are true then the order is placed. In the order action section you then add the action to assign the current bar to the savedBar which prevents any further orders until the next bar.
      Thanks Paul.

      Got it working. appreciate the help

      Jack.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by selu72, Today, 02:01 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by WHICKED, Today, 02:02 PM
      2 responses
      10 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by f.saeidi, Today, 12:14 PM
      8 responses
      21 views
      0 likes
      Last Post f.saeidi  
      Started by Mikey_, 03-23-2024, 05:59 PM
      3 responses
      51 views
      0 likes
      Last Post Sam2515
      by Sam2515
       
      Started by Russ Moreland, Today, 12:54 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X