Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to check for crossover at end of the bar

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

    how to check for crossover at end of the bar

    when i use this code to check crossover, it gets choppy as sometimes the crossover does not occur at end of the bar. how do i check for crossover so i can check at the end of the bar?

    if (CrossAbove(EMA(9), EMA(22), 1))
    {
    Draw.Text(this, "crossabove" + CurrentBar, "look for long", 1, Low[1]);

    }

    #2
    Hello junkone,

    Thanks for your post.

    If you are using Calculate.OnEachTick or Calculate.OnPriceChange then it is possible that during a forming bar you might get several cross and uncross conditions resulting in the drawtext being issued several times.

    You might try using the bool IsFirstTickOfBar as part of the condition set. The bool would only allow the crossover check once per bar, for example:

    Code:
    if (CrossAbove(EMA(9), EMA(22), 1) && IsFirstTickOfBar)
    { 
    Draw.Text(this, "crossabove" + CurrentBar, "look for long", 1, Low[1]);
    }
    Reference: http://ninjatrader.com/support/helpG...ttickofbar.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      would the firsttickofbar be processed the first tick of the new bar?

      Comment


        #4
        Hello junkone,

        That is correct.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ETFVoyageur, Today, 04:00 PM
        2 responses
        11 views
        0 likes
        Last Post ETFVoyageur  
        Started by dward123, 01-02-2024, 09:59 PM
        3 responses
        163 views
        0 likes
        Last Post bjunaid
        by bjunaid
         
        Started by AaronKTradingForum, Today, 03:44 PM
        1 response
        8 views
        0 likes
        Last Post AaronKTradingForum  
        Started by Felix Reichert, 04-26-2024, 02:12 PM
        11 responses
        77 views
        0 likes
        Last Post Felix Reichert  
        Started by junkone, 04-28-2024, 02:19 PM
        7 responses
        83 views
        1 like
        Last Post junkone
        by junkone
         
        Working...
        X