Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How do I reset a variable at the start of each session?
Collapse
X
-
How do I reset a variable at the start of each session?
I want to run a strategy only once per session. I know I can use flags (variables) to limit # of runs but I want to reset variable at start of every session. How? Thanks for your help.Tags: None
-
You can work with with bools for this task and reset them on session break to allow triggering again, here's a pseudo code snippet you can change to fit your needs - this would for example to allow one trade to be done per day / session.
Code:// in your code variables section private bool canTrade = true; OnBarUpdate() { if (SessionBreak) canTrade = true; if (long trade conditions are met) { canTrade = false; EnterLong(...); } if (short conditions are met) { canTrade = false; EnterShort(...); }
BertrandNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by gleichnerany, Today, 01:17 AM
|
0 responses
2 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
||
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
44 views
0 likes
|
Last Post Today, 12:28 AM | ||
Started by f.saeidi, Today, 12:12 AM
|
0 responses
4 views
0 likes
|
Last Post
by f.saeidi
Today, 12:12 AM
|
||
Started by Conall, Today, 12:06 AM
|
0 responses
6 views
0 likes
|
Last Post
by Conall
Today, 12:06 AM
|
||
Started by proptradingshop, 03-21-2024, 09:50 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 12:02 AM |
Comment