Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bool not working

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

    bool not working

    Hello,
    Wondering if anyone has an answer to this. I've set a bool flag and it doesn't seem to be working. My code is this:

    CurrentPrice = Close[0];

    if (Low[0] == High[0]- (Bars.Period.Value*TickSize)&& Position.MarketPosition == MarketPosition.Flat && Trade)
    EnterLongLimit(
    0,true,DefaultQuantity, Low[0] - 1 * TickSize, "");

    if(FirstTickOfBar && CurrentPrice < Low[1] )
    Trade =
    false;

    My strategy is soposed to place a limit order once a rangebar has completed it's range. The order is 1 tick below the completed range bar. The problem is that, left alone, the order will be amended by the condition if not filled by the time the new range bar has completed it's range.
    I set a bool flag to the condition and called it "trade". I then set "trade" to false if the CurrentPrice was less than low of the previous bar. 1 tick less than the low[1] is my order price. I figured that once my order price was hit I didn't want the order to amend any more. Unfortunately the flag isn't working and the order continues to amend before I get filled.
    Can anyone give me a suggestion as to why this is?
    Thanks,
    Rick

    #2
    Rick,

    Is CalculateOnBarClose=True an option for you as this would eliminate the need for a bool flag.

    Also, I believe Trade may be a reserved word, please change the name of this bool to see if this resolves the issue.

    If it does not I will need to take a look at the full code and see how you are setting the bool flag to True agian as this could be where the error is.

    If you are note conftorable posting this to the forum please send a note to support at ninjatrader dot com and reference this forum post and put ATTN: Brett in the subject line.

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    575 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X