Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi instrument

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

    Multi instrument

    Hello NT,

    There is a simple strategy code. What it does it simply wants to fade the main instrument when instrument's in background added via Add() method, price moves specified amount of points-ticks within specified number of bars. And it is simple reversal - enters when conditions are met and reverses when conditions met for opposite direction.

    Let's say I load a strategy on ES 03-09 chart and via Add i want to add 'MSFT'. As soon as MSFT price moves up 10 cents within last 2 bars, I want to short ES and hold it until MSFT price will do 10 cent downmovement, then reverse.

    Also I want MSFT price check on bar close, and enter ES intrabar.

    Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
                Add(bsym, bperiodtype, bvalue);
            }
            
            protected override void OnBarUpdate()
            {
                if (BarsInProgress == 1 && FirstTickOfBar) 
                {
                        if (High[1] >= MIN(Low, lookback)[2] + priceoffset && Close[1] >= Median[1]) 
                        {
                            DrawDot(CurrentBar.ToString()+"s", true, 0, Highs[0][0] + 2*TickSize, Color.Red);
                            if (entryOrder == null) entryOrder = EnterShort(0,tradingsize,"sell");
                        }
                        if (Low[1] <= MAX(High, lookback)[2] - priceoffset && Close[1] <= Median[1]) 
                        {
                            DrawDot(CurrentBar.ToString()+"b", true, 0, Lows[0][0] - 2*TickSize, Color.Green);
                            if (entryOrder == null) entryOrder = EnterLong(0,tradingsize,"buy");
                        }
                }
            }
            protected override void OnOrderUpdate(IOrder order)
            {
                if (entryOrder != null && entryOrder.Token == order.Token)
                {
                    Print(order.ToString());
                    if (order.OrderState == OrderState.Filled)
                    entryOrder = null;
                }
            }
    The problem I am getting is that strategy does not process any orders "real time" and I am getting such a printout:

    Order='NT-00270/Sim101' Name='sell' State=PendingSubmit Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'
    Order='NT-00270/Sim101' Name='sell' State=Accepted Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'
    Order='NT-00270/Sim101' Name='sell' State=Working Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'
    Order='NT-00270/Sim101' Name='sell' State=Filled Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=1 Fill price=768 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'

    Order='NT-00272/Sim101' Name='buy' State=PendingSubmit Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
    Order='NT-00272/Sim101' Name='buy' State=Accepted Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
    Order='NT-00272/Sim101' Name='buy' State=Working Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
    Order='NT-00272/Sim101' Name='buy' State=PendingCancel Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
    Order='NT-00272/Sim101' Name='buy' State=Cancelled Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'

    What am I missing? Am I looking for my phone while I am talking on it?

    As you can see from attached pictures, it receives a lot of buy and sell signals, but at some point just stops executing.

    Usually tthat happens as soon as real time data start coming in, sometimes even before - still on historical data

    Thank you much.
    Attached Files
    Last edited by roonius; 02-21-2009, 02:36 PM.

    #2
    Hello,

    After looking at your code briefly, I do not see anything that stands out.

    Try adding some Print()'s and print out key values to be sure they are what you think the should be.

    Also, try commenting out some of your conditions to see if they are holding things up.

    The above may give you clues as to what it going on. Sorry, I am not much more help here. You will need to debug it. This link may help:
    DenNinjaTrader Customer Service

    Comment


      #3
      Ben,

      The conditions are working fine.
      My question was why orders are canceled?
      It enters condition otherwise it would not paint the dots.

      See my previous posts part with Green font.

      thanks
      Last edited by roonius; 02-21-2009, 02:40 PM.

      Comment


        #4
        Hello,

        OK, sorry about that. I think I understand now. All working orders need to be resubmitted each bar. They are automatically cancelled each bar if you do not. This link has more detail on this:
        DenNinjaTrader Customer Service

        Comment


          #5
          Ben, I am placing market orders. They shoud be filled immediately.
          Could you please please investigate this? What causes canceling of orders?
          Is FirstTickOfBar working as expected when multiple symbols are loaded?

          Comment


            #6
            Hello,

            I am not sure what is causing this. I will have someone take a look at this Monday morning.
            DenNinjaTrader Customer Service

            Comment


              #7
              Hi roonius, FirstTickOfBar should work for multiple symbols.

              Did you try moving the FirstTickOfBar check out of the BarsInProgress one...

              Code:
              if (BarsInProgress == 1)
                  if (FirstTickOfBar)
              {
              do some trades
              }

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                Hi roonius, FirstTickOfBar should work for multiple symbols.

                Did you try moving the FirstTickOfBar check out of the BarsInProgress one...

                Code:
                if (BarsInProgress == 1)
                    if (FirstTickOfBar)
                {
                do some trades
                }
                Bertrand,
                Yes I have tried that and I get same results

                Comment


                  #9
                  I'm out of ideas here roonius, sorry. But I can test this on my end if you like, please forward me the strategy zip to support at ninjatrader dot com Attn Bertrand - Thanks!

                  Comment


                    #10
                    Originally posted by NinjaTrader_Bertrand View Post
                    I'm out of ideas here roonius, sorry. But I can test this on my end if you like, please forward me the strategy zip to support at ninjatrader dot com Attn Bertrand - Thanks!
                    Email sent
                    Thanks in advance

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    633 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    364 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    105 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    567 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    568 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X