Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

question about flags

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

    question about flags

    From a previous suggestion, I use a "Flag" in a strategy. This way if a condition is met but maybe is no longer current, the next condition will trigger a trade.

    My concern is I watched some sim trading in realtime, and it seems another signal was not taken. This makes me wonder if my flag will get reset for sure no matter how an exit is handled. Also, if I put the flag reset in the right location (i.e. after a trade is taken, it should also reset the flag, so that if or when this trade is finished, I can take another one later).

    Here is the code, if you good folks have any suggestions let me know.

    // Condition set 1
    if (Close[0] < SMA(SMA200period)[0] && (Position.MarketPosition == MarketPosition.Flat)
    && CrossAbove(SMA(5), SMA(SMA20period), 1))
    AFlag = true;


    {
    if (Close[0] < SMA(SMA200period)[0] && (CrossBelow(Stochastics(PeriodD, PeriodK, Smooth).K, TopLine, 1)
    && AFlag == true))

    {
    EnterShort(Entry2target, "Entry2TargetSIGNALNAME");
    EnterShort(Entry8target, "Entry8TargetSIGNALNAME");
    AFlag = false;
    }

    }


    Is that "AFlag=false" in the right location and right syntax?

    #2
    Yes, that is the proper syntaxing. The location should be correct, but you will have to see for yourself when you test it.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    582 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    338 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X