Strategy Position and Account Position - NinjaTrader | futures io social day trading
futures io futures trading


Strategy Position and Account Position
Updated: Views / Replies:3,987 / 15
Created: by spinnybobo Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

Strategy Position and Account Position

  #11 (permalink)
Elite Member
Boston, MA / USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES
 
Posts: 203 since Apr 2013
Thanks: 2,125 given, 264 received


spinnybobo View Post
Hello,
I am currently working on a strategy that allows me to enter the trade manually in NinjaTrader and then apply a Strategy to it with stops and targets.

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

Reply With Quote
 
  #12 (permalink)
Elite Member
Houston Texas
 
Futures Experience: Advanced
Platform: NinjaTrader, MetaTrader, TradeStation
Favorite Futures: EUR/USD
 
Posts: 4 since Jun 2013
Thanks: 0 given, 0 received

Thanks,

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...

Reply With Quote
 
  #13 (permalink)
Elite Member
Houston Texas
 
Futures Experience: Advanced
Platform: NinjaTrader, MetaTrader, TradeStation
Favorite Futures: EUR/USD
 
Posts: 4 since Jun 2013
Thanks: 0 given, 0 received


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...

Reply With Quote
 
  #14 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 48 received


ninjauser View Post
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...

Hi

the event you want to use is either
 
Code
protected override void OnExecution(IExecution execution)
{

}

or 

protected override void OnOrderUpdate(IOrder order)
{

}
as for reading a manual position inside of a strategy (since Ninja holds those separate) I have not figured a way of how to do this

Reply With Quote
 
  #15 (permalink)
Elite Member
Houston Texas
 
Futures Experience: Advanced
Platform: NinjaTrader, MetaTrader, TradeStation
Favorite Futures: EUR/USD
 
Posts: 4 since Jun 2013
Thanks: 0 given, 0 received

Those events are for supported stuff

I am looking for unsupported

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.

Indicator trigger event in a Strategy - NinjaTrader Support Forum

Reply With Quote
 
  #16 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 48 received


ninjauser View Post
Those events are for supported stuff

I am looking for unsupported

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.

Indicator trigger event in a Strategy - NinjaTrader Support Forum

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

 
Code
private IOrder target1Order = null;


protected override void OnExecution(IExecution execution)
{
      if (target1Order != null && target1Order.Order == execution.Order)
      {
              if (execution.Order.OrderStatus == OrderStatus.Filled)
              {
                   NtGetUnrealizedNotional(Account account, Instrument instrument);
              }
      }
}
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..

Reply With Quote

Reply



futures io > > > > Strategy Position and Account Position

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Call ATM Strategy on an automated strategy to control position jsengxx NinjaTrader Programming 7 May 31st, 2016 05:51 PM
Contract Rollover: Adopt Real World Position and manage per previous position entry RM99 EasyLanguage Programming 3 May 30th, 2012 07:55 AM
Account balance moving up/down after closing position??? Lord Sidious Reviews of Brokers and Data Feeds 5 May 29th, 2012 06:14 PM
Drawdown & Position Sizing Account Allocation dgresens Psychology and Money Management 7 February 10th, 2012 12:07 PM
Account position: How to differentiate positions arjfca The Elite Circle 5 February 5th, 2011 03:27 PM


All times are GMT -4. The time now is 02:12 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-11 in 0.12 seconds with 20 queries on phoenix via your IP 54.226.34.209