Logic question. Finding next greatest number. Help! - NinjaTrader Programming | futures io social day trading
futures io futures trading


Logic question. Finding next greatest number. Help!
Updated: Views / Replies:354 / 7
Created: by kidvic Attachments:1

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
 

Logic question. Finding next greatest number. Help!

  #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

Logic question. Finding next greatest number. Help!

double BaseNumber = 27;

double Z1 = 25;
double Z2 = 12;
double Z3 = 8;
double Z4 = 26;
double Z5 = 35;
double Z6 = 40;

I have a collection of Z doubles, and want to find out what the next greater number to the BaseNumber is, how do I do this?
In this case the next number to 27 in Z collection would be 35.
How do I extract that number?

Thanks in advance.

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)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,468 since Sep 2013
Thanks: 1,695 given, 3,661 received
Forum Reputation: Legendary



kidvic View Post
double BaseNumber = 27;

double Z1 = 25;
double Z2 = 12;
double Z3 = 8;
double Z4 = 26;
double Z5 = 35;
double Z6 = 40;

I have a collection of Z doubles, and want to find out what the next greater number to the BaseNumber is, how do I do this?
In this case the next number to 27 in Z collection would be 35.
How do I extract that number?

Thanks in advance.

Something like this :

 
Code
using System.Collection.Generic,

double Z1 = 25;
double Z2 = 12;
double Z3 = 8;
double Z4 = 26;
double Z5 = 35;
double Z6 = 40


double BaseNumber = 27;

Print(Biggest(Z1,Z2,Z3,Z4,Z5,Z6, BaseNumber));



double Biggest (double Z1,double Z2, double Z3, double Z4, double Z5, double Z6, double myNumber)
{
	List <double> myList = new List <double>();
	myList.Add(Z1);
	myList.Add(Z2);
	myList.Add(Z3);
	myList.Add(Z4);
	myList.Add(Z5);
	myList.Add(Z6);

	myList.Sort();

	foreach (double myZ in myList)
	{
 		if (myZ > myNYmber)
			return myZ;
	}
	return (0.0);

}

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


rleplae View Post
Something like this :

 
Code
using System.Collection.Generic,

double Z1 = 25;
double Z2 = 12;
double Z3 = 8;
double Z4 = 26;
double Z5 = 35;
double Z6 = 40


double BaseNumber = 27;

Print(Biggest(Z1,Z2,Z3,Z4,Z5,Z6, BaseNumber));



double Biggest (double Z1,double Z2, double Z3, double Z4, double Z5, double Z6, double myNumber)
{
	List <double> myList = new List <double>();
	myList.Add(Z1);
	myList.Add(Z2);
	myList.Add(Z3);
	myList.Add(Z4);
	myList.Add(Z5);
	myList.Add(Z6);

	myList.Sort();

	foreach (double myZ in myList)
	{
 		if (myZ > myNYmber)
			return myZ;
	}
	return (0.0);

}


still new to the game: Getting errors,
 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
using System.Collection.Generic;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// 
    /// </summary>
    [Description("")]
    public class TestZ : Indicator
    {
        #region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            Overlay				= true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
     double Z1 = 25;
double Z2 = 12;
double Z3 = 8;
double Z4 = 26;
double Z5 = 35;
double Z6 = 40;


double BaseNumber = 27;

Print(Biggest(Z1,Z2,Z3,Z4,Z5,Z6, BaseNumber));



double Biggest (double Z1,double Z2, double Z3, double Z4, double Z5, double Z6, double myNumber)
{
	List <double> myList = new List <double>();
	myList.Add(Z1);
	myList.Add(Z2);
	myList.Add(Z3);
	myList.Add(Z4);
	myList.Add(Z5);
	myList.Add(Z6);

	myList.Sort();

	foreach (double myZ in myList)
	{
 		if (myZ > myNYmber)
			return myZ;
	}
	return (0.0);

}
	
        }

        #region Properties

        #endregion
    }
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    public partial class Indicator : IndicatorBase
    {
        private TestZ[] cacheTestZ = null;

        private static TestZ checkTestZ = new TestZ();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public TestZ TestZ()
        {
            return TestZ(Input);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public TestZ TestZ(Data.IDataSeries input)
        {
            if (cacheTestZ != null)
                for (int idx = 0; idx < cacheTestZ.Length; idx++)
                    if (cacheTestZ[idx].EqualsInput(input))
                        return cacheTestZ[idx];

            lock (checkTestZ)
            {
                if (cacheTestZ != null)
                    for (int idx = 0; idx < cacheTestZ.Length; idx++)
                        if (cacheTestZ[idx].EqualsInput(input))
                            return cacheTestZ[idx];

                TestZ indicator = new TestZ();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                Indicators.Add(indicator);
                indicator.SetUp();

                TestZ[] tmp = new TestZ[cacheTestZ == null ? 1 : cacheTestZ.Length + 1];
                if (cacheTestZ != null)
                    cacheTestZ.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheTestZ = tmp;
                return indicator;
            }
        }
    }
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
    public partial class Column : ColumnBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.TestZ TestZ()
        {
            return _indicator.TestZ(Input);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Indicator.TestZ TestZ(Data.IDataSeries input)
        {
            return _indicator.TestZ(input);
        }
    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public partial class Strategy : StrategyBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.TestZ TestZ()
        {
            return _indicator.TestZ(Input);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Indicator.TestZ TestZ(Data.IDataSeries input)
        {
            if (InInitialize && input == null)
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

            return _indicator.TestZ(input);
        }
    }
}
#endregion

This is my code.

Reply With Quote
 
  #5 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,468 since Sep 2013
Thanks: 1,695 given, 3,661 received
Forum Reputation: Legendary


kidvic View Post
still new to the game: Getting errors,
 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
using System.Collection.Generic;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// 
    /// </summary>
    [Description("")]
    public class TestZ : Indicator
    {
        #region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            Overlay				= true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
     double Z1 = 25;
double Z2 = 12;
double Z3 = 8;
double Z4 = 26;
double Z5 = 35;
double Z6 = 40;


double BaseNumber = 27;

Print(Biggest(Z1,Z2,Z3,Z4,Z5,Z6, BaseNumber));



double Biggest (double Z1,double Z2, double Z3, double Z4, double Z5, double Z6, double myNumber)
{
	List <double> myList = new List <double>();
	myList.Add(Z1);
	myList.Add(Z2);
	myList.Add(Z3);
	myList.Add(Z4);
	myList.Add(Z5);
	myList.Add(Z6);

	myList.Sort();

	foreach (double myZ in myList)
	{
 		if (myZ > myNYmber)
			return myZ;
	}
	return (0.0);

}
	
        }

        #region Properties

        #endregion
    }
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    public partial class Indicator : IndicatorBase
    {
        private TestZ[] cacheTestZ = null;

        private static TestZ checkTestZ = new TestZ();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public TestZ TestZ()
        {
            return TestZ(Input);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public TestZ TestZ(Data.IDataSeries input)
        {
            if (cacheTestZ != null)
                for (int idx = 0; idx < cacheTestZ.Length; idx++)
                    if (cacheTestZ[idx].EqualsInput(input))
                        return cacheTestZ[idx];

            lock (checkTestZ)
            {
                if (cacheTestZ != null)
                    for (int idx = 0; idx < cacheTestZ.Length; idx++)
                        if (cacheTestZ[idx].EqualsInput(input))
                            return cacheTestZ[idx];

                TestZ indicator = new TestZ();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                Indicators.Add(indicator);
                indicator.SetUp();

                TestZ[] tmp = new TestZ[cacheTestZ == null ? 1 : cacheTestZ.Length + 1];
                if (cacheTestZ != null)
                    cacheTestZ.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheTestZ = tmp;
                return indicator;
            }
        }
    }
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
    public partial class Column : ColumnBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.TestZ TestZ()
        {
            return _indicator.TestZ(Input);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Indicator.TestZ TestZ(Data.IDataSeries input)
        {
            return _indicator.TestZ(input);
        }
    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public partial class Strategy : StrategyBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.TestZ TestZ()
        {
            return _indicator.TestZ(Input);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Indicator.TestZ TestZ(Data.IDataSeries input)
        {
            if (InInitialize && input == null)
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

            return _indicator.TestZ(input);
        }
    }
}
#endregion

This is my code.

the function needs to be outside the other function
you will need to study a few hours on functions/ basics...
classes, members, methods

Reply With Quote
 
  #6 (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


rleplae View Post
the function needs to be outside the other function
you will need to study a few hours on functions/ basics...
classes, members, methods

This seems a lot more difficult than I imagined. Thank you for trying.

Reply With Quote
 
  #7 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,468 since Sep 2013
Thanks: 1,695 given, 3,661 received
Forum Reputation: Legendary


kidvic View Post
This seems a lot more difficult than I imagined. Thank you for trying.

don't give up
all beginning is hard

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
 
  #8 (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


rleplae View Post
don't give up
all beginning is hard

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

I'm not. Thank you for the effort.

Reply With Quote

Reply



futures io > > > > > Logic question. Finding next greatest number. Help!

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
ThinkScript - MM-PS Code/Logic Question... netarchitech ThinkOrSwim 1 October 29th, 2015 11:26 AM
Thinkscript - Code/Logic Question... netarchitech ThinkOrSwim 4 August 31st, 2015 06:13 PM
Thinkscript logic question strategynode ThinkOrSwim Programming 0 January 5th, 2015 01:28 PM
Number Bars Question- Plotting Volume POC Babool Sierra Chart 2 October 5th, 2014 02:20 PM
Finding X number of largest daily moves in a market Mobiius Elite EasyLanguage Automated Trading 2 September 13th, 2012 03:53 PM


All times are GMT -4. The time now is 01:31 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.11 seconds with 20 queries on phoenix via your IP 54.145.16.43