Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order doubt

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

    Order doubt

    Hello,

    I would like that my strategy open a position like this:

    protected override void Initialize()
    {
    Add(PeriodType.Tick, 1);
    CalculateOnBarClose = false;

    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 0)

    {
    if (Close[1]>Open[1] && Open [0]>=Close[1])
    EnterShort(1,"");
    }
    if (BarsInProgress == 1)
    {
    return;

    But it doesn't open the position untili the following bar. What I want is that if the open of the current Bar is higher than the Close of the previous bar, it immediately opens a position, but it waits till the following bar.

    What should I do?

    Thanks

    Sincerely

    #2
    dvercher, you need to submit the order to the 1 tick time series. I'm not sure if that's what you're trying to do now with EnterShort(1, ""), but if you change that to EnterShort(1,1,""), everything should work as you want.
    AustinNinjaTrader Customer Service

    Comment


      #3
      It still doesn't work. I attach you a graph with a little text, so it is better to understand.

      Thanks

      Sincerely
      Attached Files

      Comment


        #4
        Sorry, I misread your original question. There isn't really a way to backtest this with 100% accuracy because the backtester works on a bar by bar basis, so it will always submit the order to the open of the next bar to be filled. It isn't currently possible to have the order filled on the same bar that triggered the order.

        When running this strategy in real-time you will be able to do this if you set CalculateOnBarClose = false because it won't wait for the bar to close to submit the order.

        The suggestion I gave above was because I thought you were trying to submit orders to the smaller, one tick timeframe.
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bill2023, Yesterday, 08:51 AM
        7 responses
        42 views
        0 likes
        Last Post bill2023  
        Started by yertle, Today, 08:38 AM
        6 responses
        25 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        46 views
        0 likes
        Last Post jeronymite  
        Working...
        X