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 Filling 2-4 Order In Succession

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

    Strategy Filling 2-4 Order In Succession

    I am running a strategy on playback and it placed 2 orders in a row instantaneously one after the other and added extra ticks to my stop loss. It seems to happen if my stop loss is hit right after order is filled. Is there a way to stop this? Will this happen in Live trading? I'm scared.

    #2
    Hello Sadat,

    This is likely due to the logic being used in combination with the strategy settings being used. It is possible that if your condition remains true after your stop is filled it will repeat the same process over and over.

    Are you currently setting the stop very close to the entry price where it may be filled within the same bar? Another item would be using the strategy OnEachTick, intrabar calculations can also result in many entries per bar with a condition that is not specific enough or an order placement that is very close to the entry price.

    If you are seeing this occur in playback during live playback, it is very likely that something similar may happen in realtime. Depending on what logic is being used and how specific the conditions to trade are will control this type of occurrence.



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      The stop is 3 ticks. I am using market replay with a strategy. The part you said about conditions being specific enough could be the problem. I tightened up my values for volume and Buysell pressure before and it seemed to decrease the orders in succession. Right now my volume values are within 50 of each other and my buysell pressure values are within three of each other. Maybe that is not tight enough. I do not want to make it too tight to the point it will not trigger

      Comment


        #4
        Hello Sadat,

        If there should be no point where two or more entries/exits should happen in the same bar you could look into using the BarsSinceEntryExecution or BarsSinceExitExecution in your logic. For conditions that would be difficult to make more specific, you can always look at using logic to control that situation better.




        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,


          You mentioned using logic. Where would you place this logic in the strategy?

          Comment


            #6
            Hello Sadat,

            This syntax would need to be part of a condition similar to the samples shown in the help guide. Your strategy likely has other conditions in it, you could use these items in your conditions if that would assist in refining the condition to happen less frequently. I just mentioned these items because they deal with a number of bars since an event. If you wanted to ensure the condition cannot become true again in the same bar, these are good items for that use case.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Originally posted by Sadat View Post
              Hello Jesse,


              You mentioned using logic. Where would you place this logic in the strategy?
              You would use the logic as part of your entry gate. That would depend on exactly what you want your final state to be regarding the orders entered. As an example, if you wanted to ensure that there can be one and only one entry on a bar, and we shall assume that you (most efficient way) use a bool variable to determine whether to make an entry, here is some structured pseudocode that you could use.

              Code:
              // these are declared in class scope.
              private int entryBar =0;
              private bool entryAllowed = false;
              
              protected override void OnBarUpdate()
              {
                  if (IsFirstTickOfBar) entryBar = 0; //this resets this on entry to each bar, effectively allowing orders to be made, [I](q.v.)[/I]
              
                  if (/* all your entry conditions are met */) entryAllowed = true;
                  else entryAllowed = false;
              
                  if (CurrentBar != entryBar && entryAllowed)
                      {
                          /*your entry order here - EnterLong(... etc) */
                          entryBar = CurrentBar; //this ensures that the block cannot be entered again until the entryBar variable is reset on the open of the next bar
                      }
              }

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Perr0Grande, Today, 08:16 PM
              0 responses
              2 views
              0 likes
              Last Post Perr0Grande  
              Started by elderan, Today, 08:03 PM
              0 responses
              3 views
              0 likes
              Last Post elderan
              by elderan
               
              Started by algospoke, Today, 06:40 PM
              0 responses
              10 views
              0 likes
              Last Post algospoke  
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              9 views
              0 likes
              Last Post maybeimnotrader  
              Started by quantismo, Today, 05:13 PM
              0 responses
              7 views
              0 likes
              Last Post quantismo  
              Working...
              X