• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit strategy for manually entered positions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • All4theticks
    replied
    Thanks for the quick reply, I did figure out a small work around for the trade plotting wrong, I ran the strategy from the strategy tab instead of from the chart. Now it shows correctly my manual trade entry price and marker, and the strategy exit price and marker. I'm still going to try and add some more of my own trade logic like you suggested. Thanks for your help

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    That is an interesting side-effect, but it does make sense, as strategies were not designed to only handle half of a trade, and always assume that they are handling both sides. Although there may not be a way to get around this with the built-in position and PnL reporting, it should be possible to include your own position and trade recognition logic in your strategy, based on the manual trades it has identified and the actions it has taken. In addition to identifying the manually entered market position, you could also identify its average price (PositionAccount.AveragePrice) and other properties.

    To solve the issue with mismatched execution plots showing on your chart, you could set the PlotExecutions property of the strategy's input series to DoNotPlot, like so:

    Code:
    ChartControl.BarsPropertiesCollection[0].PlotExecutions = ChartExecutionStyle.DoNotPlot;

    Leave a comment:


  • All4theticks
    replied
    I am now able to place a manual trade (long or short) and have my already running strategy exit the trade for me based on the ATR . My strategy never makes an entry trade it only works the exits for me on a previous manually placed trade.

    Everything seems to be working correctly but I noticed that the chart acts weird. When I place a manual long trade the trade markers do not show (which I understand because my strategy is running) but when my strategy exits the manual long trade, the marker is shown. Not a problem, although kind of annoying. Now if I decide to go short (again this wont display on the chart because of the running strategy) and then my strategy exits the trade, the chart will connect the Exit from my long trade and the Exit from my short trade. (Because these are the only two trades my strategy made it thinks they go together) If I go into strategy performance (real-time) it wont show my real trades, but it will show this fake trade. I also notice that when my strategy exits my manual long trade the strategy shows that I'm short. The Accounts tab, Orders tab, and executions tab all show the correct trades and amounts but the strategy tab shows that I'm short, Positions tab shows no active positions, which is correct.

    Although everything technically works its confusing having the strategy and chart show incorrectly. Am wondering if this is just the way it will be trying to mix manual trading with a strategy (Strategy Position vs Account Position ) or if there is something I'm doing wrong (which is a good assumption because I'm new to c#)

    I'm using unmanaged orders:
    exitOrderLong = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Market, 1, 0,
    0, "", "Exit Long - AtrMultiplier " + atrMultiplier.ToString() );

    I use this to check if a manual trade has been placed:
    PositionAccount.MarketPosition



    Thanks

    Leave a comment:


  • All4theticks
    replied
    Thanks, that worked! I didn't realize I needed to use the unmanaged approach but now that makes sense.

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    I would not recommend using ExitLong() in this scenario, as that is a managed method intended to exit a Long position entered by the strategy. I recommend using the unmanaged SubmitOrderUnmanaged() method for more precise control, based on what you find in the account position. Remember to set IsUnmanaged = true in State.SetDefaults, as well.
    Last edited by NinjaTrader_DaveI; 11-16-2015, 11:55 AM.

    Leave a comment:


  • All4theticks
    replied
    problem

    I'm trying to get my manual entered trade to be exited by a strategy, I'm just experimenting right now using:

    if(PositionAccount.MarketPosition == MarketPosition.Long)
    {
    Print("Long Trade" + PositionAccount.AveragePrice.ToString());
    ExitLong(1); //exit the trade a soon as its placed
    }

    I have these properties set: IsAdoptAccountPositionAware = true;
    StartBehavior = StartBehavior.AdoptAccountPosition;

    This will print the manual order entry price, but when I try to exit the manual trade nothing happens, ExitLong() does not exit my manually placed order. How do I exit the manual trade through the strategy code?

    Thanks for any help

    Leave a comment:


  • ShaneAU
    replied
    Thanks Matthew, I appreciate the detailed response...

    It all sounds good!
    Cheers,
    Shane

    Leave a comment:


  • NinjaTrader_Matthew
    replied
    Strategies now have a concept of Strategy Position and Account Position.

    If you wanted to check the Strategy position, you would check just like you did with NT7:

    Code:
    if(Position.MarketPosition != MarketPosition.Flat)
    {
    	// do something
    }
    If you wanted to check against the account position, you would use the PositionAccount object

    Code:
    if(PositionAccount.MarketPosition != MarketPosition.Flat)
    {
    	// do something
    }
    Both objects can be checked against each other interchangeably as long as you have IsAdopAccountPositionAware = true;

    1) NinjaTrader 8 also gives you access to a global Accounts class which is a low level object which provides you all information related to that account. This would allow your strategy to be aware of any manually place orders that are running on the same account as the strategy.

    There is not a switch which says if an order was manually submitted or strategy submitted, however there is a Strategy Orders collection and Account Orders collection you can compare against. You could apply logic which basically says if the order does not exist in the Strategy Account collection, then it was placed outside of the strategy. Providing you are giving your strategy orders a unique and explicit order.Name, you can check against that string as well to then execute whichever logic you seek.

    2) NinjaTrader 8 now allows you to enable Chart Trader from the same chart that a strategy is running, allowing you to visual the orders on the same chart the strategy is running.

    3) Thanks for your suggestion - however there is not always a lot of room on chart trader as it is, and if I understand your request, this can be done from the Strategies tab of the control center (which can now be pulled out of the control center and setup as it's own window if desired)

    4) Chart Trader hotkeys have not changed from NinjaTrader 7, but I have logged your request under tracking ID #438
    Last edited by NinjaTrader_Matthew; 06-10-2015, 07:09 AM.

    Leave a comment:


  • ShaneAU
    replied
    Hi Brett,

    Thanks for your response, much appreciated. I am not on the Ninjatrader Beta so cannot access the links you provided, but I think I understand;

    We would just enable IsAdoptAccountPositionAware in our strategy then use something like:

    If market position = long then manage long trade, and;
    If market position = short then manage short trade

    I just had some follow-up questions, to see what trading as a hybrid discretionary/automated style will be like in NT8 (for those who would place their orders through the charts);

    1) In our automated trade management/exit strategy, can we access or interact with a manually entered stop? For example, if we manually enter a position in the chart trader, we may have calculated our position size based on a certain discretionary stop-loss level (i.e. risking 1% of our account size on each trade). But if we have an automated exit strategy, it would presumably override our stop with the strategy calculated stop on the next bar updated, which would adversely affect our risk control for that position size…. If we can reference the manual stop in our strategy we can code the strategy not to move the initial manual stop unless more precise criteria is met? It would also mean, that if the user intervened and changed a stop which was set by the automated strategy, we could code the strategy to accept this change and disable the automated stop section of the strategy rather than needing to disable the whole strategy (which would have the drawback of disabling the other trade management control in the strategy which we may want to keep active).

    …Just to clarify the above: a) will the strategy recognise if a StopLoss which has been set manually? b) and if the StopLoss is recognised by the strategy, will it be able to differentiate that it was a human entered stop or will it be treated identically as if it was a StopLoss entered by the strategy itself?

    2) Will strategies be able to plot their indicators/stoploss levels/profit targets etc in the same window that has the chart trading functions, or would we need to have two identical windows open (one with the strategy and one with the chart trading)?

    3) I just wanted to add the suggestion to allow toggling of a strategy on and off from the chart trader window, so that we can quickly take over control of the strategy if needed, or so we can quickly enable the strategy if we needed to go AFK for whatever reason.

    4) Are hot keys in combination with mouse clicks possible in the chart trader - for example holding down CTRL and clicking a price level would move the stop to this level, and holding down Space Bar and clicking a price level would be a profit target or limit order etc.

    Thanks again Brett and cheers,
    Shane

    Leave a comment:


  • NinjaTrader_Brett
    replied
    Yes this is now supported in NinjaTrader 8 and its support by start behaivior called Adopt Account Position. You need to specifically add a line to your strategy to enable it (IsAdoptAccountPositionAware = true.

    Please see the documentation and let me know if any questions on the new start mode and how to use it to program a strategy to manage the exit of a manual entry.

    http://www.ninjatrader.com/support/h..._positions.htm
    http://www.ninjatrader.com/support/h...rtbehavior.htm
    http://www.ninjatrader.com/support/h...itionaware.htm

    Leave a comment:


  • ShaneAU
    started a topic Exit strategy for manually entered positions

    Exit strategy for manually entered positions

    Hi guys,

    I was wondering if it is possible to write an automated exit strategy which can be used for manually entered positions in NT8? I don't mean the ATM which just has multiple stops and targets, but something we can create using supported code that will allow full strategy exit criteria to be written and applied to our position?

    Cheers,
    Shane

Latest Posts

Collapse

Topics Statistics Last Post
Started by bc24fl, Today, 10:00 AM
3 responses
8 views
0 likes
Last Post NinjaTrader_Jesse  
Started by TonyParisi, Today, 07:38 AM
2 responses
11 views
0 likes
Last Post TonyParisi  
Started by fx.practic, Today, 10:03 AM
2 responses
7 views
0 likes
Last Post fx.practic  
Started by traderpards, 12-12-2018, 01:15 PM
6 responses
154 views
0 likes
Last Post NinjaTrader_PaulH  
Started by Cyanez, Today, 08:41 AM
1 response
12 views
0 likes
Last Post NinjaTrader_Jesse  
Working...
X