Print("91 Cancelled Order");
...but my other print statements do though. Leading me to believe it's not being called. I'll try and find another statement to use instead.
if(CurrentBar==entrybar + 1
if(CurrentBar > barNumberOfOrder + 2
public class TFSV2BATM : Strategy
{
#region Variables
private string atmStrategyId = string.Empty;
private string orderId = string.Empty;
private int barNumberOfOrder = 0;
private int prevBarsMinusTicks = 1; // Default setting for PrevBarsPlusTicks
#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()
{
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Make sure this strategy does not execute against historical data
if (Historical)
return;
// Submits an entry limit order to initiate an ATM Strategy if both order id and strategy id are in a reset state
if (Position.MarketPosition == MarketPosition.Flat
&& orderId.Length == 0
&& atmStrategyId.Length == 0
&& FirstTickOfBar
&& Close [1] <= Open [1]
&& Low[1] - PrevBarsMinusTicks * TickSize < GetCurrentAsk())
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Stop, 0, Low[1] - PrevBarsMinusTicks * TickSize , TimeInForce.Day, orderId, "TF_short_500T", atmStrategyId);
barNumberOfOrder = CurrentBar;
}
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
if(CurrentBar > barNumberOfOrder + 2 && (status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
{
Print("91 Cancelled Order");
AtmStrategyCancelEntryOrder(orderId);
atmStrategyId = string.Empty;
orderId = string.Empty;
}
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
else if (status.GetLength(0) > 0)
{
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status[0]);
Print("The entry order filled amount is: " + status[1]);
Print("The entry order order state is: " + status[2]);
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id
//else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
// atmStrategyId = string.Empty;
else
if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat)
{
Print("302 reset the strategy id");
atmStrategyId = string.Empty;
orderId = string.Empty;
}
if (atmStrategyId.Length > 0)
{
// Print some information about the strategy to the output window
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId));
Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
Print("The current ATM Strategy Realized PnL is: " + GetAtmStrategyRealizedProfitLoss(atmStrategyId));
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int PrevBarsMinusTicks
{
get { return prevBarsMinusTicks; }
set { prevBarsMinusTicks = Math.Max(1, value); }
}
#endregion
}
}
public class TFS3BRATM : Strategy
{
#region Variables
private string atmStrategyId = string.Empty;
private string orderId = string.Empty;
private int prevBarsMinusTicks = 1; // Default setting for PrevBarsPlusTicks
private int barNumberOfOrder = 0;
#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()
{
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Make sure this strategy does not execute against historical data
if (Historical)
return;
// Submits an entry limit order to initiate an ATM Strategy if both order id and strategy id are in a reset state
if (Position.MarketPosition == MarketPosition.Flat
&& orderId.Length == 0
&& atmStrategyId.Length == 0
&& FirstTickOfBar
&& Close [1] >= Open [1]
&& Low [1] - PrevBarsMinusTicks * TickSize < GetCurrentAsk())
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Stop, 0, Low[1] - prevBarsMinusTicks * TickSize, TimeInForce.Day, orderId, "TF_short_500T", atmStrategyId);
barNumberOfOrder = CurrentBar;
}
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
// 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(CurrentBar > barNumberOfOrder + 1
&& (status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
AtmStrategyCancelEntryOrder(orderId);
Print("91 Cancelled Order");
atmStrategyId = string.Empty;
orderId = string.Empty;
}
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
else if (status.GetLength(0) > 0)
{
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status[0]);
Print("The entry order filled amount is: " + status[1]);
Print("The entry order order state is: " + status[2]);
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId = string.Empty;
}
}
else
if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat)
{
Print("302 reset the strategy id");
atmStrategyId = string.Empty;
orderId = string.Empty;
}
if (atmStrategyId.Length > 0)
{
// Print some information about the strategy to the output window
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId));
Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
Print("The current ATM Strategy Realized PnL is: " + GetAtmStrategyRealizedProfitLoss(atmStrategyId));
}
}
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
// 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((status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
AtmStrategyCancelEntryOrder(orderId);
Print("91 Cancelled Order");
atmStrategyId = string.Empty;
orderId = string.Empty;
}
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
if (status.GetLength(0) > 0)
{
if
((status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
AtmStrategyCancelEntryOrder(orderId);
Print("91 Cancelled Order");
atmStrategyId = string.Empty;
orderId = string.Empty;
}
[COLOR=#000000][COLOR=#0000BB][/COLOR][/COLOR]string[] status = GetAtmStrategyEntryOrderStatus(orderId); Print("entry order info:\t" + status.ToString());
string[] status = GetAtmStrategyEntryOrderStatus(orderId); Print("entry order info:\t" + status.ToString());
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
Print("entry order info:\t" + status.ToString());
// 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(
//CurrentBar > barNumberOfOrder + 1
&& (status[1] == "Accepted" || status[1] == "Working" || status[1] == "Pending"))
AtmStrategyCancelEntryOrder(orderId);
Print("TFS3BRATM Cancelled Order");
atmStrategyId = string.Empty;
orderId = string.Empty;
}
if (barNumberOfOrder == 2 && (status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
{
Print("108 Cancel the TFLV2Bjthom order ");
AtmStrategyCancelEntryOrder(orderId);
}
if (Close [0] - 5 * TickSize < High[1] &&(status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
{
Print("108 ATM cancel TFL3BR order");
AtmStrategyCancelEntryOrder(orderId);
}
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by zstheorist, Today, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
150 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
6 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
6 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.
Comment