Math.Max, Max help with int - NinjaTrader Programming | futures io social day trading
futures io futures trading


Math.Max, Max help with int
Updated: Views / Replies:535 / 6
Created: by kidvic 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 100,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
 

Math.Max, Max help with int

  #1 (permalink)
Trading for Fun
Los Angeles, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, ThinkOrSwim
Favorite Futures: Options, Futures
 
Posts: 92 since Mar 2015
Thanks: 13 given, 2 received

Math.Max, Max help with int

Need some NinjaScript help!

so I have 10 conditions (bool) ranging from c1 - c10.
if any of those conditions are true, then they give me the appropriate int.
ex. if c1 is true, then m2 = 3.

This is all under BarUpdate()

int m2 = c1 ? 3 : 0;
int m3 = c2 ? 4 : 0;
int m4 = c3 ? 5 : 0;
int m5 = c4 ? 6 : 0;
int m6 = c5 ? 7 : 0;
int m7 = c6 ? 8 : 0;
int m8 = c7 ? 9 : 0;
int m9 = c8 ? 10 : 0;
int m10 = c9 ? 11 : 0;
int m11 = c10 ? 12 : 0;

int max1 = Max(m2, m3);
int max2 = Max(max1, m4);
int max3 = Max(max2, m5);
int max4 = Max(max3, m6);
int max5 = Max(max4, m7);
int max6 = Max(max5, m8);
int max7 = Max(max6, m9);
int max8 = Max(max7, m10);
int max9 = Max(max8, m11);

int maxcondition = max9;



Now, what I want to do is have maxcondition extract the highest value between m1 - m11, by using the max function (max1 - max9).

However, I get the following error:

the name 'max' does not exist in the current context.

The errors are on ints max1- max9

Thanks in advance.


Last edited by kidvic; October 17th, 2015 at 01:53 PM. Reason: Clarification
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)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,424 since Jun 2009
Thanks: 3,621 given, 4,093 received


Try Math.Max() and not Max().

And using an array of int would have been better...

Success requires no deodorant! (Sun Tzu)
Reply With Quote
 
  #4 (permalink)
Trading for Fun
Los Angeles, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, ThinkOrSwim
Favorite Futures: Options, Futures
 
Posts: 92 since Mar 2015
Thanks: 13 given, 2 received


sam028 View Post
Try Math.Max() and not Max().

Awesome!
Worked.

- Working around the ThinkScript version.

Thank you!


Last edited by kidvic; October 17th, 2015 at 02:01 PM. Reason: Clarification
Reply With Quote
 
  #5 (permalink)
Trading for Fun
Los Angeles, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, ThinkOrSwim
Favorite Futures: Options, Futures
 
Posts: 92 since Mar 2015
Thanks: 13 given, 2 received

I shouted glory too soon. Is all my coding correct?
It doesn't produce any more errors, but it also doesn't draw a trendline.
The trendline when placed in a fresh new indicator under BarUpdate, works fine alone.

However, when I introduce the bools, and ints, and max ints, it does not.

What am I doing wrong?

Reply With Quote
 
  #6 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,511 since Jun 2009
Thanks: 645 given, 6,829 received
Forum Reputation: Legendary


kidvic View Post
I shouted glory too soon. Is all my coding correct?
It doesn't produce any more errors, but it also doesn't draw a trendline.
The trendline when placed in a fresh new indicator under BarUpdate, works fine alone.

However, when I introduce the bools, and ints, and max ints, it does not.

What am I doing wrong?

make sure you have enough bars before plotting a line

for example you are looking for max of 5 bars then wait for 5 bar values first thus;

protected override void OnBarUpdate()
{
// wait for 5 bar values before plotting
if (CurrentBar < 5)
return;

Reply With Quote
 
  #7 (permalink)
Trading for Fun
Los Angeles, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, ThinkOrSwim
Favorite Futures: Options, Futures
 
Posts: 92 since Mar 2015
Thanks: 13 given, 2 received


cory View Post
make sure you have enough bars before plotting a line

for example you are looking for max of 5 bars then wait for 5 bar values first thus;

protected override void OnBarUpdate()
{
// wait for 5 bar values before plotting
if (CurrentBar < 5)
return;

Thank you for that, I started commenting out the code, and I have come to this:

https://futures.io/ninjatrader-programming/37407-help-bool-indicator.html#post529658

The rest of the code is working, its just some bools are what are causing the issue.


Last edited by kidvic; October 17th, 2015 at 03:16 PM. Reason: Clarification
Reply With Quote

Reply



futures io > > > > > Math.Max, Max help with int

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

July Journal Challenge - $500 in Amazon Gift Cards!

July
 

AXESS Trader: Powerful Cloud Based Trading Platform w/GFF Brokers

Jul 17

TBA: FuturesTrader71 w/Morad Askar

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
thinkscript definitions max kidvic ThinkOrSwim 4 May 4th, 2015 09:14 AM
max daily loss charlie37 NinjaTrader 12 August 16th, 2014 01:38 AM
Max International R1Drake Reviews of Brokers and Data Feeds 1 July 11th, 2012 10:19 PM
Getting the max account value freddy250 NinjaTrader Programming 1 February 17th, 2012 01:41 PM


All times are GMT -4. The time now is 10:23 AM. (this page content is cached, log in for real-time version)

Copyright © 2018 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 2018-07-20 in 0.13 seconds with 14 queries on phoenix