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 gravdigaz6, Yesterday, 11:40 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Yesterday, 10:49 PM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by XXtrader, Yesterday, 11:30 PM
        0 responses
        4 views
        0 likes
        Last Post XXtrader  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Yesterday, 09:43 PM
        0 responses
        9 views
        0 likes
        Last Post funk10101  
        Working...
        X