Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Using Market.Position in indicator from addon
Collapse
X
-
Using Market.Position in indicator from addon
Im working on an indicator that submits orders when conditions are met, i currently use an add on to get ATM Insturment QTY and Account from chart trader, the indicator takes the trade, but the problem is that it calculates on each tick so i wanted to use this to take only one trade if flat or reverse when long, is there anyway i can get around this? could i pass it as a string value from an event?
-
code im using
if(Position.MarketPosition == MarketPosition.Flat)
{
Order mar****rder = account.CreateOrder(Instrument, OrderAction.Buy, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, 1, 0, 0, string.Empty, "Long conditional", new DateTime(), null);
account.Submit(new Order[] { mar****rder });
}
else if(Position.MarketPosition == MarketPosition.Short)
{
Order mar****rder = account.CreateOrder(Instrument, OrderAction.BuyToCover, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, 1, 0, 0, string.Empty, "Long conditional", new DateTime(), null);
account.Submit(new Order[] { mar****rder });
}
else
{
}
-
i found a work around but its only registering long or short, i can close them but cant enter a new position when flat, any suggestions would be greatly appreciated
int marketPosition = 0;
lock (Account.All)
account = Account.All.FirstOrDefault(a => a.Name == acct);
if (account != null)
{
lock (account.Positions)
{
foreach (Position position in account.Positions)
{
if (position.MarketPosition == MarketPosition.Long)
{
marketPosition = 1;
Print("LONG");
}
else if (position.MarketPosition == MarketPosition.Short)
{
marketPosition = 2;
Print("SHORT");
}
else if(position.MarketPosition == MarketPosition.Flat)
{
marketPosition = 3;
Print("FLAT");
}
Comment
-
I solved it, new here, not sure how to delete this post, so if an admin see this you can get rid of it
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
155 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
307 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
244 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
345 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
176 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment