Strategy Position and Account Position - futures io
futures io futures trading



Strategy Position and Account Position


Discussion in NinjaTrader

Updated by spinnybobo
      Top Posters
    1. looks_one spinnybobo with 8 posts (0 thanks)
    2. looks_two ninjauser with 4 posts (0 thanks)
    3. looks_3 sam028 with 2 posts (4 thanks)
    4. looks_4 Camdo with 1 posts (0 thanks)
    1. trending_up 6,563 views
    2. thumb_up 5 thanks given
    3. group 6 followers
    1. forum 15 replies
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

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

 
Search this Thread
 

Strategy Position and Account Position

(login for full post details)
  #1 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received

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.
It seems as though I am having a hard time accessing the Account Position direction and AvgPrice from the Strategy.
When I Sync Account Position = True, it simply Flattens the position that I am already in. I don't want it to flatten, I want it to show up as a Position somewhere.

Maybe I can do it as an Unmanaged = True and just program it in a way that I handle everything, so no OCO needed

I was hoping to access something that said what my position is OnStartUp() and Cancel any open orders, then apply my stop using SubmitOrder(.....) and then tighten it accordingly.

I kind of want my entries to be manual, and the stops to be from the strategy. But I don't want to use ATM since I need to have control of how it is tightened based on the "Swing" indicator.

So I don't think there is anything supported and I am actually somewhat surprised since it seems like I have heard of people complaining that they don't want the Sync Account Position to "Flatten" their position, but simply add some trade management to an already existing position.

So, thinking maybe a workaround to this is possible if I can at least access the Object for Account Position that is not from the Strategy but from the manual position.

thanks
Spencer

Follow me on Twitter Visit my Facebook Reply With Quote

Can you help answer these questions
from other members on futures io?
3x Fangdango
Traders Hideout
THINKorSWIM Scripting
ThinkOrSwim
Degiro Negative Balance Advice
Traders Hideout
I have segregated my investment and trading
Psychology and Money Management
QDEL
Stocks and ETFs
 
Best Threads (Most Thanked)
in the last 7 days on futures io
VWAP for stock index futures trading?
57 thanks
Coronavirus COVID-19
19 thanks
Price Action Kewltech Style
19 thanks
Trying to locate prop firm that purchased my automated trading system
11 thanks
Margins for MES
10 thanks
 
(login for full post details)
  #2 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,639 since Jun 2009
Thanks: 3,766 given, 4,445 received

You should try to use an indicator, and not a strategy, which has more "controls".
Take a look at NinjaTrader.Cbi.Globals.Accounts and its methods, that will allow you to control your orders yourself, without the strategy (safe) controls.
Highly unsupported, of course, but it works.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
The following user says Thank You to sam028 for this post:
 
(login for full post details)
  #3 (permalink)
Orlando, Florida
 
Experience: Advanced
Platform: NinjaTrader, TradeStation, MultiCharts, eSignal, MetaTrader
Trading: ES
 
Posts: 57 since Aug 2010
Thanks: 6 given, 73 received


You may want to have a look at the Documentation for the NTDirect.DLL file. See the section on DLL functions at the link below:

NinjaTrader Version 7

If you have any questions about our products or services please contact me via Private Message
Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to MooreTech for this post:
 
(login for full post details)
  #4 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received


sam028 View Post
You should try to use an indicator, and not a strategy, which has more "controls".
Take a look at NinjaTrader.Cbi.Globals.Accounts and its methods, that will allow you to control your orders yourself, without the strategy (safe) controls.
Highly unsupported, of course, but it works.

Hi Sam

so Indicators have more things available through its inheritance?
that is interesting. I will check it out.
But do place trades you would need a strategy right? So, I guess you would use the indicator to check for the account position through the strategy?

thanks
Spencer

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #5 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received


MooreTech View Post
You may want to have a look at the Documentation for the NTDirect.DLL file. See the section on DLL functions at the link below:

NinjaTrader Version 7

Hi MooreTech

thanks I will look into it. It seems like most of those files are located in C:\Program Files (x86)\NinjaTrader 7\bin
I tried to reference things from there like NTDirect.dll or NinjaTrader.Client.dll
but at least with the Client, it gave a bunch of problems to Ninja things when compiled. I think this is because this can mess up the "arrow direction" of the dependencies by probably creating a "dependency loop"

if you could give me an example of NTDirect.dll that would be great. thanks
Spencer

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #6 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received


sam028 View Post
You should try to use an indicator, and not a strategy, which has more "controls".
Take a look at NinjaTrader.Cbi.Globals.Accounts and its methods, that will allow you to control your orders yourself, without the strategy (safe) controls.
Highly unsupported, of course, but it works.

Hey Sam.
can you give me an example of your using statement and the object you would create?
thanks
Spencer

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #7 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,639 since Jun 2009
Thanks: 3,766 given, 4,445 received

In fact all can be done in an indicator. What's I've done is adding some extra buttons and fields to the "ChartTrader", so it's then possible to get the account name, then create an order.

See the code to create a buy limit order :
 
Code
                            
    string accName ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"].Text;

    
int quantity = (int)((NumericUpDown)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["nudQuantity"]).Value;
    if (
quantity 1)
        return;            
    
Account a null;    
    for (
int i=0;i<=NinjaTrader.Cbi.Globals.Accounts.Count-1;i++)
    {
        if (
NinjaTrader.Cbi.Globals.Accounts[i].Name == accName)
        {
            
NinjaTrader.Cbi.Globals.Accounts[i];
        }
    }            
    if (
!= null)
    {
        
Order o a.CreateOrder(Instrument,OrderAction.Buy,OrderType.Limit,TimeInForce.Day,quantity,(double)nudBuyLmtPr.Value,0,"","Buy");            
        
o.Submit();                
    }


Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
The following 3 users say Thank You to sam028 for this post:
 
(login for full post details)
  #8 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received


sam028 View Post
In fact all can be done in an indicator. What's I've done is adding some extra buttons and fields to the "ChartTrader", so it's then possible to get the account name, then create an order.

See the code to create a buy limit order :
 
Code
                            
    string accName ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"].Text;

    
int quantity = (int)((NumericUpDown)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["nudQuantity"]).Value;
    if (
quantity 1)
        return;            
    
Account a null;    
    for (
int i=0;i<=NinjaTrader.Cbi.Globals.Accounts.Count-1;i++)
    {
        if (
NinjaTrader.Cbi.Globals.Accounts[i].Name == accName)
        {
            
NinjaTrader.Cbi.Globals.Accounts[i];
        }
    }            
    if (
!= null)
    {
        
Order o a.CreateOrder(Instrument,OrderAction.Buy,OrderType.Limit,TimeInForce.Day,quantity,(double)nudBuyLmtPr.Value,0,"","Buy");            
        
o.Submit();                
    }


thank you Sam. Your always so helpful. :-) I will give this a try

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #9 (permalink)
Houston Texas
 
Experience: Advanced
Platform: NinjaTrader, MetaTrader, TradeStation
Trading: EUR/USD
 
Posts: 5 since Jun 2013
Thanks: 3 given, 1 received

Great Thread!

I have a follow up question.

After submitting "Account" order from "Account" object (let's say limit order) - how to get notification when that order gets fully or partially filled (limit order - not the market one)?

I tried looking at internal methods in the Account.cs file of NinjaTrader:
public event ExecutionUpdateEventHandler Execution;

public event OrderStatusEventHandler OrderStatus;

public event PositionUpdateEventHandler PositionUpdate;

Should I create inherited class from Account? Will then I be able to get notified when some event has occured (like Position has been updated, or Order has changed its status)?
Any sample code/idea would be very appreciated!

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 181 since Aug 2009
Thanks: 103 given, 56 received



ninjauser View Post
Great Thread!

I have a follow up question.

After submitting "Account" order from "Account" object (let's say limit order) - how to get notification when that order gets fully or partially filled (limit order - not the market one)?

I tried looking at internal methods in the Account.cs file of NinjaTrader:
public event ExecutionUpdateEventHandler Execution;

public event OrderStatusEventHandler OrderStatus;

public event PositionUpdateEventHandler PositionUpdate;

Should I create inherited class from Account? Will then I be able to get notified when some event has occured (like Position has been updated, or Order has changed its status)?
Any sample code/idea would be very appreciated!

Hello

so I might be interpreting you incorrect, but it sounds like you want to know the status of the order : i.e. PartiallyFilled, or Filled, etc..

From my experience, this is all handled via IOrders

 
Code
private IOrder entryOrder = null;
private IOrder stopOrder = null;
private IOrder targetOrder = null;

protected override void OnOrderUpdate(IOrder order)
{
     if (entryOrder != null && entryOrder == order)
     {
            if (order.OrderState == OrderState.Filled)
            {
                 // do this 
            }
           if (order.OrderState == OrderState.PartiallyFilled)
           {
                // do this
           }

     }

}
hope this is what you mean

Spencer

Follow me on Twitter Visit my Facebook Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Strategy Position and Account Position


February 13, 2015


Upcoming Webinars and Events
 

An Afternoon With futures io member TropicalTrader

Elite only
     



Copyright © 2020 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