Are ATM orders Suitable in a NinjaScript (or better avoid it) - NinjaTrader | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader

Are ATM orders Suitable in a NinjaScript (or better avoid it)
Started:August 11th, 2013 (05:17 AM) by benwincky Views / Replies:855 / 1
Last Reply:August 11th, 2013 (01:15 PM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Are ATM orders Suitable in a NinjaScript (or better avoid it)

Old August 11th, 2013, 05:17 AM   #1 (permalink)
Brussels Belgium
Futures Experience: Beginner
Platform: Ninjatrader
Favorite Futures: Forex
Posts: 14 since Mar 2013
Thanks: 5 given, 0 received

Are ATM orders Suitable in a NinjaScript (or better avoid it)

Hello sir,

This is a copy of a question I asked the support forum

I’m wondering if it is suitable to use ATM orders within a NinjaScript

I quote you Help section considering the “AtmStrategyClose()” method

Cancels any working orders and closes any open position of a strategy by first modifying any existing target orders so they are filled or submitting a market order if no target orders exist.

Method Return Value

Returns true if the specified ATM strategy was found; otherwise false. [COLOR="YellowGreen"]True in NO WAY indicates that the strategy in fact has been closed
. It indicates that the the specified ATMstrategy was found and the internal close routine was triggered”[/COLOR]

The green colored part worries me a lot because I based all my entries on ATM

I enter “Short” (let’s say) with the following code

private void GoShort(){


Print(ChartName + " VENTE EST LANCE "+String.Format("{0:HH:mm:ss}",DateTime.Now)+" "+Price);

if (orderId.Length == 0 && atmStrategyId.Length == 0)


atmStrategyId = GetAtmStrategyUniqueId();

orderId = GetAtmStrategyUniqueId();

AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, Low[0], 0, TimeInForce.Gtc, orderId, "MoBenOrder", atmStrategyId);


Positions[0].MarketPosition = MarketPosition.Short;


Disregard the Print and the last market position is short. We know it is short, but since I hired a C# programmer, I don’t want to change his code

And I close (and this is where I’m worried) with the following code

private void StopOrder(){

if(Positions[0].MarketPosition == MarketPosition.Long){


Print(ChartName + " STOP ACHAT "+String.Format("{0:HH:mm:ss}",DateTime.Now)+" "+Price);

if(orderId.Length > 0)


atmStrategyId = string.Empty;

orderId = string.Empty;


if(Positions[0].MarketPosition == MarketPosition.Short){


Print(ChartName + " STOP VENTE "+String.Format("{0:HH:mm:ss}",DateTime.Now)+" "+Price);

if(orderId.Length > 0)


atmStrategyId = string.Empty;

orderId = string.Empty;


Positions[0].MarketPosition = MarketPosition.Flat;


What would you tell me

1. ReWrite all the entries so that I don't use ATM in the script

2. Carry on with The Atm. they are OK to initiate orders in a ninja strategy

Shortly rephrased. How does one makes 100% sure that the ATM order was closed" whether or not a Target or a stop loss" has been reached

Thanks In Advance,

Benoit Winckelmans

Last edited by benwincky; August 11th, 2013 at 08:29 AM.
Reply With Quote

Old August 11th, 2013, 01:15 PM   #2 (permalink)
Elite Member
Mumbai, India
Futures Experience: Intermediate
Platform: MT4, NT7,eSignal
Broker/Data: AMP/CQG
Favorite Futures: ZB,ZN,ES,currencies
indiantrader's Avatar
Posts: 105 since Jul 2010
Thanks: 311 given, 130 received

This post has been selected as an answer to the original posters question Answer

Its okay to use ATM strategy in ninjascript, only thing is you cannot backtest them, but only test them on market replay or live.
However, if you want to backtest, then unmanaged approach would be the best with orders handling as an IOrder object.

Instead of Position.MarketPosition==MarketPosition.Short
you should have

Check out this post of a sample ATM based ninjascript strategy.

Reply With Quote

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > Are ATM orders Suitable in a NinjaScript (or better avoid it)

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced managed orders ninjascript with intrabar granularity iPipper427 NinjaTrader Programming 7 June 4th, 2013 11:21 PM
Strategy creating to many orders with ATM ryangillespie NinjaTrader Programming 3 January 22nd, 2012 10:22 AM
NOT Suitable for delicate Americans!! dee50 Jokes 0 December 4th, 2011 10:15 AM
White House Orders Review Of Energy Department Loans To Avoid Solyndra Subpoena And E Quick Summary News and Current Events 0 October 28th, 2011 03:59 PM
ATM and Limit Orders spinnybobo NinjaTrader Programming 6 June 12th, 2010 08:06 PM

All times are GMT -4. The time now is 10:21 AM.

Copyright © 2016 by All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts

Page generated 2016-10-23 in 0.08 seconds with 23 queries on phoenix via your IP