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 Mindset, 04-21-2026, 06:46 AM
|
0 responses
77 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
109 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
57 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
108 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
65 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment