Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detecting Previous Red Bars - Not Working

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

    Detecting Previous Red Bars - Not Working

    I appreciate any help on this matter. I wanted to add text to the top of the candles if the previous bar is red. Currently this is the only thing the strategy does. But it randomly skips bars and I don't know why. The code is very simple. This is in BackTesting by the way.

    Questions:
    1) Why is it randomly skipping bars?
    2) Why does it always skip the first few bars of the day?


    Code:
            protected override void OnBarUpdate()
            {
                if (CurrentBar < BarsRequiredToTrade)
                    return;
            
                if (Close[1] < Open[1])  // RED BAR
                        Draw.Text(this, "R"+Bars.GetAsk(CurrentBar), "R", 0, High[0]+.01);​
    Click image for larger version

Name:	2025-02-06 18_00_04-Strategy Analyzer - Analyzer.png
Views:	107
Size:	56.4 KB
ID:	1333865

    #2
    Hello jerrod.davenport,

    Use unique tag names to create new drawing objects instead of moving existing drawing objects.

    With your code a drawing object at the same ask price will have a duplicate tag and will modify to move the existing object instead of generating a new object.


    Add CurrentBar to the tag name so this is unique for each new bar.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X