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 DJ888, Today, 10:57 PM
        0 responses
        1 view
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        158 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Today, 09:29 PM
        0 responses
        7 views
        0 likes
        Last Post Belfortbucks  
        Started by zstheorist, Today, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        151 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Working...
        X