Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Logic question. Finding next greatest number. Help!
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.
Can you help answer these questions from other members on NexusFi?
#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
#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