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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    46 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    14 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X