Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 inanazsocial, Today, 01:15 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by rocketman7, Today, 02:12 AM
    0 responses
    10 views
    0 likes
    Last Post rocketman7  
    Started by dustydbayer, Today, 01:59 AM
    0 responses
    1 view
    0 likes
    Last Post dustydbayer  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    23 views
    0 likes
    Last Post trilliantrader  
    Started by Davidtowleii, Today, 12:15 AM
    0 responses
    3 views
    0 likes
    Last Post Davidtowleii  
    Working...
    X