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

Strategy "Startup" Needed

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

    Strategy "Startup" Needed

    I've programmed a strategy that is "always in" the market based on crossovers. I also need to operate with COBC=false. To get around the problem of having more than one bar per entry, I've set the "BarsSinceEntry" to >0 for both entry triggers. It works fine once I get the system started. The problem is when I actually enable the system, the strategy does not make an opening entry -- because there is no "Entry" to refer to in the BarsSinceEntry part of the triggers. In other words, how can I tell the strategy to "just take a position" at some point many bars back so that it cabn calculate where it would be now? I've tried a couple things -- but they are not perfect, because there is still a remote chance of an overfill condition. (One such idea is telling it to enter a position coming out of a session break if I am flat -- but it occurs to me that if a session break leads to a major move, the crossover trigger could hit (and I'd be flat for a split second) and then the "starter" would also hit giving me an overfill). Also I would very much like to do this in Strategy Wizard. I can't seem to tell it "If i've been flat for three bars, go long". If I could do that, my problem would be solved.

    #2
    Hello irish9293,

    Thanks for the post and welcome to our forums.

    A nice feature of BarsSinceExit() is that it returns -1 before the first exit has taken place. So you could structure your entries like this to allow it to trigger for the first entry, and then still enforce BarsSinceEntry() > 0.

    Code:
    if(yourCrossOverConditions && [COLOR="Red"]([/COLOR]BarsSinceExit() == -1 || BarsSinceEntry() > 0[COLOR="red"])[/COLOR]) 
    {
    //doSomething
    }
    To set this up in the wizard, you would essentially have to duplicate your entry methods using two sets.

    One set would include crossover condition && BarsSinceExit == -1. The other set would have your crossover condition && BarsSinceEntry > 0.
    Last edited by NinjaTrader_RyanM1; 01-26-2012, 08:43 AM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan: Thanks -- that should work.

      One last glitch/issue. I actually think "BarsSinceEntry > 0" doesn't work the way i thought -- I'm getting multiple orders on a single bar. I think maybe I should use "BarsSinceEntry >=1"? Do you think this was the cause of the multiple orders (which caused overfills and crashed the strategy)?

      Comment


        #4
        BarsSinceEntry > 0 and BarsSinceEntry >=1 should be the same.

        The most likely reason for overfill in this type of strategy would be if you had like ExitLong(), EnterShort() in the same action section. If this is the case, you would want to remove the separate Exit method. Enter methods would take care of the reversal for you.

        If that's not it, I'm happy to take a look if you can post the code here.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Actually, I haven't had those superfluous Exits, so I'm stumped. I will try the >=1 and see what happens.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by naanku, Today, 07:25 PM
          0 responses
          7 views
          0 likes
          Last Post naanku
          by naanku
           
          Started by milfocs, Today, 07:23 PM
          0 responses
          5 views
          0 likes
          Last Post milfocs
          by milfocs
           
          Started by PaulMohn, Today, 06:59 PM
          0 responses
          7 views
          0 likes
          Last Post PaulMohn  
          Started by bortz, 11-06-2023, 08:04 AM
          48 responses
          1,756 views
          0 likes
          Last Post carnitron  
          Started by Jonker, 04-27-2024, 01:19 PM
          3 responses
          24 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X