Welcome to NexusFi: the best trading community on the planet, with over 200,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 -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Does anybody know why this ATM strategy is outputting these types of errors?
**NT** GetAtmStrategyMarketPosition() method error: Missing atmStrategyId parameter
**NT** AtmStrategyCancelEntryOrder() method error: Missing orderId parameter
#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.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
///
/// </summary>
[Description("")]
public class ATMTEST1: Strategy
{
#region Variables
private string atmStrategyIdLong = string.Empty;
private string orderIdLong = string.Empty;
private string atmStrategyIdShort = string.Empty;
private string orderIdShort = string.Empty;
private string atmStrategyName = "atmtest";
private int slipTicks = 1;
private int barNumberOfOrderLong = 0; //***
private int barNumberOfOrderShort = 0; //***
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
//Cancels Limit order LONG************************************
if (CurrentBar > barNumberOfOrderLong && GetAtmStrategyMarketPosition(atmStrategyIdLong) == MarketPosition.Long)
{
AtmStrategyCancelEntryOrder(orderIdLong);
orderIdLong = string.Empty;
Print("Cancelled LONG ENTRY Order from strategy");
}
//Cancels Long Limit if short strategy is short
if (GetAtmStrategyMarketPosition(atmStrategyIdShort) == MarketPosition.Short)
{
AtmStrategyCancelEntryOrder(orderIdLong);
orderIdLong = string.Empty;
Print("Cancelled LONG ENTRY Order from strategy");
}
//Cancels Limit order Short************************************
if (CurrentBar > barNumberOfOrderShort && GetAtmStrategyMarketPosition(atmStrategyIdShort) == MarketPosition.Short)
{
AtmStrategyCancelEntryOrder(orderIdShort);
orderIdShort = string.Empty;
Print("Cancelled SHORT ENTRY Order from strategy");
}
//Cancels Short Limit if strategy is long
if (GetAtmStrategyMarketPosition(atmStrategyIdLong) == MarketPosition.Long)
{
AtmStrategyCancelEntryOrder(orderIdShort);
orderIdShort = string.Empty;
Print("Cancelled SHORT ENTRY Order from strategy");
}
// Check for a pending entry order LONG
if (orderIdLong.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderIdLong);
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderIdLong = string.Empty;
}
}
// Check for a pending entry order Short
if (orderIdShort.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderIdShort);
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderIdShort = string.Empty;
}
}
[Description("Slippage Ticks for Entry")]
[GridCategory("Parameters")]
public int SlipTicks
{
get { return slipTicks; }
set { slipTicks = Math.Max(1, value); }
}
[Description("Name for the ATM Strategy")]
[GridCategory("Parameters")]
public string AtmStrategyName
{
get { return atmStrategyName; }
set { atmStrategyName = value; }
}
#endregion
}
}
Can you help answer these questions from other members on NexusFi?