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

Updated Fractals indicator by Bill Williams - Upper/Lower index issue in strategy?

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

    Updated Fractals indicator by Bill Williams - Upper/Lower index issue in strategy?

    Thanks to Paul and Kane for updating the BWFractal indicator to make it more strategy friendly. Timing could not have been better. The updated indicator works perfectly as an indicator.

    However I have ruin into a minor issue when using this in a strategy, a strategy that simply checks various indicators when a fractal is confirmed. The strategy calculates on Calculate.OnBarClose; At that time I check the _fractal.Upper[3] or _fractal.Lower[3] for a non-zero value to see if a new pivot has formed. However when a pivot forms on screen when the 3rd bar after the pivot forms, is is actually the Upper/Lower[2] value that is set. Pls see the attachment. I am new to c#. I can decipher some of your logic - but struggle in the overall context of NT8.

    I can check for a value in the second position but that seems cheating. I would appreciate any insights and hopefully avoid/help others running into the same issue.

    Thanks in advance, Lex


    Click image for larger version

Name:	PAUL 2021-09-17_20-05-28.png
Views:	449
Size:	341.9 KB
ID:	1171479





    #2
    Hello grzltn,

    Thanks for your post and welcome to the NinjaTrader forums!

    Just to clarify, neither Kane nor I created the indicator. The indicator was originally created in NinjaTrader7 by forum member Gains who is likely no longer around the forums. When NinjaTrader8 was created we (the ninjascript support team) converted most of the forum indicators, strategies, and misc files to work with NinjaTrader8. We do not necessarily understand the logic of what we convert.

    If you can pull the value from 2 bars ago and it matches what the fractal value is then you should be good to go.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul. Thing is that the indicator inherits the Calculate.OnBarClose from the strategy. If one uses the other Calculate options it actually uses the 3rd Upper/Lower and create unpredictable results. I had hoped you may have a clue on how to fix this. Or perhaps now this is posted another member with subject matter expertise with ideas on how to solve as the indicator is pretty versatile? Thank you for the very prompt response!

      Comment


        #4
        Hello grzltn,

        Thanks for your reply.

        When you are checking for a fractal on historical data OR are running the strategy with Calculate.OnBarClose, then you can reference [3] for the fractal. When you are running the strategy with Calculate.OnpriceChange or Calculate.OnEachTick AND are on live (or playback with market replay data) then you would use [2].

        You could use check of the "state" to set the bars ago to use, for example

        myBarsAgo = 3;

        if (State == State.RealTime)
        {
        myBarsAgo = 2;
        }


        BwFractal.Upper[myBarsAgo]

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello grzltn,

          Looking at this further, I don't see any reason why you would not be able to use [2] for both historical and real time.

          Try printing out the fractal values, on each bar, of the currentbar[0], and [1] and [2] and [3] to confirm.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Thanks again Paul - and a good approach. I worked out it is not the indicator but the business logic in NT8. For the OnBarClose status is as stated "on the completion of the bar" - and not the RHS bar still in formation. For the OnBarClose, bar[0] is the actually second one from the right. Definitely a trap for new players!! So your recommendation is perfect as using this approach ensures that business logic is preserved when the strategy setting is updated. Definitely a trap for new players!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            26 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, Yesterday, 09:53 PM
            2 responses
            49 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            192 views
            0 likes
            Last Post Hasadafa  
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,234 views
            0 likes
            Last Post xiinteractive  
            Working...
            X