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

Pullback with CrossAbove/CrossBelow

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

    Pullback with CrossAbove/CrossBelow

    Hi,

    I´m trying to get this figured out, but no luck yet.
    I am trying to get (in this case) long trade to be triggered, when the price is first above EMA, after that price makes LOW, which is under EMA, and after that price gets up again and crosses above EMA. That´s where the trigger should be, the crossing.
    Strategy is calculating OnEachTick and all that mentioned above, should take place intrabar, during only one bar.
    I used few variables to narrow down the right place before the final trigger, here is that part of the code (little simflified):



    LongShort = (Open[0] - EMA1[0]); // Detects that the current bar has opened above EMA (positive value for LONGs)
    Low1 = (Low[0] - (EMA1[0]); // Detects if the low of current bar has reached value under EMA value (negative value for LONGs)


    if ((LongShort > 0)
    && (Low1 < 0))

    To this point all goes fine, and strategy detects these places.
    But if I add (CrossAbove(Close, EMA1, 1)) to the if statement, nothing happens. No trades are made.

    This action should be possible using CrossBelow/-Above?
    Any ideas what´s wrong with my logic?

    Thanks in advance!
    -Paroooni-

    #2
    Hello Paroooni,

    Thanks for your post and welcome to the NinjaTrader forums!

    For your intrabar cross-check why not check for the Close[0] > EMA1[0] ?

    if (LongShort >0 && Low1 < 0 && Close[0] >EMA1[0])
    {
    // entry order
    }
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      Thank you for that, seems to work ok!
      Maybe I was trying to think too complicated...

      Is that logic even possible with CrossAbove?
      My simple mind tells it should work like that, but maybe it needs something else to be added?

      Comment


        #4
        Hello Paroooni,

        Thanks for your reply.

        The crossabove/below condition would be looking for the previous bar to the EMA and then the current bar to the EMA for the determination of a cross, so it would not be looking at just the intrabar values.



        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Today, 06:40 PM
        0 responses
        9 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        7 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        7 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        168 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X