Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
If statements and bool variable
Collapse
X
-
Hello Brian,
Pi is correct. You can call the bools in such a manner, for example equals false can be !B2_SU.
-
Originally posted by BReal View PostI am new to C# and am learning by working my way through strategies found in the Ninjascripts library. I'm having trouble understanding the logic in one particular section of the PZO Strategy.
Code://UpTrendRules if (Close[0] > EMA(EMAPeriod)[0] && ADX(ADXPeriod)[0] > 18) { if (CrossAbove(PriceZoneOscillator(PZOPeriod), -40, 1)) EnterLong("Buy1"); if (CrossAbove(PriceZoneOscillator(PZOPeriod), 0, 1)) B2_SU = true; if (B2_SU && CrossAbove(PriceZoneOscillator(PZOPeriod), 15, 1)) { EnterLong("Buy2"); } }
Is there an inherent code in an if statement with bool variables that I haven't learned yet? Please translate if you could be so kind.
Thanks!
Brian
You will gradually find this natural later on, especially if the variable name is self explaining. For example:
if (RSI_Overbought && ... ) EnterShort();
Pi
Leave a comment:
-
If statements and bool variable
I am new to C# and am learning by working my way through strategies found in the Ninjascripts library. I'm having trouble understanding the logic in one particular section of the PZO Strategy.
Code://UpTrendRules if (Close[0] > EMA(EMAPeriod)[0] && ADX(ADXPeriod)[0] > 18) { if (CrossAbove(PriceZoneOscillator(PZOPeriod), -40, 1)) EnterLong("Buy1"); if (CrossAbove(PriceZoneOscillator(PZOPeriod), 0, 1)) B2_SU = true; if (B2_SU && CrossAbove(PriceZoneOscillator(PZOPeriod), 15, 1)) { EnterLong("Buy2"); } }
Is there an inherent code in an if statement with bool variables that I haven't learned yet? Please translate if you could be so kind.
Thanks!
BrianTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by abelsheila, 05-14-2025, 07:38 PM
|
2 responses
39 views
0 likes
|
Last Post
![]()
by hglover945
05-16-2025, 03:48 PM
|
||
Started by nailz420, 05-14-2025, 09:14 AM
|
1 response
84 views
0 likes
|
Last Post
|
||
Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
|
0 responses
425 views
1 like
|
Last Post
|
||
Started by domjabs, 05-12-2025, 01:55 PM
|
2 responses
75 views
0 likes
|
Last Post
![]()
by domjabs
05-12-2025, 02:50 PM
|
||
Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
|
1 response
103 views
0 likes
|
Last Post
|
Leave a comment: