Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Here is my strategy that does what you ask. After a manual entry, start the strategy. You have to enter the date and time when you want the strategy to become effective. This is a bother, but necessary for tailstop flexibility. It will exit when RSI crosses above the oversold level, or on stoploss, or profit limit, or on a tail stop. You can easily modify the strategy for whatever your exit plan is. ExitSlPlTsRsi.cs
Can you help answer these questions from other members on NexusFi?
However, I am trying to work with Account orders and not IOrder objects. I haven't found a way of getting IOrder object from Account Order. Idea is I can enter position manually and then enable strategy which will pick up the current position (which is working fine).
Then I want my strategy (or myself even before I start strategy) to place limit order.
If/When NinjaTrader is restarted - it should be able to get list of current "Working" orders - which I know how to do.
Problem is when order actually gets filled or partially filled - I want to get notified at this exact moment that execution has occured...
And as I am writing it - I tried using different event and found out that even OnPositionUpdate happens as any of the limit orders get filled... that opens a way for me to look for collection of orders and check their status to determine what has actually happened...
Thanks for replying anyway! I think I can move on now...
The only problem - it works only for first limit order. Second limit order in a row doesn't trigger this event unless I disable/enable strategy in NinjaTrader...
Here are functions I created to get current "Manual" position:
public double NtGetUnrealizedNotional(Account account, Instrument instrument)
{
Position myPosition = account.Positions.FindByInstrument(instrument);
if (myPosition == null)
{
return 0;
}
return myPosition.GetProfitLoss(Close[0], PerformanceUnit.Currency);
}
public int NtGetUnrealizedQuantity(Account account, Instrument instrument)
{
Position myPosition = account.Positions.FindByInstrument(instrument);
if (myPosition == null)
{
return 0;
}
return myPosition.Quantity;
}
With regards to limit orders - I wonder is there an answer to maybe this thread as alternative (get notified when specific price touches, and then just send a Market order) - prefer to have even and not to do polling from the strategy.
I prefer to run my strategy on every close bar and not on open.
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
Posts: 173 since Aug 2009
Thanks Given: 105
Thanks Received: 61
it sounds like you are basically saying you want to be notified when an execution actually happens rather than it would happen "delayed" if you put your methods inside of OnBarUpdate() ?
try putting NtGetUnrealizedNotional(Account account, Instrument instrument) inside of OnExecution.
If your "limit order" you use is called
A guy from Ninja actually said it is better to put order information inside of OnOrderUpdate
and to put non order stuff like calculating PnL and stuff inside of OnExecution
This is because order information always happens in correct sequence inside of OnOrderUpdate, but is not guaranteed to happen in correct sequence inside of OnExecution since Ninja's multithreaded nature, etc..