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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    60 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    145 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    283 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X