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 charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
70 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
152 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
162 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
100 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
288 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment