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

How to use Swing indicator with multiple time frames

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

    How to use Swing indicator with multiple time frames

    Hi.

    I try to write a strategy that use two different range bar series. The primary is 8 tick range bars and second is 2 tick range bars. I want to run Swing() indicator only with 8 tick range bars. I know that this can be done by checking (BarsInProgress == 0) in OnBarUpdate(), then call Swing(n)... The Swing will automatic use primary bar data series.

    What I need to know is when (BarsInProgress == 1), how do I call
    Swing(??,n).... with primary bar series?

    I checked the NT online manual for Swing() indicator. It has two formats:

    Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)
    Swing(IDataSeries inputData, int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)

    How to use the second format? Please help.

    Regards,
    JD

    #2
    Hi jdz1247,

    Depending on the overload you choose, a few options...

    1. You can pass in, for example Closes[0] for the "IDataSeries inputData"
    More info at - http://www.ninjatrader-support.com/H...ameInstruments

    2. You can use BarsArray[0] in an overload that doesn't accept a dataseries.
    More info at - http://www.ninjatrader-support.com/H...html?BarSeries
    TimNinjaTrader Customer Service

    Comment


      #3
      jdz,


      Have you used Swing before? It very non-standard to use. It redraws and is pretty funky to program with. To use it you will probably need to build a referencable series within the indicator.

      double test = Swing(Closes[0],12).SwingHigh[10];

      double test = Swing(Opens[0],12).SwingHigh[10];

      double test = Swing(Highs[0],12).SwingHigh[10];

      All of the above will work in calling the primary bar Close/Open/High because you are missing the second [] part for Closes[][] etc. Note it is Closes with an 's'. The first index is the bar in progress index. Take a look at the SMA calls in SampleMultiTimeFrame for BarsArray examples, but you can change all of those out with Closes[0] or whatever you need. I think Closes[idx] is the better choice here, but both work...

      Comment


        #4
        I agree with Mountainclimber,

        The existing Swing indicator seems to have been written with the focus more on retrospective visual analysis rather than for use in strategies.
        The updating of historical bars makes Swing appear more useful for real-time decisions than it really is.
        It also makes debugging more tricky.
        It would be useful to be able to tell at a glance whether or not an indicator updates historical bars.
        Perhaps NT should consider introducing (in NT8?) a boolean flag for indicators (say HistoricalBarUpdateAllowed=false). If HistoricalBarUpdateAllowed=false then attempting to set the value of a previous bar in a public IDataSeries would fail.
        Programmers could quickly see whether an indicator updated history by checking the flag.
        When writing strategies programmers would tend to choose indicators with HistoricalBarUpdateAllowed=false.
        Has anyone written a version of Swing that does not update history?
        It would not look so pretty on the chart, but would be a better reflection of trading reality, and more useful to strategies.

        Comment


          #5
          I've written many indicators that are similar to swing and some repaint and some don't (repaint is jargon for indicators that have look-ahead bias or reference and change historical values). The problem is that you have to either a) wait quite long before you have enough info to determine (with any accuracy) that peak or valley was established, b) repaint misplotted/inaccurate peaks and valleys. In the end, it is more useful to plot them early then repaint them as you get more data/bars, otherwise the plots are useless/inaccurate later.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rexsole, Today, 08:39 AM
          0 responses
          4 views
          0 likes
          Last Post rexsole
          by rexsole
           
          Started by trilliantrader, Yesterday, 03:01 PM
          3 responses
          30 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          4 responses
          26 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Brevo, Today, 01:45 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by rjbtrade1, 11-30-2023, 04:38 PM
          2 responses
          74 views
          0 likes
          Last Post DavidHP
          by DavidHP
           
          Working...
          X