PDA

View Full Version : Order Management


cirion
12-17-2008, 09:32 PM
Hey,

Does this following line refer to the sim account or just a live account position?

// If the strategy has terminated reset the strategy id
else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
Print("Idle");It seems to print "idle" on every bar update even when the dom is in a trade

NinjaTrader_Ben
12-18-2008, 07:19 AM
Hello,

This condition will evaluate to true when you are in an ATM strategy
"atmStrategyId.Length > 0" since the length of the array will always be greater than zero if you HAVE an ATM. This link will help:
http://www.ninjatrader-support.com/HelpGuideV6/GetAsmStrategyEntryOrderStatus.html

In this condition remove the Cbi portion "GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat". This link will help:
http://www.ninjatrader-support.com/HelpGuideV6/ASMStrategyPosition.html


Remember your conditions will only evaluate properly if you have a valid id in your atmStrategId variable.

cirion
12-23-2008, 01:17 AM
How do i cancel a pending order if price has gone X far? I enter the trade with this statement.

AtmStrategyCreate(Action.Sell, OrderType.Limit, Close[0], 0, TimeInForce.Day, orderId, "atmtemplatename", atmStrategyId);Another question i have is i want to do a no trade zone around the PP, GAP, S1 etc. While this code works i feel it is very inefficient any suggestions of a better way to go about it?

&& (Close[0] < (SessionPivotsDaily_V4(HLCCalculationMode.CalcFrom IntradayData, true, 30).PP[0] - 2.25) || (Close[0] > (SessionPivotsDaily_V4(HLCCalculationMode.CalcFrom IntradayData, true, 30).PP[0] + 2.25)))Thanks for your help

NinjaTrader_Ben
12-23-2008, 08:18 AM
Hello,


When you use ATM in NinjaScript you need to first build the template in the DOM then access it via the name within AtmStrategyCreate():
http://www.ninjatrader-support.com/HelpGuideV6/ASMStrategyCreate.html

Then cancel it via AtmStrategyCancelEntryOrder():
http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?AsmStrategyActive

If you are not sure how to build your request in the DOM use this link below. You want to enter a profit target or stop loss parameter:
http://www.ninjatrader-support.com/HelpGuideV6/PositionStrategy.html


For the no trade zone, your code looks fine. What do you feel needs improvement? Is this a condition for when NOT to trade or when TO trade; that will make all the difference of course.

cirion
12-23-2008, 02:16 PM
Thanks ben i will look into the atm side after work today.

For the no trade zone, your code looks fine. What do you feel needs improvement? Is this a condition for when NOT to trade or when TO trade; that will make all the difference of course.

I am after a no trade zone like 2pts (on the ES) around the PP, S1 S2 etc While the code will work i feel it would be better to set the PP, S1 etc numbers as a variable or put all the numbers that are in the no trade zone into an array and call against that instead of calling an indicator to do the maths again for it.

Hope that made sense.

NinjaTrader_Josh
12-23-2008, 02:36 PM
You will just have to program yourself the condition not to enter when the price is around there.

cirion
12-23-2008, 02:39 PM
You will just have to program yourself the condition not to enter when the price is around there.

Can something like this be done josh?

private string = SessionPivotsDaily_V4(HLCCalculationMode.CalcFromI ntradayData, true, 30).PP

NinjaTrader_Josh
12-23-2008, 02:41 PM
Likely not. Whatever indicator you are using is not a string. It will most likely be a double value.

cirion
01-01-2009, 08:27 PM
Firstly thanks ben and josh for all your help so far.

I am having trouble finding the syntax to use in the following code(replacing PendingLimitPrice). The goal is if at close of bar price is 1.25ticks above the limit order (so not filled) created by
AtmStrategyCreate to cancel it

if (status[2] == "Working")
&& (Close[0] > PendingLimitPrice + 1.25))
{
AtmStrategyCancelEntryOrder(orderId);
Print("Order Cancelled" );
}

NinjaTrader_Bertrand
01-02-2009, 05:39 AM
Hi cirion, you could save your limit entry price to a variable (your PendingLimitPrice) when you call the AtmStrategyCreate(). Then your cancel logic you posted should work.

cirion
01-02-2009, 05:54 PM
Hi cirion, you could save your limit entry price to a variable (your PendingLimitPrice) when you call the AtmStrategyCreate(). Then your cancel logic you posted should work.

Thank you heaps it is working perfect now :)

cirion
01-12-2009, 05:23 PM
Can you use the || in a statement like this?

((Close[0] < (PP - 1.25) || Close[0] > (PP + 1.25)) || (Close[0] < (S1 - 1.25) || Close[0] > (S1 + 1.25)) || (Close[0] < (S2 - 1.25) || Close[0] > (S2 + 1.25)))

Trying to create a no trade zone around the major support and resistance levels.

Thanks in advance

NinjaTrader_Bertrand
01-13-2009, 05:00 AM
Sure you can use the 'or else' like this cirion. You may want to express the no trade zone in terms of TickSize, this way you create more universal code working the same on more products.

cirion
01-13-2009, 03:40 PM
Sure you can use the 'or else' like this cirion. You may want to express the no trade zone in terms of TickSize, this way you create more universal code working the same on more products.

Thanks your reply was most helpful

I will do that TickSize changes to :)

cirion
01-14-2009, 07:39 PM
Does not work how i want it to, so i guess it is back to the drawing board for the deadzone.

It appears to not work at all in this form returns true all the time unless i am missing something.


((Close[0] < PPLow || Close[0] > PPHigh) || (Close[0] < S1Low || Close[0] > S1High) || (Close[0] < S2Low || Close[0] > S2High))I am thinking putting all price numbers into an array and do a Close[0] is not in array approach.

NinjaTrader_Bertrand
01-15-2009, 06:16 AM
Hi cirion, since this is a big 'or else' statment some condition will return true and therefore prevent this from being the filter you like to have for your 'deadzones' approach. Are you splitting between long / short no tradezones, or is it a more general idea? Otherwise you could simply create the no trade levels for the day and set a bool variable false when price is in those areas...

cirion
01-15-2009, 12:40 PM
There is no difference between sell and buys just a complete deadzone. What would be the easiest way to create those no trade levels in your opinion

NinjaTrader_Josh
01-15-2009, 12:48 PM
cirion,

Not sure what you mean exactly. If you don't want to trade in certain times I suggest you introduce a time filter and completely prevent any of your trading logic from processing within those times. http://www.ninjatrader-support2.com/vb/showthread.php?t=3226

cirion
01-15-2009, 12:52 PM
Thanks for the reply josh,

An example of what i am after is this.

Lets say the PP is 900.00 for the day i want a 5 * TickSize around the PP to be a no trade zone. So if Close[0] = any number between 901.25 down to 898.75 there will be no trades taken.

Hope that made sense.

NinjaTrader_Josh
01-15-2009, 01:29 PM
Bracket your trade logic with an if-statement then.

if (Close[0] > 901.25 || Close[0] < 898.75)
{
// some logic
EnterLong();

// other logic
EnterShort();
}

cirion
01-15-2009, 04:39 PM
While your suggestion will work for just the PP what about in this case.


((Close[0] < PPLow || Close[0] > PPHigh) || (Close[0] < S1Low || Close[0] > S1High) || (Close[0] < S2Low || Close[0] > S2High))Where i want to do the no trade zone around PP S1-4 and R1-4

You suggesting an if statement for each one or with this in mind is an array better? (or another way)

NinjaTrader_Josh
01-15-2009, 04:43 PM
It doesn't matter how you do it. There are many ways to skin a cat. You understand the general concept and as such it is just a matter of implementing it.