PDA

View Full Version : use Positions[0].MarketPosition


Folls
10-16-2007, 06:43 PM
Hi,

I want to use Positions[0].MarketPosition as an argument in a method and then in the method, compare it to an integer value.

I'm trying to see if there is a certain number (for example 2) of contracts open. I figured Positions[0].MarketPosition would be an integer (positive for long, negative for short, 0 for flat). That didn't work.

I'm doing something like this in the method:

public bool Symbol1Done(int cons1, int position)
{
if (OrderType == 1 && cons1 == position)
{
Symbol1Filled = true;
return (true);
}
else
{
return (false);
}
}

What is the type and how do I compare it to an integer?

Thank you!

Folls

NinjaTrader_Josh
10-17-2007, 12:11 AM
Hi Folls,

The type MarketPosition returns is a MarketPosition type. This means you want to compare it to things like MarketPosition.Long or MarketPosition.Short instead of an int.

if (Positions[0].MarketPosition == MarketPosition.Long)
// Do somethinghttp://www.ninjatrader-support.com/HelpGuideV6/MarketPosition.html

To determine the number of contracts you have in a position you can use the .Quantity property.

if (Positions[0].Quantity > 1)
// Do somethinghttp://www.ninjatrader-support.com/HelpGuideV6/Quantity.html

Folls
10-17-2007, 06:19 AM
Thanks. That was a very detailed, thoughtful reply.

Folls