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 cmtjoancolmenero, Yesterday, 03:58 PM
        11 responses
        39 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        5 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        26 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X