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 Haiasi, 04-25-2024, 06:53 PM
|
2 responses
17 views
0 likes
|
Last Post
by Massinisa
Today, 05:32 AM
|
||
Started by Creamers, Today, 05:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Creamers
Today, 05:32 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
12 responses
1,786 views
0 likes
|
Last Post
by Leafcutter
Today, 05:30 AM
|
||
Started by poplagelu, Today, 05:00 AM
|
0 responses
3 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
||
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,407 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
Comment