PDA

View Full Version : ATM Strategy Stop Target methods


theperm
05-18-2007, 03:41 AM
There are two problems here one i think is a bugs the other relates to help.

First one is in AtmStrategyChangeStopTarget()

I can change both Stop and Target orders sucessfully however when changing a Target order "TARGET1" it never returns true. The calling method is a delegate ive attached to a custom barupdate event (HINT: where are ninjas events at?), but it cant unsubscribe if true is not returned.

Second is your code example from the help for GetAtmStrategyStopTargetOrderStatus generates an index out of range error. (after you fix the entryOrder syntax error)
protected override void OnBarUpdate()
{
string[,] orders = GetAtmStrategyStopTargetOrderStatus("TARGET1", "idValue");

// Check length to ensure that returned array holds order information
if (orders.Length > 0)
{
for (int i = 0; i < orders.Length - 1; i++)
{
Print("Average fill price is " + entryOrder[i, 0].ToString());
Print("Filled amount is " + entryOrder[i, 1].ToString());
Print("Current state is " + entryOrder[i, 2].ToString());
}
}
}
You need to use orders.GetLength(0) to determine the length of a multi dimensional array.

in code above the for statement needs to be replaced with

string[,] orders = GetAtmStrategyStopTargetOrderStatus("TARGET1", entryATMs[level].AtmID);

// Check length to ensure that returned array holds order information
if (orders.Length > 0)
{
for (int i = 0; i < orders.GetLength(0); i++)
{
Print("Average fill price is " + orders[i, 0].ToString());
Print("Filled amount is " + orders[i, 1].ToString());
Print("Current state is " + orders[i, 2].ToString());
}
}

NinjaTrader_Ray
05-18-2007, 10:24 AM
theperm,

1) This is a bug, thank for reporting this. Its resolved for R3 update, might be a few weeks. We just released R2 within the last hour.

2) You are right, thank for pointing out this documentation error, I will update the documentation for R3 release as well

theperm
05-18-2007, 01:19 PM
There is something else regarding AtmStrategyChangeStopTarget().

When you modify a stop or target to the same price as it allready is it doesnt return true.

This makes it very difficult to write generic code to modify orders, As result i cant unsubscribe my modify handlers in my code cause of this. The only solution is to start calculating and storing lots of order prices so as not to try and modify order to the same price, all very messy indeed.

I look as modifying to the same price as being successful, and any false returns telling me an error possibly occurred.

NinjaTrader_Ray
05-18-2007, 01:28 PM
I see, let me think about this one. I will get back to you.

theperm
05-18-2007, 01:28 PM
Think about it...

If you issued a change to the same price then you obviously didnt know the order was allready at that price. If this was the case you want to know you where successfull in any event (literally!).

I quess it only matters when the outcome is critical in an encapsulated OO event driven framework. Isn't this what .NET is suppose to be all about?
Currently Ninjascript is severly crippled in this respect. Roll on when you guys open up the TradeMagic api. Until then, more adventurous developers like myself are going to try to emulate an event driven framework.

NinjaTrader_Ray
05-18-2007, 01:49 PM
What happened was some time ago, the method did not check if the price was already at the proposed change to price and therefore it would always return true. Since this check was added, it would fall to the end of the method and return false.

I will change this for the R3 release. Thanks for pointing this out.

On another note, as we gain more experience in supporting these capabilities we will roll out more of the functionality that we have.

theperm
05-18-2007, 01:59 PM
I understand your policies on supporting any advanced functionality. I dont see how it wouldnt hurt to make the entire functionality available, the API, generate an API help chm, using one of the automated tools, and make it quite clear there is no support for anything that is not mentioned in the main help/ninjascript reference.

I like to think i am smart enough to figure most things out from an API doc alone as im sure a lot of seasoned developers would.
If problems would arrise its because it would introduce to intelisense more properties and references, then you could have two modes, one that hides the unsupported api.

NinjaTrader_Dierk
05-18-2007, 10:44 PM
Most non exposed NT API functionality can not be used without a lot of support (which we can not deliver at this time). This has nothing to do with the smartness of the actual user.

theperm
05-21-2007, 09:17 AM
this modify bug is proving to be a real thorn in my side. Each time i come up with a workarround, sooner or later it lets me down. Any chance of a quick patch release sometime soon. i cant afford to wait a few weeks for R3.

NinjaTrader_Ray
05-21-2007, 03:53 PM
Possibly but can't commit at this very moment. I will let you know if we decide to release something sooner.