Announcement

Collapse
No announcement yet.

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 pdennis, Today, 07:43 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by NinjaTrader_Brandon, Today, 07:49 AM
        0 responses
        9 views
        0 likes
        Last Post NinjaTrader_Brandon  
        Started by b16_aln, Today, 05:15 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Negustrader, Today, 01:01 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by soon123, Yesterday, 10:50 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Working...
        X