if(this.TBuySignals.GetValueAt(5) || this.TBuySignals.GetValueAt(4) || this.TBuySignals.GetValueAt(3) || this.TBuySignals.GetValueAt(2) || this.TBuySignals.GetValueAt(1))
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
operator || cannot be applied to operands of type double and double
Collapse
X
-
operator || cannot be applied to operands of type double and double
Getting this error for the sample below:
how do i overcome that??Code:Tags: None
-
Hello outsource,
Thanks for your post.
The error message is indicating that, for example, this.TBuySignals.GetValueAt(5) is resolving to a double value instead of a needed true or false condition.
In an "if" statement you have conditions that must resolve to true or false. If the condition resolves to true then the action(s) below the If statement (usually contained by "{}") are executed. In your example you have several conditions and using the "OR" operator "||" means that if any of the separated conditions are true the action(s) following the if statement would be executed.
With a double value, you typically would need to do a comparison to create a logical true or false, for example if (this.TBuySignals.GetValueAt(5) > this.TBuySignals.GetValueAt(4)) would resolve to a true or false condition that would be acceptable to the compiler.
Likely you would need to review with the originator of the code to determine what comparisons are expected to be made for the if statement to work.
-
It`s not a comparison.It`s just kind of the age of the value stored back N bars.
here`s the snippet that works in NT7 quite well
if(this.TBuySignals.ContainsValue(5) || this.TBuySignals.ContainsValue(4) || this.TBuySignals.ContainsValue(3)
|| this.TBuySignals.ContainsValue(2) || this.TBuySignals.ContainsValue(1))
So, how do i make it work with NT8??
Maybe it`s the NT 8 internal issue?
Comment
-
I am not sure what type this.TBuySignals actually is but ...
is basically asking if this.TBuySignals has the value 5, or has a value 5 bars ago.Code:if(this.TBuySignals.ContainsValue(5)...
The code snippet
is basically saying... retrieve the value of this.TBuySignals at bar index 5, or 5 bars back (not sure of the nature of your variable) and then if this value is ... the rest is missing and so NT complains.Code:if(this.TBuySignals.GetValueAt(5)
Comment
-
Hello outsource,
Thanks for your reply.
In NT7 the extension .ContainsValues() is not the same as GetValuesAt() in NT8. In the case of NT7 it returns a logical true or false. As previously advised GetValuesAt() returns a double value.
For NT8, use .IsValidDataPoint() reference: https://ninjatrader.com/support/help...ddatapoint.htm Please take care to read the helpguide and heed the warning provided.
For your example then replace this.TBuySignals.ContainsValue(5) with this.TBuySignals.IsValidDataPoint(5), etc, etc.
Comment
-
A little off-top, but could you guys also please help me with the string converter?
In NT 8 it doesn`t recognize the Core part of the snippet below:
string folder = System.IO.Path.Combine(Cbi.Core.InstallDir,"sounds");
With what do i have to change it?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
625 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
359 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
562 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
567 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment