I am new to the forum and to NT. Love this tool. I am writing a simple scripts to make sure that there is no overfill errors. I am not having just two conditions of enterShort() or EnterLong(). On top of that I will have ExitLong() and ExitShort(). Can you please help me with the skeleton of the code that can accomplish this. Never mind about the actual condition. I am trying this but it does not seem to be working. Thanks,
-----
// 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 Sha****est : Strategy
{
#region Variables
// Wizard generated variables
private int varZero = 0; // Default setting for VarZero
// 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()
{
Add(macdShashi(12, 26, 20));
Add(macdShashi(12, 26, 20));
Add(macdShashi(12, 26, 20));
Add(macdShashi(12, 26, 20));
EntriesPerDirection = 2;
EntryHandling = EntryHandling.AllEntries;
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
private IOrder entryOrder = null;
protected override void OnBarUpdate()
{
// Condition set 1
if (macdShashi(12, 26, 20).Diff[0] < VarZero && entryOrder == null)
entryOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Market, 1, 0, 0, "", "Enter Short");
// Condition set 2
if (macdShashi(12, 26, 20)[0] > macdShashi(12, 26, 20)[1] && entryOrder == null)
entryOrder = SubmitOrder(0, OrderAction.BuyToCover, OrderType.Market, 1, 0, 0, "", "Exit Short");
Comment