Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Resetting the Swing High/Low Indicator on New Session

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

    Resetting the Swing High/Low Indicator on New Session

    Time for my daily post on here.....

    I have a problem where it seems a signal is being triggered early in a session by reference to the swing high or low of a previous session if one hasn't formed yet during this session.

    Does anyone have any ideas how I can address this?

    Thanks

    Mark

    #2
    Hi Mark,

    Using Swing as a condition for entry will generally be challenging for this reason. When you're looking at historical swing values, these are actually generated by future values, causing a discrepancy with what you see on the chart compared to what is available programatically. You may get better results basing trade conditions on indicators that only have a historical lookback, rather than repainting ones like swing.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan

      I have not explained it clearly enough.

      I'm not using the swing indicator for entry it is used for exit.

      What is happening however is when a trade is entered into (short for example), if the price is higher than the last swing high (which was last session) it sends a signal to exit the trade. As it happens the exact same time as the entry, the trade does not exit but i'm just concerned that in theory it could.

      Is there anyway round this?

      Comment


        #4
        Mark, I believe you could use the High and Low bar methods of the Swing indicator here as workaround to check to how long back this Swing point was found and then not submit the exit if it's one from the prior day / session.

        Comment


          #5
          Could you write a brief example please Bertard?

          Many thanks

          Mark

          Comment


            #6
            I would unfortunately not have a code snippet handy, but the methods you would need to work with are shown here - http://www.ninjatrader.com/support/h.../nt7/swing.htm

            Comment


              #7
              I'm still having problems with this unfortunately.



              I entered into a trade yesterday. At 99.40 on the CL contract. A swing low exit was triggered straight away despite the swing low being aproximately $1 below.

              The output log is as follows:


              03/06/2011 14:51:00 Entered internal PlaceOrder() method at 03/06/2011 14:51:00: BarsInProgress=0 Action=Buy OrderType=Market Quantity=5 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              03/06/2011 14:51:00 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=0 Currency=2125 Simulated=False
              03/06/2011 14:51:00 Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=0 Currency=12500 Simulated=False
              03/06/2011 14:52:00 Aup Entry


              03/06/2011 14:51:00 Entered internal PlaceOrder() method at 03/06/2011 14:51:00: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              03/06/2011 14:51:00 Ignored PlaceOrder() method: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
              03/06/2011 14:52:00 Exit Long Swing

              03/06/2011 14:51:00 Entered internal PlaceOrder() method at 03/06/2011 14:51:00: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              03/06/2011 14:51:00 Ignored PlaceOrder() method: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
              03/06/2011 14:52:00 Exit Long Swing

              03/06/2011 14:51:00 Entered internal PlaceOrder() method at 03/06/2011 14:51:00: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              03/06/2011 14:51:00 Ignored PlaceOrder() method: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
              03/06/2011 14:52:00 Exit Long Swing

              **NT** Stop/target handling for strategy 'ACD' set to 'ByStrategyPosition' since currency based stop order was placed.
              03/06/2011 14:51:01 Amended stop order: Order='90cf29ad52cb402e8a98537052bd963a/U653374' Name='Stop loss' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=0 Stop price=98.93 Quantity=2 Strategy='ACD' Type=Stop Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='5fa008d2380a4f27b5f040955d41f9b1' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Amended target order: Order='f5a86c45e13242e18d81fbd98c9af4d8/U653374' Name='Profit target' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=101.85 Stop price=0 Quantity=2 Strategy='ACD' Type=Limit Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='a18d23bb67b3453d9e3980f0ab65ac47' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Amended stop order: Order='90cf29ad52cb402e8a98537052bd963a/U653374' Name='Stop loss' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=0 Stop price=98.92 Quantity=3 Strategy='ACD' Type=Stop Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='5fa008d2380a4f27b5f040955d41f9b1' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Amended target order: Order='f5a86c45e13242e18d81fbd98c9af4d8/U653374' Name='Profit target' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=101.85 Stop price=0 Quantity=3 Strategy='ACD' Type=Limit Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='a18d23bb67b3453d9e3980f0ab65ac47' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Amended stop order: Order='90cf29ad52cb402e8a98537052bd963a/U653374' Name='Stop loss' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=0 Stop price=98.93 Quantity=4 Strategy='ACD' Type=Stop Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='5fa008d2380a4f27b5f040955d41f9b1' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Amended target order: Order='f5a86c45e13242e18d81fbd98c9af4d8/U653374' Name='Profit target' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=101.85 Stop price=0 Quantity=4 Strategy='ACD' Type=Limit Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='a18d23bb67b3453d9e3980f0ab65ac47' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Amended stop order: Order='90cf29ad52cb402e8a98537052bd963a/U653374' Name='Stop loss' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=0 Stop price=98.93 Quantity=5 Strategy='ACD' Type=Stop Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='5fa008d2380a4f27b5f040955d41f9b1' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Amended target order: Order='f5a86c45e13242e18d81fbd98c9af4d8/U653374' Name='Profit target' State=PendingSubmit Instrument='CL 07-11' Action=Sell Limit price=101.85 Stop price=0 Quantity=5 Strategy='ACD' Type=Limit Tif=Gtc Oco='CL 07-11/0000e9a5.4de838b7.01.01-20' Filled=0 Fill price=0 Token='a18d23bb67b3453d9e3980f0ab65ac47' Gtd='01/12/2099 00:00:00'
              03/06/2011 14:51:01 Entered internal PlaceOrder() method at 03/06/2011 14:51:01: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              03/06/2011 14:52:00 Exit Long Swing
              The relevant code is as follows:

              Code:
                    
              
              if (GetCurrentAsk() < Swing(5).SwingLow[0] - (OffsetS * TickSize)
                              && Avalue == 1)
                              
                          {
                          ExitLong();
                              Print("Exit Long Swing Low exit");
                          }
              Obviously the swing values are higher that they should be. How can I track/print the SwingLow value maybe on each new bar?

              Thanks

              Mark



              Comment


                #8
                Can anyone help with this please?

                Comment


                  #9
                  Whether you're using swing as conditions for entry or exit is pretty much the same. The value accessed programatically varies from what you see visually, as discussed earlier. You should generally not use swing in automated strategies.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_RyanM View Post
                    Whether you're using swing as conditions for entry or exit is pretty much the same. The value accessed programatically varies from what you see visually, as discussed earlier. You should generally not use swing in automated strategies.
                    Understand what you are saying Ryan but whether it differs from whats shown on the chart is irrelevant really.

                    Using the swing indicator is a key part of my strategy. Without it, I don;t have a strategy and therefore the need to continue paying your subscription.

                    It works fine when back tested (irrespective of if it differs from the charts). I need to know how it is working during live trading and therefore need to print the SwingLow and SwingHigh values to the output window. To see what is going on. How can I do this at regular intervals say on the start of a new bar. (bear in mind I have the strategy set up as CalculateOnBarClose = False)

                    Many thanks

                    Mark

                    Comment


                      #11
                      You can Print the current value of Swing highs and lows. If you want to check on the start of a bar you can use FirstTickOfBar when using COBC = false.


                      if (FirstTickOfBar)
                      Print(Swing(3).SwingHigh[0]);

                      When you look at the same bar historically it will not necessarily be the same value. This indicator works great when you backtest because it has a forward bias.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_RyanM View Post
                        You can Print the current value of Swing highs and lows. If you want to check on the start of a bar you can use FirstTickOfBar when using COBC = false.


                        if (FirstTickOfBar)
                        Print(Swing(3).SwingHigh[0]);

                        When you look at the same bar historically it will not necessarily be the same value. This indicator works great when you backtest because it has a forward bias.
                        Great thanks.

                        Strangly it has worked fine today when traded using the sim account.

                        Comment


                          #13
                          Ryan - problem identified straight away!

                          According to the chart - the first SwingHigh of the session occured at 14.27 (GMT) at a high of $100.04. the first SwingLow at 14.02 (GMT) at $99.02.

                          These values are still showing up in the following (at 19.00 GMT):

                          Code:
                           
                          Print(Swing(10).SwingHigh[0]); and 
                          Print(Swing(10).SwingLow[0]);
                          So essentially all the succeeding SwingHigh and SwingLows have not updated from the original values. Do you have any idea why this might be?

                          Thanks




                          Comment


                            #14
                            The values has just changed @ 19.22 (GMT) to the second SwingHigh/Low which occured about 15.00 (GMT).

                            Comment


                              #15
                              According to the chart there about 8 Swing Highs and Lows after this...

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X