Can I use a DataSeries as part of an 'if' statement? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Can I use a DataSeries as part of an 'if' statement?
Updated: Views / Replies:2,083 / 11
Created: by magnumdbl Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Can I use a DataSeries as part of an 'if' statement?

  #1 (permalink)
Elite Member
Cranford, New Jersey, USA
 
Futures Experience: Advanced
Platform: Tradestation, Ninja Trader
Broker/Data: TS and MB Trading
Favorite Futures: ES, EC
 
Posts: 10 since Dec 2010
Thanks: 8 given, 1 received

Can I use a DataSeries as part of an 'if' statement?

I tried to use a DataSeries called "cond1"
similar to the way Scott did in his TimeToTrade code with ' _signal', but couldn't get it to work.

I declared it in Variables with
private DataSeries cond1;

I initialized it as cond1 = new DataSeries(this);

I set it with cond1.Set(+1);

I put it in Properties with
public DataSeries Cond1 (not sure which one I should use.)
{
// get { return cond1; } //c I tried both of these.
get { return Values[4]; } //d

but when I tried to use it with (not sure about this either)
// if (cond1[0] = 1) //a I tried both of these.
if (cond1 = 1) //b

I got these errors from the above combinations:

a & c = Cannot implicitly convert type double to bool
a & d = Cannot implicitly convert type double to bool
b & d = Cannot implicitly convert type 'int' to DataSeries
b & c = Cannot implicitly convert type 'int' to DataSeries

I've been programming TS for years and am 2wks into C# trying
to go thru as many webinars etc as possible.
But something is not sinking in.
Hoping someone can point me in the right direction.

Don

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,215 since Jun 2009
Thanks: 628 given, 6,312 received


but of course, go to \My Documents\NinjaTrader 7\bin\Custom\Indicator
take a look at @stochastics.cs coding it has exactly what you are looking for

Reply With Quote
The following user says Thank You to cory for this post:
 
  #4 (permalink)
Elite Member
Cranford, New Jersey, USA
 
Futures Experience: Advanced
Platform: Tradestation, Ninja Trader
Broker/Data: TS and MB Trading
Favorite Futures: ES, EC
 
Posts: 10 since Dec 2010
Thanks: 8 given, 1 received

comment on using the cond1 variable.


cory View Post
but of course, go to \My Documents\NinjaTrader 7\bin\Custom\Indicator
take a look at @stochastics.cs coding it has exactly what you are looking for

I noticed in that code that they didn't put anything in the 'Properties' region.
when do I have to put DataSeries etc. into the Properties?

So I took cond1 out of the properties and used the

if( cond1 = 1)

statement and got the error: cannot implicity convert 'int' to NT Data.DataSeries'

I'm stillconfused.

Thanks,
Don

Reply With Quote
 
  #5 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,215 since Jun 2009
Thanks: 628 given, 6,312 received


magnumdbl View Post
I noticed in that code that they didn't put anything in the 'Properties' region.
when do I have to put DataSeries etc. into the Properties?

So I took cond1 out of the properties and used the

if( cond1 = 1)

statement and got the error: cannot implicity convert 'int' to NT Data.DataSeries'

I'm stillconfused.

Thanks,
Don

click + sign next to 'Properties' region to expanse it.


data series are in:
.............
#region Variables
private int periodD = 7; // SlowDperiod
private int periodK = 14; // Kperiod
private int smooth = 3; // SlowKperiod
private DataSeries den;
private DataSeries nom;
private DataSeries fastK;
#endregion
..............

protected override void Initialize()
{
Add(new Plot(Color.Green, "D"));
Add(new Plot(Color.Orange, "K"));

Add(new Line(Color.DarkViolet, 20, "Lower"));
Add(new Line(Color.YellowGreen, 80, "Upper"));

den = new DataSeries(this);
nom = new DataSeries(this);
fastK = new DataSeries(this);
}
...............

Reply With Quote
The following user says Thank You to cory for this post:
 
  #6 (permalink)
Elite Member
Cranford, New Jersey, USA
 
Futures Experience: Advanced
Platform: Tradestation, Ninja Trader
Broker/Data: TS and MB Trading
Favorite Futures: ES, EC
 
Posts: 10 since Dec 2010
Thanks: 8 given, 1 received

Using DataSeries as a variable

Thanks for your patients, but that doesn't quite solve my problem.

e.g. I see that in the Stochastics, den is not mentioned in the Properties section.

So I took my 'cond1' variable out of my Properties section .

HOWEVER

when I set my cond1 with cond1.Set(1)

and then try to use it in an 'if' statement such as

if(cond1 = 1)

{

}

I get the error message that I cannot implicitly convert an 'int' to a DataSeries.

Does that make sense?

Don

Reply With Quote
 
  #7 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received


magnumdbl View Post

if(cond1 = 1)

{

}

I get the error message that I cannot implicitly convert an 'int' to a DataSeries.

Does that make sense?

Don

Yes, it does. First, cond = 1 is a conversion, not a comparison.

Make sure both sides of a comparison are of the same type.

Math. A gateway drug to reality.
Reply With Quote
 
  #8 (permalink)
Elite Member
Cranford, New Jersey, USA
 
Futures Experience: Advanced
Platform: Tradestation, Ninja Trader
Broker/Data: TS and MB Trading
Favorite Futures: ES, EC
 
Posts: 10 since Dec 2010
Thanks: 8 given, 1 received

zig zag

Thanks for your previous advice.
I did get thru another 60 pages in the C# reference manual and that helped also.

In the ZigZagUTC i see numbers with 15 decimal places. Is there a place to select how many decimals?

I also looked at the Sample FontChange reference in ninja. Was wondering if there is a demo that shows how to allow choice of font SIZE(pxl) in the Indicator Panel?

Would like to be able to make a similar choice for DrawDot size . Any references or examples of that?

Thanks,
Don

Reply With Quote
 
  #9 (permalink)
Atlas
Bloomington
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: Stocks
 
ShruggedAtlas's Avatar
 
Posts: 191 since Apr 2011
Thanks: 78 given, 74 received

This maybe talking about something else entirely but i've seen this before in my own coding (i'm a beginner here)

If statements compare two or more data types that must be the same. It must evaluate to either true or false (a bool)

if(EMA(8))
{ //would produces a type conversion error because it's looking to evaluate to bool but this is a series}

if(EMA(8)[0]))
{//would produce a type conversion error because this statement does not produce true or false evaluation only an int}

if(EMA(8)[0] == EMA(8)[0])
{//this would produce either a true or false evaluation and would not produce any errors because the conditions of the
// if statement have been satisfied}

In your code find out exactly what cond1 is. if it is s series you need to choose one data point in the series and compare it to another piece of data of the same type in order to have a valid if statement.

I could be wrong here but I went through the same issues when i was figuring out conditional statements like if. Can someone else verify that I'm correct?

"I've missed more than 9,000 shots in my career. I've lost almost 300 games. 26 times, I've been trusted to take the game-winning shot and missed. I've failed over and over and over again in my life. And that is why I succeed."
- Michael Jordan, 5-Time NBA Most Valuable Player, 6-Time NBA Champion
Reply With Quote
The following user says Thank You to ShruggedAtlas for this post:
 
  #10 (permalink)
Atlas
Bloomington
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: Stocks
 
ShruggedAtlas's Avatar
 
Posts: 191 since Apr 2011
Thanks: 78 given, 74 received



traderwerks View Post
Yes, it does. First, cond = 1 is a conversion, not a comparison.

Make sure both sides of a comparison are of the same type.

Oh i just noticed that!

you would want something like this:

if (cond1 == 1)

but that won't work if cond1 is a series. You'd get an error I think

"I've missed more than 9,000 shots in my career. I've lost almost 300 games. 26 times, I've been trusted to take the game-winning shot and missed. I've failed over and over and over again in my life. And that is why I succeed."
- Michael Jordan, 5-Time NBA Most Valuable Player, 6-Time NBA Champion
Reply With Quote
The following user says Thank You to ShruggedAtlas for this post:

Reply



futures io > > > > > Can I use a DataSeries as part of an 'if' statement?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch Statement DonStar AmiBroker 7 August 20th, 2012 04:15 PM
RE Easylanguage statement for coding price baz111 EasyLanguage Programming 2 December 26th, 2011 11:07 AM
Jefferies Re-Releases Statement Quick Summary News and Current Events 0 November 3rd, 2011 11:30 AM
NT7 audio alert - statement expected? subterfuge NinjaTrader Programming 2 March 17th, 2011 10:55 AM
Fed repurchase statement Snoop Traders Hideout 1 November 4th, 2010 08:11 AM


All times are GMT -4. The time now is 03:20 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-11 in 0.14 seconds with 19 queries on phoenix via your IP 54.226.172.30