NexusFi: Find Your Edge


Home Menu

 





to get NT to perform an action only once while a strategy condition is true


Discussion in NinjaTrader

Updated
    1. trending_up 2,397 views
    2. thumb_up 4 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
richw's Avatar
 richw 
Salt Lake City, UT
Legendary Market Wizard in Training
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: CL, ES, NQ, YM
Posts: 1,917 since May 2010
Thanks Given: 2,318
Thanks Received: 1,621

...only once while a strategy condition it true? (Wait for the condition to be false and then take action only once when the condition turns true again.)


Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
OneChronos Launches First Combinatorial Auction FX Venue …
Currencies
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
The Feds Stagflation Trap -- Negative Payrolls, $91 Oil, …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #3 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 801


Untested but try something like this:

 
Code
#region Variables

privatebool myFlag = false; // Default setting for MyFlag

#endregion

protectedoverridevoid Initialize()
{
CalculateOnBarClose = true;
}

protectedoverridevoid OnBarUpdate()
{
if (historical) return;
if (Close[0] > Close [1] && myFlag == false)
{
Print(DateTime.Now + " It's going up!");
myFlag = true;
}
else myFlag = false;


}


Reply With Quote
Thanked by:
  #4 (permalink)
 
richw's Avatar
 richw 
Salt Lake City, UT
Legendary Market Wizard in Training
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: CL, ES, NQ, YM
Posts: 1,917 since May 2010
Thanks Given: 2,318
Thanks Received: 1,621

That should work nicely.


Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on February 28, 2011


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts