I am working on an indicator to draw lines based on user input bool variable, bool can remain true for n number of bars so how can I store current bar to int saveBar only when bool was changed to true from false. Any help is appreciated!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to save Current Bar based on bool variable ?
Collapse
X
-
How to save Current Bar based on bool variable ?
Hello,
I am working on an indicator to draw lines based on user input bool variable, bool can remain true for n number of bars so how can I store current bar to int saveBar only when bool was changed to true from false. Any help is appreciated! -
Hello s.kinra,
Thanks for your post.
A typical user input would be a read-only type of input so it would only be changed by the user.
The user would change this input when the script is applied and would not change states after that.
To answer your question though, you would need another bool variable (internal variable) that matches the current state of the bool of interest and when the two bools are different is when the change occurs and when you could save the current bar.
if (userBool != myinternalbool)
{
savedBar = CurrentBar;
myinternalbool = userBool;
}
-
Hello Paul,
Let me share a test script for better clarity, what exactly I need is the Bar Index when the user bool is set to true so that I can fix the start anchor of Ray.Attached Files
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment