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

Can't Dial in Cross Above/Below Entry Condition

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

    Can't Dial in Cross Above/Below Entry Condition

    Hello Good People,

    I'm having issues using CrossAbove within my entry conditions for a short entry. What I want to see is price:
    1. CrossAbove myLevel - we'll call this Candle A
    2. And then, close below myLevel (can be candle A or next candle(s))
    3. Current Delta[0] < Delta [1]
    Works great sometimes, but other times the Close[1] condition counts the previous candle before the CrossAbove condition and enters me early. I've tried to insert a bool which turns true once the CrossAbove condition is made, but I'm still having the same issue.

    What is the best way to insure the CrossAbove condition happens first and then the Close[1] < myLevel happens next (never counting a candle as closed before CrossAbove is made)?

    I've tried different Look Back periods, but same issue. I'm sure it's simple but I'm not seeing it....

    Code:
    if  (CrossAbove(Close, myLevel, 5))
                                            
    {
         enableTrade = true; 
    }
                                        
     if   ((enableTrade == true) && (Close[1] < myLevel)
            && (cumulativeDelta.DeltaLow[0] < cumulativeDelta.DeltaLow[1]))
    {
    EnterShort()
    }
    ​
    Many thanks in advance for any guidance!

    #2
    Hello swjake,

    Thank you for your post.

    Based on your description, my understanding is that you would like the CrossAbove to happen on one candle, then you want to check the next condition on the following bar after the bar for the crossover occurred. To do this, you could save the bar index where the crossover condition becomes true, then check in your next condition if the current bar is greater than that saved bar number:
    Code:
    if (CrossAbove(Close, myLevel, 5))
    
    {
    enableTrade = true;
    savedCrossoverBar = CurrentBar;
    }
    
    if ((enableTrade == true) && (Close[1] < myLevel)
    && (cumulativeDelta.DeltaLow[0] < cumulativeDelta.DeltaLow[1]) && CurrentBar > savedCrossoverBar)
    {
    EnterShort()
    }​
    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thank you Emily!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ageeholdings, Today, 07:43 AM
      0 responses
      6 views
      0 likes
      Last Post ageeholdings  
      Started by pibrew, Today, 06:37 AM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      12 views
      0 likes
      Last Post burtoninlondon  
      Working...
      X