View Full Version : Once Per Session
a2vwnick
12-06-2007, 01:32 PM
I am looking for a way to only execute my strategy once per session. Once the first signal gets executed (on a stop entry) I want it to wait until the next session. Any nice way to do this?
NinjaTrader_Ray
12-06-2007, 01:44 PM
You would need to declare an internal variable.
private bool triggeredThisSession = false;
then wherever you have strategy logic that enters a position such as OnBarUpdate()
if (FirstBarOfSession)
triggeredThisSession = false;
if (myCondition == true)
{
EnterLong();
triggeredThisSession = true;
}
http://www.ninjatrader-support.com/HelpGuideV6/FirstBarOfSession.html
a2vwnick
12-06-2007, 02:04 PM
Well I think the problem with that is since I want to enter on a stop, once the bar closes it will cancel the stop and there will never be an entry.
NinjaTrader_Ray
12-06-2007, 02:09 PM
Then I would suggest a different approach and use Position.MarketPosition property to change the value of the "triggeredThisSession" variable.
a2vwnick
12-06-2007, 02:31 PM
Thanks that did it. I could have sworn I looked at marketposition before.