Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Signals from the previous day triggering trades

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

    #16
    Hi Mark, then please try running the strategy with a TIF setting of DAY instead GTC - would that change your outcome seen?

    Comment


      #17
      Originally posted by NinjaTrader_Bertrand View Post
      Hi Mark, then please try running the strategy with a TIF setting of DAY instead GTC - would that change your outcome seen?
      I will give it a go tomorrow Bernard. What is strange though, if you look at the output window below, it is blank until the session begins, then you have the signals from yesturday and the order and entry is triggered as soon as the session begins, there is not a latent order from the previous day.

      I just don;t understand why I have to have a lookback at all, why can't I just apply the stategy on today only?

      Version:0.9 StartHtml: 105 EndHtml: 4091 StartFragment: 334 EndFragment: 4059
      **NT** Enabling NinjaScript strategy 'ACD/8f88c32f84f54166807e36966fe78ef4' : On starting a real-time strategy - StrategySync= WaitUntilFlat SyncAccountPosition=True EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=ByStrategyPosition ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Str ategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=True CancelExitOrdersOnDi sable=True MaxRestarts=4 in 5 minutes

      10/05/2011 14:03:00 OR High Established

      10/05/2011 14:12:00 Aup Established

      11/05/2011 14:00:00 Entered internal PlaceOrder() method at 11/05/2011 14:00:00: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 11/05/2011 14:00:00 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=0 Currency=425 Si mulated=False
      11/05/2011 14:00:00 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=0 Currency=2500 Simulated=False 10/05/2011 14:18:00 Aup Entry
      11/05/2011 14:00:00 Entered internal PlaceOrder() method at 11/05/2011 14:00:00: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''

      11/05/2011 14:00:00 Ignored PlaceOrder() method: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' F romEntrySignal='' Reason='This was an exit order but no position exists to exit'
      10/05/2011 15:39:00 Exit Long ATR

      11/05/2011 14:04:00 OR High Established

      Comment


        #18
        I just disabled and reenabled with the TIF set to day and the following happened:

        Version:0.9 StartHtml: 105 EndHtml: 4648 StartFragment: 334 EndFragment: 4616
        **NT** Enabling NinjaScript strategy 'ACD/013ccbeb9abc4f86b2ab0ea2b246f997' : On starting a real-time strategy - StrategySync =WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Str ategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=True CancelExitOrdersOnDi sable=True MaxRestarts=4 in 5 minutes

        10/05/2011 14:03:00 OR High Established
        11/05/2011 14:04:00 OR High Established
        11/05/2011 14:05:00 OR High Established
        11/05/2011 14:06:00 OR High Established

        11/05/2011 14:12:00 Adown Established

        11/05/2011 18:53:00 Entered internal PlaceOrder() method at 11/05/2011 18:53:00: BarsInProgress=0 Action=SellShort OrderType=Ma rket Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 11/05/2011 18:53:00 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=0 Currency=425 Si mulated=False 11/05/2011 18:53:00 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=0 Currency=2500 Simulated=False

        11/05/2011 14:18:00 Adown Entry
        11/05/2011 18:53:00 Entered internal PlaceOrder() method at 11/05/2011 18:53:00: BarsInProgress=0 Action=BuyToCover OrderType =Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''

        11/05/2011 18:53:00 Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalNa me='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
        11/05/2011 17:15:00 Exit Short ATR
        **NT** Stop/target handling for strategy 'ACD' set to 'ByStrategyPosition' since currency based stop order was placed.
        You can see it is entering historic orders when the it should not be.

        Very confusing!

        Comment


          #19
          Then the TIF change would likely not make a difference here - the question then remains : what about the code logic would result in a signal being issued here?

          The lookback needed is determined by MinBarsRequired, you can set this to 0 and then just roll the strategy forward.

          Comment


            #20
            Originally posted by NinjaTrader_Bertrand View Post
            Then the TIF change would likely not make a difference here - the question then remains : what about the code logic would result in a signal being issued here?

            The lookback needed is determined by MinBarsRequired, you can set this to 0 and then just roll the strategy forward.
            MinBarsRequired is currently set to 2. So would this look back 2 bars into the previos session at the start of a new one?

            The confusing thing is it works perfectly when backtested.

            Is there anyway of resticting when an entry happens from when the entry conditions are met? What appears to be happening is the code is running over the historic code and then entering positions because the conditions were set at some point in the past.

            Comment


              #21
              Hello MJUK10,

              Yes, this was the suggestion in Post #6.

              You can add if (Historical) return; to top line of OnBarUpdate() and it will exclude strategy processing on historical bars.
              Ryan M.NinjaTrader Customer Service

              Comment


                #22
                Originally posted by NinjaTrader_RyanM View Post
                Hello MJUK10,

                Yes, this was the suggestion in Post #6.

                You can add if (Historical) return; to top line of OnBarUpdate() and it will exclude strategy processing on historical bars.
                All ready added that Ryan as well as all the other suggestions and it had no effect.

                Comment


                  #23
                  This should do the trick.

                  Can you please send your code into support at ninjatrader dot com reference this forum post so we can make sure it is added correctly so it does not run on historical.

                  I look forward to assisting you further.
                  BrettNinjaTrader Product Management

                  Comment


                    #24
                    Thanks Brett

                    For some reason my virus software won't let me attach the code to my email. I have realised however the if(historical) function could be in the wrong place. I have a If(BarsinProgress==0) function at the top and the historical function was outside of the brackets for this function so this could be why it wasn't working? I have put the historic function inside the BarsinProgress fuctions brackets like so:

                    OnBarUpdate()

                    {

                    If (BarsInProgress==0)

                    {

                    If(Historical)
                    return;

                    REST OF THE CODE

                    }

                    Is this correct?

                    Thanks

                    Mark

                    Comment


                      #25
                      Mark, please just add this completely at the start of OnBarUpdate(), so not after your BIP check but before, then recheck please.

                      Thanks

                      Comment


                        #26
                        That is how it was originally and it had no effect.

                        Comment


                          #27
                          Do I have to enclose everything underneath the Historical statment with {} ?

                          Comment


                            #28
                            Please for example this simple HMA indicator example attached - you see it will only process realtime seen bars, no historical ones. It would be easiest if Print the CurrentBar and Time after the historical statement sitting at the top of your OnBarUpdate() method, this way you see exactly which bars are then processed by it after the Historical addition. It would also be important to apply a new strategy instance after editing / compiling changes in.
                            Attached Files

                            Comment


                              #29
                              Ok thanks Bernard.

                              I'll give it a go.

                              Cheers

                              Comment


                                #30
                                Bernard - how do I print currentbar?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                670 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                379 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                111 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                575 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                582 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X