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

Accessing Cross Over Value for Stochastics

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

    Accessing Cross Over Value for Stochastics

    Hi guys,

    I'm sure this is something stupid simple but I can't seem to figure it out. I'm using CrossAbove (or CrossBelow) that lets me know that a Cross-over has occurred. I'm checking this cross-over 1 bar ago to be sure that the cross-over existed for sure. And I'm cool with this.

    However I now have a need to get the exact value at the cross-over point. How is this possible?

    #2
    Maybe something like this would work:

    if (CrossAbove(StochInd.K, Threshold, 1))
    Print (StochInd.K[1]);

    Assuming StochInd is your instance and Threshold is your defined Stochastic Threshold.

    Comment


      #3
      Thank you! I’ll give it a shot and report back

      Comment


        #4
        I used ".D" as the Threshold since I'm looking for a CrossOver between .K and .D and the result give me the value of %K at the close of the previous bar (which makes sense since I'm asking it to give me the value at [1]. That's close but still not close enough. In the attached image you'll see the Output Window showing a value of 90.53... whereas I'm looking for something closer to 88.57 (Where the actual CrossOver occurs).

        Attached Files

        Comment


          #5
          I have Tick Replay and Calculate.OnEachTick setup so I suppose the closest I could get to a real answer using this method is if I had a lookback period of 1 tick (rather than 1 bar).

          Not sure if I'm missing something but would this be a feature request? i.e. a high resolution lookback? Or maybe a different approach to a solution?

          Comment


            #6
            Hello Bluebeep,

            The look back period is how many bars back can a cross have occured within. This is because we are comparing the current value of each series with the previous bars value.

            In real-time this means that a cross can occur multiple times within a single bar and the condition would evaluate as true multiple times while that bar is open. This is the same with Tick Replay and Calculate.OnEachTick.

            The action would be triggered at the moment the cross occurs and any values of any series would be the values at that exact moment when the cross occurs (and would not be the final values of that bar once that bar is actually closed).
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            19 views
            0 likes
            Last Post algospoke  
            Started by ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            45 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            181 views
            0 likes
            Last Post jeronymite  
            Working...
            X