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)
I assume you are asking how to get the parameters from the dialog box to/from your strategy. The best thing to do is start downloading indicators and looking at how they work. I have to admit, NT doesn't document them well. You may also want to try the Strategy Wizard to have it setup the input parameters, then cut/paste those parts into your code. Also check out a few of the helper threads & webinars:
This tread will discuss auto trading with Ninja Trader 7. I am by no means an expert on this subject but have learned quite a bit about what doesn't work and why. If you are starting out, hopefully this thread can save you months of frustration and …
Here is an example of the UI code embedded within the code (Taken from RiskReward V2 Indie):
The parameter section holds the UI for NT. Take the "FixedShares" public variable above. Based upon the lines above, it is stored in the "Parameters" section of the UI, with the description in the next line, but has a specific display name in the UI box (without this last line you would see just the variable name). It is defined as an "int", it uses the private variable "fixedShares" (note the lowercase "f" rather than capital "F"). Upon opening the dialog box, "fixedShares" is loaded into the dialog box. Upon closing the "value" of the parameter is set back into the variable but will have a minimum value of 0 due to the Math.Max() statement.
Hope that give you a taste, hopefully that is what you are asking.
heres the code i wrte but im not getting any results , can anyone help ?
#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.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class Trend3bar : Strategy
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, 2);
SetStopLoss("", CalculationMode.Ticks, 3, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < 3) return;
//rest of the codes
// Condition set 1
if (Close[0] > Close[1]
&& Close[1] == Close[2]
&& Close[2] == Close[3])
{
}
}
heres what i have so far but im not getting targets i want
#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.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class MyCustomStrategy : Strategy
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, 2);
SetStopLoss("", CalculationMode.Ticks, 3, false);
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{if (CurrentBar < 3) return;
//rest of the codes
{
isBuy = false; //setting it to false makes sure there is no additional buys
isSell = true; //resets isSell so that buy orders can be taken
//rest of the buy order codes
}
{
isBuy = true; //resets buy so that buy orders can be taken
isSell = false; //set isSell to false so that no other sell is taken
//rest of the sell order codes
}
// Condition set 1
if (Close[0] > Close[1]
&& Close[1] > Close[2]
&& Close[2] == Close[3])
{
EnterLong(DefaultQuantity, "");
EnterShort(DefaultQuantity, "");
}
}
I put some notes in your code above to help get you closer. The last block tries to enter both a long and short at the same time. Not sure what happens in NT, net is 0 orders (buy then sell really fast), but I think one gets overwritten so you are likely to aways get a short or a long depend on the sequence.