Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting killed on order entry... no... slaughtered...

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

    Getting killed on order entry... no... slaughtered...

    Hi All!!!

    Okay... so the strategy is moving right along... getting close to being able to trade it live... pure lovliness! BUT... I have not a CLUE how to set up the orders.... not a clue, and I'm getting slaughtered in SIM.

    Do I set the trigger "bars ago" to one bar ago? Do I set it to the current bar? Not a clue...

    Do I set the strategy to calculate on bar close? Not a clue...

    Here's what I'll be doing... maybe someone here can take a moment and help me get my head around this one... I would REALLY appreciate that! (so would my 401K).

    Okay... the strategy is a crossover strategy... pretty simple.

    When one line crosses over another, a signal is generated... enter a trade at the first tick of the next bar that forms.

    Now... I'm using 6 range bars... so the bar that creates the crossover is pretty long in terms of time usually. I don't want to enter on that bar, but I DO want that bar to be the trigger (in other words, it's the one which starts the cascade). Sometimes the crossover occurs right at the start of that bar... and then retraces sometime later during the formation of the bar... which causes the crossover to UN-crossover, and prices to reverse. So... I've decided to wait until the next bar for entry... by which time the crossover is usually well underway according to my tests.

    So... what I've decided to do is wait until that bar has closed... and then... at the very first tick of the next bar... enter the trade.

    The way I have it set up now is:

    1. In the crossover condition setup in the strategy wizard, I have the "bars ago" set to 0. In other words, I've said: "if the crossover occurs during the formation of the current bar, wait... and enter on the first tick of the next bar." However, in sim, with live data feed, seem to be late by one bar (one 6 range bar is a lot of money to be giving away due to an entry error). Yep... that's me... clueless...

    2. I have the strategy set to calculate on bar close == true (checkbox is checked). Should this be set to false? (I know this won't work in backtesting, but for live trading, I want to get in at the very open of the next bar.).

    3. As far as the entry setup goes... if I say: "Close[0] + 1 *TickSize" for the long entries, should it be "- 1" for the short entries?

    4. Finally... during SIM trading... I have a profit target set at 8 ticks, with a stop loss set at 8 ticks. When I set the entry criteria to "getcurrentbid" or "close[0] + 1" I keep getting the following errors:

    "AMP Live, Sell stop or sell stop limit orders can't be placed above the market. affected order: blah blah..."

    In addition to that error, I also get: "Strategy has sent cancel requests, attempted to close the position and terminate itself." Huh? Again... not a clue...

    But... by a few days from now... with your wonderful help... I will be a trade NINJA!!!

    As always, my trading and coding friends... any and all help is greatly appreciated, and I look forward to learning more from you.

    -V

    #2
    Hello Aurum,

    Thanks for your post.

    It is important to understand how CalculateOnbarClose =true or false effects your strategy/indicators.

    When set on True, as you have now, all calculations occur once per bar on the last tick of the bar. In the 6 tick bar, the crossover would not be known until the last tick of that bar. Consequently your entries cannot happen until the first tick of the next bar. The good news is that the calculation results will not change.

    When set on False, all calculations occur on each tic (price movement). This means that when the crossover is detected and your logic says enter, it will do so immediately. Concern here is that the crossover condition may be true in one moment and then not true in another moment, then true again, then false again, etc, so you have to guard against a condition that is possible to change potentially hundreds of times within a (range) bar.

    When using CalculateOnBarClose = False, to enter on the first tick of a bar, you can use the system bool FirstTickOfBar, something like if (FirstTickOfBar) {action to take...;}.

    For your entry set-up you have all price types available to you in the strategy wizard.

    Regarding your errors, without your code to review it is difficult to answer. If you do not wish to post your code, please feel free to e-mail it to PlatFormSupport[AT]NinjaTrader[dot]Com , attention: Paul and please reference this forum post.

    Please let me know if I can be of further assistance.

    Comment


      #3
      Thank you Paul for your reply.

      I'm still pretty confused. Maybe even more so now after your reply.

      So, let me try and clarify my questions even more.

      In the scenario I outlined in my previous post, what is the correct procedure to follow?

      If the current bar triggers a crossover... and I want to enter on the first tick of the next bar that forms after that crossover event... how should I configure my strategy? Is the crossover happening on bar [0], or is that bar, which will be closed by the time the trade opens... is that bar considered bar [1]?

      And with regard to the actual order entry command, should I have: "Close[0] +1", or "Close[1] +1"? If I want to enter on the bar AFTER the trigger bar... which of those do I use for my entry command?

      Please keep in mind that these concepts are extremely confusing for someone who has not done this before and is just starting out with NinjaTrader, so please be patient with me and treat me as if I'm six years old...

      Let me ask it this way:

      What is the best way to configure the strategy if I want to trigger the crossover event, have the strategy see that trigger when it occurs, and then, open a trade on the first tick of the next bar that forms?
      Should the strategy be set to calculate on bar close? In my scenario, should that be true, or false? I still really don't have a clue.

      Also, the system bool you mentioned is not available in the wizard, right? I'd really like to stick to the wizard for the moment and do as much as I can there. I'm not familiar with code and don't feel very comfortable with the notion of opening up the strategy and "tinkering" in a realm with which I'm completely unfamiliar. Next year maybe!


      So... in the conditions set... am I looking at the current bar [0], or am I looking at the previous bar? If I want to enter on the next bar... by the time that "next" bar forms... the "signal" bar is now [1], right? See how this is confusing?

      It's the same for the order entry... it is very confusing... am I saying I want to enter at the price of the close of the "previous bar + 1 tick" or am I saying (while the pervious bar is still the current bar, before it closes), am I saying I want to enter at the close of THIS current bar + 1 tick?

      I'm sure I cannot be the only person who is completely baffled by this thing with the "bars ago" field. It's got to be confusing others as well.

      So... in summary:

      1. Calculate on bar close... do I set it for true or false? (based on what I've described as my strategy goals)?
      2. Is the crossover occurring on the current bar... or is it occurring on the previous bar?
      3. Is the order price based on the current bar's close + 1 tick, or is it based on the previous bar's close +1 tick?

      Thank you, thank you, thank you, for helping me understand this fully.

      -V

      Comment


        #4
        Hello Aurum,

        Thanks for your post.

        When your strategy runs on CalculateOnBarClose (COBC)=true:

        A crossover cannot be evaluated until the end of the bar because the strategy can only run once when the bar has closed. If the crossover is detected at the end of that bar your entry would be on the first tick of the very next bar.

        When your strategy runs on CaculateOnBarClose=false:

        If a crossover happens within the bar it will execute your entry immediately. However it is important to understand that the crossover condition can change based on price action within the bar and it is possible that you can have many crossover conditions within one bar. To visualize this bring up a chart of your choice with the moving averages of interest placed on the chart and ensure that they are set to CalculateOnBarClose = false. Set the market replay time for the end of the day, then review the entire day looking for crossovers and write down the times. Next set the market replay to the time just before the crossover and run market replay at 1x speed and observe the changes of the two MAs. You may need to expand the view so you can see the movements of the lines. Do they touch/cross once, many times? The answer will depend entirely on the price action within the bar and the relative positions of the moving averages prior to the crossover. This exercise will give you a great visual as to what CalculateOnBarClose actually means.

        I understand this may be confusing but it becomes important to understand when you are asking the questions that involve COBC= true or false. To clarify what barsago and Close[0] and Close[1] mean. The [0] is an index that points to the Current Bar. In the case of the COBC= true, the Current Bar is the last one closed and the bar that is forming is not known to the strategy until it too closes. Once the forming bar closes, it will now be at index[0] and the bar that was at index [0] is now at index[1]. In the case of COBC=false, the current bar is the one that is being formed and is given the index of [0] on the first tick of the bar, the prior bar is at index of [1]. Here is a refernce post that will also be help: http://www.ninjatrader.com/support/f...d.php?p=108461

        As a recommendation, use market replay extensively to evaluate the strategy performance. Find the condition on the chart that you clearly want to work with, then apply your strategy and evaluate. Then make changes to your strategy and evaluate what COBC true/false means in performance using that condition over and over until you have reached a conclusion. After that you would want to test on multiple conditions. It is easy to get defocus trying to capture everything so focus on one cross on one instrument until you have found what you need.

        I hope this helps, please feel free to write in with any specific question you have to PlatformSupport[at]NinjaTrader[dot]Com.

        Comment


          #5
          Hello Paul,

          Thank you for your detailed explanation. I appreciate you taking the time.

          That is exactly the sort of clarification I was needing.

          Your advice on how to use replay is pure gold!

          I have a couple of other questions, but I'll post them in a different thread.

          Thank you again for this amazing reply!!!

          -V

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sjsj2732, Yesterday, 04:31 AM
          0 responses
          31 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          286 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          283 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          133 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          91 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X