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
|