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 kujista, Today, 06:23 AM
        0 responses
        1 view
        0 likes
        Last Post kujista
        by kujista
         
        Started by traderqz, Yesterday, 04:32 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by f.saeidi, Today, 05:56 AM
        1 response
        4 views
        0 likes
        Last Post Jltarrau  
        Started by Jltarrau, Today, 05:57 AM
        0 responses
        4 views
        0 likes
        Last Post Jltarrau  
        Started by Stanfillirenfro, Yesterday, 09:19 AM
        7 responses
        53 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X