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:	40
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 rubiijonson, Today, 01:02 AM
    0 responses
    4 views
    0 likes
    Last Post rubiijonson  
    Started by fkronloff, Today, 12:25 AM
    0 responses
    3 views
    0 likes
    Last Post fkronloff  
    Started by Zadomani, Yesterday, 11:39 PM
    0 responses
    11 views
    0 likes
    Last Post Zadomani  
    Started by ToNovy, 01-27-2025, 11:22 PM
    20 responses
    197 views
    0 likes
    Last Post ToNovy
    by ToNovy
     
    Started by hypercube, 03-07-2025, 12:22 AM
    2 responses
    38 views
    0 likes
    Last Post hypercube  
    Working...
    X