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)
RJay, is that by specifying the same number of bars or the same number of days or either? (in the Format Data Series Dialogue Box) or am I totally on the wrong track?
Well its not quite there yet. Attached two photos... one of the strat executing the ATM and one of the strat executing draw arrow. There are four instances where the strat with the ATM "missed" buy signals and one instance where it did a "buy" when it should not have.
When those two strats run live against incoming data, the indicators look exactly the same.
In a way it was good to be out of some of that chop... I just need to figure out why the code does not work the same between both strats.
Go Long ATM:
// ATM Strategy code cut-and-paste from NT
// Make sure this strategy does not execute against historical data
if (Historical)
return;
// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'ES 2 w BE and Trail' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
// in the line below I've deleted && Close[0] > Open[0] from the default sampleATMstrategy code
if (orderId.Length == 0 && atmStrategyId.Length == 0 )
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "ES 2 w BE and Trail", 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)
{
// 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
elseif (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId = string.Empty;
if (atmStrategyId.Length > 0)
{
// You can change the stop price
if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);
// 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: " + GetAtm
1. Compare each strat's code once again, line by line.
2. Run both on the same chart using Market Replay 1x speed.
3. Work on hard coding an "ATM like" exit strategy as Mike suggested weeks ago . I've started that already on a strat I use on FESX, but struggling with how to "tighten" stops after trailing for a while.
It's 9am where I live, which gives me 5 hours until FESX opens. Let the Games begin!
Just to update this thread. My problem was solved with Action #1 above. A single typo in my strat code had it trading against an indicator parameter that was different than the plotted parameter.
I've found the bug, and it was me.
On the ATM-like hard code, I'm still playing around with it. To be honest the only reason for it seems to be the issue of backtesting using data from different time frames. Important, but I need to prioritize what I need to do in NT.