NexusFi: Find Your Edge


Home Menu

 





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


Discussion in NinjaTrader

Updated
    1. trending_up 2,610 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

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

  #1 (permalink)
 benwincky 
Brussels Belgium
 
Experience: Beginner
Platform: Ninjatrader
Broker: GAINCAPITAL/Forex.com
Trading: Forex
Posts: 14 since Mar 2013
Thanks Given: 5
Thanks Received: 0

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

“Definition
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(){

//EnterShort();

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){

//ExitLong();

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

if(orderId.Length > 0)

AtmStrategyClose(atmStrategyId);

atmStrategyId = string.Empty;

orderId = string.Empty;

}

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

//ExitShort();

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

if(orderId.Length > 0)

AtmStrategyClose(atmStrategyId);

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 
kkfx's Avatar
 kkfx 
Mumbai, India
 
Experience: Intermediate
Platform: MT4, NT8,TradingView
Broker: AMP
Trading: Index,currencies
Posts: 116 since Jul 2010
Thanks Given: 325
Thanks Received: 160

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
GetAtmStrategyPosition(atmStrategyId)==MarketPosition.Short

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


Reply With Quote




Last Updated on August 11, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts