Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Question about Swing Indicator

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

    Question about Swing Indicator

    Hi -- just a question about the Swing indicator.

    When I first connect to my data provider in the morning and open a new chart, the chart will show so-many 'days back' of data. If I have a Swing indicator on the chart, it will carry over the swing value from the day before. So that the following code will reflect the Swing value from yesterday if there is not a new Swing pivot for the current day yet:

    CurrentSH = Swing(Strength).SwingHigh[Strength];

    I would like to NOT have the previous day's Swing pivots carry over to the next day. I want each day to start with CurrentSH=0 until a new pivot is created in the current trading day (let's say since Midnight). Is there a way to do this in a strategy?

    Thanks!
    Bryan
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Not that I am aware of, you would have to code your own version of a swing indicator.
    RayNinjaTrader Customer Service

    Comment


      #3
      OK. Is there anything that would indicate which bar or date or time or something that Swing(Strength).SwingHigh[Strength] is based on? If not, then I think I can probably customize the Swing code to store that and keep it as a property maybe. Do you have an idea of how to code that? I'm not sure I can add a new property to an indicator or not.

      Something like Swing.SwingHigh.Bar or Swing.SwingHigh.Date.
      Last edited by cassb; 05-13-2008, 08:20 AM.
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        Something like -

        Time[Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)]

        Will return a DateTime object.
        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          Something like -

          Time[Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)]

          Will return a DateTime object.
          Excellent, Ray -- I'll play around with that, thanks!

          Bryan
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            Simple solution:

            Code:
                        if (ToDay(Time[Swing(5).SwingLowBar(0, 1, 100)]) == ToDay(Time[0]))  // Only evaluate swing value if set during the current trading session.
            cassb
            NinjaTrader Ecosystem Vendor - Logical Forex

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by RubenCazorla, Today, 09:07 AM
            2 responses
            11 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by i019945nj, 12-14-2023, 06:41 AM
            7 responses
            81 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by timmbbo, 07-05-2023, 10:21 PM
            4 responses
            158 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by tkaboris, Today, 08:01 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Lumbeezl, 01-11-2022, 06:50 PM
            31 responses
            819 views
            1 like
            Last Post NinjaTrader_Adrian  
            Working...
            X