• 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

Semi-automatic strategy

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

    Semi-automatic strategy

    Hey, I am developing a strategy and I have a question.
    The sole purpose of the strategy is getting me in the market as soon as possible when certain conditions are met, and from there on I want to be able to manage my order the way I want. Then when I exit the market I want the strategy to be 'back on track' and keep monitoring the market for additional entries.

    The issue I experience is the following:
    - When I exit the market (manually), the strategy position remains unchanged.
    ex. Long condition was met, I entered the market long, then went out of it manually. Account Position: Flat, Strategy Position: Long
    I tried manually setting Strategy's position to flat through the code, but still Unrealized PnL is being calculated and when a signal for the opposite direction is received then the strategy gets 'Flat', because there were lots remaining.
    Other thing I've tried was - keeping my 'Order' referrence in a variable
    Code:
    [...]
    if(PositionAccount.MarketPosition == MarketPosition.Flat && PositionAccount.MarketPosition != Position.MarketPosition) {
    	Position.MarketPosition = MarketPosition.Flat;
    	CancelOrder(latestOrder);
    }
    This doesn't really cancel the order (because it was closed before by me), the strategy is being considered in Sync with the account right now.

    What method should I go for to accomplish the desired result?
    Should I stick with Managed Order Execution or maybe I should go for Unmanaged?
    Or perhaps I should consider exploring ATM Strategy methods and rework my logic using them?


    Best regards, Martin.

    #2
    Hello AsterixBT,

    Thanks for your post.

    Based on your description I recommend using the ATM methods and properties through Ninjascript as this will allow the strategy to find and enter the orders then turn profit/loss control over to an ATM (template) that you can then manually adjust on the fly as you wish. Once the profit or stop is filled the strategy can then look for the next order.

    Please review the strategy "SampleATMstrategy" in your NinjaTrader strategies as this is the best-documented code for demonstrating the concept. You can test and build upon the code if you wish. To test the sample, you would need to create an ATM and save it with the specific name of: "AtmStrategyTemplate".

    In addition to the documented code sample, here is a link to the ATM methods and properties in the NT8 helpguide: https://ninjatrader.com/support/help...gy_methods.htm

    Please note that with the use of an ATM in the script, you would not be able to backtest in the strategy analyzer. You would be able to use with Playback/Market replay data.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Newtrader101, Today, 04:50 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by utilizator, Today, 06:31 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by digibob, Today, 01:13 AM
    3 responses
    13 views
    0 likes
    Last Post digibob
    by digibob
     
    Started by calebsandfort, Yesterday, 05:16 PM
    2 responses
    9 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by StevenNelson, Yesterday, 05:45 PM
    3 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jermaine  
    Working...
    X