Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy stays YELLOW for hours

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

    Strategy stays YELLOW for hours

    Could any one please share your fix with strategy being YELLOW? I am having to wait for my strategies for hours to get to GREEN State.

    I am using a temporary work around: When I have to exit a postion in the middle of an executing strategy, I close my position by dragging and dropping the profit target below the current price from within the chart. Even after this the strategy sometimes goes YELLOW and stays YELLOW for long time.

    Note: I would not want to use the option: Immediately submit live working historical orders - This is similar to just using manual ATM.

    From the order trace log...it appears that it is trying to close the OCO orders and/or looking for a matching close that were opened when I entered a position via strategy.

    Does anyone know a manual way of setting the position state to FLAT? May be a back door in the log or db?

    #2
    If you want your strategy to operate immediately, you would want 'immediately submit live working historical order' Can you please clarify what behavior this option introduces that you do not want?

    Alternatively you can add a check at the beginning of the code to prevent the strategy from calculating historical orders - http://www.ninjatrader.com/support/h...historical.htm

    Code:
    if (Historical)
    return;
    MatthewNinjaTrader Product Management

    Comment


      #3
      Q1. When should we use "if Historical return;" in the code? I am using SIM101 connected with ZenFire and IB from two different machines. "if (Historical) return;" just does not go anywhere as per its function. I print from within the if Historical and it is always true.

      "Can you please clarify what behavior this option introduces that you do not want?"
      When setting 'immediately submit live working historical order' from options
      The strategy turns green.
      The chart displays open OCO orders and position stays flat in the chart.[in the options however, the entry and exit orders are checked to cancel when strategy is disabled]
      The strategies tab's Position, Avg Price and Unrealized shows the last open position values.
      The Positions Tabs do not show any position open.

      Q2. Does 'immediately submit live working historical order' option calculates/checks the entry conditions in the strategy before submitting order?
      Last edited by mypkonline; 08-13-2012, 12:57 AM.

      Comment


        #4
        Hello mypkonline,
        1. Please append the code just below the OnBarUpdate() method.

        Code:
        protected override void OnBarUpdate()
        {
           if (Historical) return;
           //rest of your code
        }
        2. Yes, it will check for the entry condition. Please refer to our help guide to know more about it.

        When starting a NinjaScript strategy that relies on historical data for calculating its current position and orders states, it will immediately submit live any working orders that reflect the current strategy's overall order state. It is IMPORTANT to understand that the position of the strategy reported in the Strategies tab may not reflect the actual account-based position reported in the Accounts tab at the time the strategy is started. In this scenario, it is highly recommend that the account position be synced to the strategy position.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Hi Joydeep,
          Thank you for replying, unfortunately, your suggestion does not help resolve the issue. I am going in circles for the past two weeks and have tried all I was told or found.

          The issue is a working strategy, that was working during a session, takes hours to re-sync itself or to find a FLAT state. What could be wrong? What is the max time a strategy should take to change its state to FLAT?

          Your suggestion # 1 - This only skips the execution of the code below return. This does not help speed up changing to state FLAT, does it?

          Since last night I have same strategy sitting there in YELLOW state with "YM 09-12" selected as instrument. However, same code on same machine selected with "CL 09-12" as instrument has been running since last night without any issue.

          There is got to be a way of syncing it faster?

          Please help!

          Order Trace::::::
          8/7/2012 4:23:00 AM Entered internal PlaceOrder() method at 8/7/2012 4:23:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
          8/7/2012 8:45:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Price Value=13111 Currency=0 Simulated=True
          8/7/2012 8:45:00 AM Amended stop order: Order='NT-00004/Sim101' Name='Stop loss' State=Working Instrument='YM 09-12' Action=Sell Limit price=0 Stop price=13111 Quantity=1 Strategy='LongV8' Type=Stop Tif=Gtc Oco='NT-00002-190' Filled=0 Fill price=0 Token='ee895d4311d043d6b094dab450a9fcf7' Gtd='12/1/2099 12:00:00 AM'
          8/7/2012 8:48:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00005/Sim101' Name='Profit target' State=Working Instrument='YM 09-12' Action=Sell Limit price=13159 Stop price=0 Quantity=1 Strategy='LongV8' Type=Limit Tif=Gtc Oco='NT-00002-190' Filled=0 Fill price=0 Token='4b8fddc264694955a36c83b52cb419ce' Gtd='12/1/2099 12:00:00 AM'
          8/7/2012 8:48:00 AM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00005/Sim101' Name='Profit target' State=Cancelled Instrument='YM 09-12' Action=Sell Limit price=13159 Stop price=0 Quantity=1 Strategy='LongV8' Type=Limit Tif=Gtc Oco='NT-00002-190' Filled=0 Fill price=0 Token='4b8fddc264694955a36c83b52cb419ce' Gtd='12/1/2099 12:00:00 AM'
          8/7/2012 8:49:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:50:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:51:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:52:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:53:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:54:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:55:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:56:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False
          8/7/2012 8:57:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=50 Currency=0 Simulated=False

          Comment


            #6
            Hello mypkonline,
            When the strategy will go FLAT will depend on your strategy. Unless your strategy shoots an exit/close command your strategy wont be flat.

            Yes, if Historical then return, will help since your strategy wont submit any order in the historical bars. Thus the strategy will be flat whenever you initialize it.

            I would suggest to pull down the strategy (which is still in yellow state), modify the code and then reinitialize it again.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              I am giving it a try.............Thanks!

              Comment


                #8
                I have given it a try and ran the strategy all day with the code
                Code:
                                if (Historical)
                                    PrintWithTimeStamp("Historical");
                                    return;
                The strategy has been GREEN, however, it has not taken a single position from 9:28AM till 4:15PM.

                I am using ZenFire's feed and using SIM101 account. What could be wrong now? Could you please check the code?

                This same code works fine without Historical and when it is in GREEN state. I use 5 copies of this strategy on a single machine running 5 different instruments. i.e. TF, CL, QM, YM and ES and works fine only when it is GREEN. When it turns YELLOW then it stays YELLOW for hours. Please, help!

                My Initialize looks like this:

                Code:
                        #region Initialization Functions
                         protected override void Initialize()
                         {
                             
                             SetStopLoss("",CalculationMode.Ticks, stopLossTicks, true);
                             SetProfitTarget(CalculationMode.Ticks, profitTargetTicks);
                             CalculateOnBarClose = false;
                             ExitOnClose = false;
                             
                             //Debugging
                             TraceOrders        = true; 
                         }
                         #endregion

                My Entry looks like this:

                Code:
                            #region Enter Trades
                             // LongEntry
                             if (Position.MarketPosition == MarketPosition.Flat && CurrentBar > BarTraded)
                              {
                             //RSI, STOC, MACD, EMA all up
                                 if ((RSI(14,3)[0] >= RSI(14,3).Avg[0] || Rising(RSI(14,3)))
                                     && (Stochastics(3, 14, 3).K[0] >= Stochastics(3, 14, 3).D[0] || Rising(Stochastics(3, 14, 3).K))
                                     && (MACD(12, 26, 9)[0] >= MACD(12, 26, 9).Avg[0] || Rising(MACD(12, 26, 9)))
                                     && Rising(EMA(9))
                                     && Rising(EMA(20))
                                     && Rising(ADX(14))
                                     && GetCurrentBid() > High[1]
                                    )
                                 {
                                     
                                     PrintWithTimeStamp("***"+Instrument.FullName+"**********ENTER LONG********"+Count++);
                                     if (BarsSinceExit() > 5 || BarsSinceExit() == -1)                    
                                     EnterLong();
                                     BarTraded = CurrentBar;
                                 }
                 
                             }
                             #endregion

                Comment


                  #9
                  Your return; is not under any condition, which is returning the entire OnBarUpdate method.

                  Please try putting these two functions in brackets to ensure it is not returning code you do not want to return on

                  Code:
                                  if (Historical)
                  {
                                      PrintWithTimeStamp("Historical");
                                      return;
                  }
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    lol...........just a little ignorance from my part. Working fine. Thanks!

                    C# usually works without {} and takes the colon as terminator of the condition but I guess does not work with return;

                    Thank you Matthew and thank you Joydeep.
                    Last edited by mypkonline; 08-13-2012, 10:01 PM. Reason: correcting the sentence

                    Comment


                      #11
                      Originally posted by mypkonline View Post
                      lol...........just a little ignorance. Working fine. Thanks!

                      C# usually works without {} and takes the colon as terminator of the condition but I guess does not work with return;

                      Thank you Matthew and thank you Joydeep.
                      Hi mypkonline,
                      You are only partially right about the ; or the {}
                      If you have only one statement after the 'if', then it would work. But in your case, you have 2 statements, so without the {}, only the first statement after the 'if' would be executed if the condition is met.
                      Last edited by kedar; 08-13-2012, 09:50 PM.

                      Comment


                        #12
                        How would you do this in the strategy wizard (rising and falling?) and can we do the bars it looks back on lets say if im long and i want to exit on 2 bars of falling ATR. How would i do that

                        Comment


                          #13
                          Hello cameo86,

                          Thank you for your post.

                          We actually have a reference sample that details how to setup Rising and Falling conditions in the Strategy Wizard. you may view this reference sample at the following link: http://www.ninjatrader.com/support/f...ad.php?t=19384

                          Please let me know if you have any questions.

                          Comment


                            #14
                            chart color sync

                            the color matching of sync ing chart at top right is mal functoning.Cant label a chart red yellow etc

                            Comment


                              #15
                              Hello laredo,

                              Thank you for your post.

                              Please send your log and trace files so I may investigate this matter further.

                              You can do this by going to the Control Center-> Help-> Mail to Support.

                              Please place 'ATTN: Patrick - 693131' in the subject line and a reference to this thread in the bosy of the e-mail: http://www.ninjatrader.com/support/f...ad.php?t=51794

                              I look forward to assisting you further.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post cmtjoancolmenero  
                              Started by Stanfillirenfro, 04-22-2024, 09:19 AM
                              7 responses
                              59 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by olisav57, Yesterday, 07:39 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by cocoescala, 10-12-2018, 11:02 PM
                              7 responses
                              942 views
                              0 likes
                              Last Post Jquiroz1975  
                              Started by oviejo, Today, 12:28 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X