if(this.TBuySignals.GetValueAt(5) || this.TBuySignals.GetValueAt(4) || this.TBuySignals.GetValueAt(3) || this.TBuySignals.GetValueAt(2) || this.TBuySignals.GetValueAt(1))
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
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:
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.Paul H.NinjaTrader Customer Service
-
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 ...
Code:if(this.TBuySignals.ContainsValue(5)...
The code snippet
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.Paul H.NinjaTrader Customer Service
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 llanqui, Today, 11:10 AM
|
0 responses
4 views
0 likes
|
Last Post
by llanqui
Today, 11:10 AM
|
||
Started by llanqui, Today, 10:29 AM
|
0 responses
5 views
0 likes
|
Last Post
by llanqui
Today, 10:29 AM
|
||
Started by llanqui, Today, 08:32 AM
|
1 response
13 views
0 likes
|
Last Post
by llanqui
Today, 08:50 AM
|
||
Started by lollers, Yesterday, 03:26 AM
|
1 response
53 views
0 likes
|
Last Post
by lollers
Today, 07:20 AM
|
||
Started by Salahinho99, 05-05-2024, 04:13 AM
|
7 responses
63 views
0 likes
|
Last Post
by Salahinho99
Today, 06:45 AM
|
Comment