Any comments?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
using 'while'
Collapse
X
-
Originally posted by Rigsby66 View PostIt seems that if I use a 'while' loop in the OnBarUpdate(), I get a crash....
Any comments?
For example:
int myInt = 5;
while (myInt == 5)
// Do somethingRayNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Ray View PostCould it be that your while loop never exits and causes an infinite loop?
For example:
int myInt = 5;
while (myInt == 5)
// Do something
while (Stochastics(7, 14, 3).D[0] < 50)
{
Print(Stochastics(7, 14, 3).D[0]);
}
Comment
-
Originally posted by NinjaTrader_Austin View PostRigsby, the code you posted would definitely cause an infinite loop and crash NinjaTrader because the loop doesn't have an exit.
The point is that there is an exit. The exit should be when the stochastics go >=50. This is the point of a while statement. It checks for a condition until it is met.... So I guess I need to do a while but grab the stochastics myself in each loop as this is obviously not happening otherwise..
Maybe I need to add that I am not a trader and am not a C# programmer... I am a C programmer who has lost his way... LOL
Comment
-
Originally posted by Rigsby66 View PostWell, I know that because as I already said Ninja crashes when I do it.
The point is that there is an exit. The exit should be when the stochastics go >=50. This is the point of a while statement. It checks for a condition until it is met.... So I guess I need to do a while but grab the stochastics myself in each loop as this is obviously not happening otherwise..
Maybe I need to add that I am not a trader and am not a C# programmer... I am a C programmer who has lost his way... LOLRayNinjaTrader Customer Service
Comment
-
Rigsby, why won't an if statment work?
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (Stochastics([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]7[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]).D[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]] < [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]50[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]// Stochastics are less than 50. do something.[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2] [SIZE=2][FONT=Courier New]} [/FONT][/SIZE][/SIZE][/FONT]
AustinNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Austin View PostRigsby, why won't an if statment work?
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (Stochastics([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]7[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]).D[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]] < [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]50[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]// Stochastics are less than 50. do something.[/FONT][/SIZE][/SIZE][/FONT] [SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [/FONT][/SIZE]
I guess I am just trying to find a more reliable cycle than OnBarUdpate()
Comment
-
Originally posted by Rigsby66 View PostI guess I am just trying to find a more reliable cycle than OnBarUdpate()
Lets take a step back, what do you mean by you want to find a more reliable cycle than OnBarUpdate?AustinNinjaTrader Customer Service
Comment
-
Sorry
Originally posted by NinjaTrader_Austin View PostLets take a step back, what do you mean by you want to find a more reliable cycle than OnBarUpdate?
Thanx
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by milfocs, Today, 07:23 PM
|
0 responses
1 view
0 likes
|
Last Post
by milfocs
Today, 07:23 PM
|
||
Started by PaulMohn, Today, 06:59 PM
|
0 responses
4 views
0 likes
|
Last Post
by PaulMohn
Today, 06:59 PM
|
||
Started by bortz, 11-06-2023, 08:04 AM
|
48 responses
1,748 views
0 likes
|
Last Post
by carnitron
Today, 06:57 PM
|
||
Started by Jonker, 04-27-2024, 01:19 PM
|
3 responses
23 views
0 likes
|
Last Post Today, 05:45 PM | ||
Started by businessman1929, 04-29-2024, 01:28 PM
|
2 responses
22 views
0 likes
|
Last Post Today, 05:38 PM |
Comment