• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 bomanpbm, Today, 09:27 PM
        0 responses
        1 view
        0 likes
        Last Post bomanpbm  
        Started by tgn55, Today, 08:47 AM
        0 responses
        8 views
        0 likes
        Last Post tgn55
        by tgn55
         
        Started by ballboy11, 05-04-2019, 10:26 AM
        6 responses
        58 views
        0 likes
        Last Post Kermit
        by Kermit
         
        Started by mrlucky1x, Yesterday, 10:01 PM
        0 responses
        15 views
        0 likes
        Last Post mrlucky1x  
        Started by roger556, Yesterday, 09:22 PM
        0 responses
        8 views
        0 likes
        Last Post roger556  
        Working...
        X