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

Cross Above Question

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

    Cross Above Question

    I am having problems implementing a simple crossover strategy . What I am trying to do is to get the current close to crossabove the High from 2 bars ago . It is simple enough to do close[0] > high[2] but as soon as I try ;

    CrossAbove(Close,High[2], 1) it does not work . Could you let me know how I can do a crossabove signal but linking to a previous bars value.
    thanks,
    Tim

    #2
    Originally posted by raker22 View Post
    I am having problems implementing a simple crossover strategy . What I am trying to do is to get the current close to crossabove the High from 2 bars ago . It is simple enough to do close[0] > high[2] but as soon as I try ;

    CrossAbove(Close,High[2], 1) it does not work . Could you let me know how I can do a crossabove signal but linking to a previous bars value.
    thanks,
    Tim
    What is the error in your log? Search the forum on that message and you will see a plethora of posts telling you that you need to ensure that there are enough bars to do what you want to do, the first time that your calculation is done.

    In your particular case, you will need:
    Code:
    if (CurrentBars < 2) return;
    placed close to, if not at, the top of your OnBarUpdate() method.

    Comment


      #3
      Hi there,
      There is no error log , it just does not plot and the system shows no results , when I was over at Neoticker it was pretty straight forward in that you could access previous valueof data series in their equivilent of the crossover function :

      This is Neoticker's version

      Long_Signal:= if(xabove(C(0),H(2)),1,0);

      Any idea how I can do this on Ninjatrader.

      Comment


        #4
        Hello,

        Thank you for the post.

        I tried the condition you are questioning and do see that it is able to become true but did see that it was infrequent depending on the instrument and settings used.

        Could you try the following code from an Indicator to see if you are able to see the dots drawn? I had tested on the ES 12-16 1 minute chart.

        This test could at least confirm the condition is working, if it works in a test indicator but does not in the script you are working on it may be other logic playing a role as well.

        Code:
        if(CrossAbove(Close,High[2], 1))
        {
        	DrawDot("dot" + CurrentBar, true, 0, Close[0], Color.Orange);	
        }
        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Skifree, Today, 03:41 AM
        1 response
        2 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by usazencort, Today, 01:16 AM
        0 responses
        1 view
        0 likes
        Last Post usazencort  
        Started by kaywai, 09-01-2023, 08:44 PM
        5 responses
        603 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        6 responses
        23 views
        0 likes
        Last Post xiinteractive  
        Started by Pattontje, Yesterday, 02:10 PM
        2 responses
        22 views
        0 likes
        Last Post Pattontje  
        Working...
        X