Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Exit on Manual Entries

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

    Strategy Exit on Manual Entries

    I'm trying to set up my strategy to help me manage and automatically exit manual entries.

    I have added
    Code:
     IsAdoptAccountPositionAware = true;
    StartBehavior = StartBehavior.AdoptAccountPosition;
    if(State == State.Historical) return;
    to the code.

    I also have "Adopt Account Position" enabled.

    My exit code is
    Code:
    if (
    (Close[1] < Open[1])
    && (BarsSinceEntryExecution(0,"",0) > 0)
    && (PositionAccount.MarketPosition == MarketPosition.Long)
    )
    {
    ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
    }
    But that doesnt seem to work.
    Any help?

    Thanks!
    Last edited by Ousher; 05-17-2022, 01:09 PM.

    #2
    Hello Ousher,

    Thank you for your post.

    I don't believe you can use BarsSinceEntryExecution here since at the time the position is entered the strategy would not be active. A strategy programmed to adopt the account position would need to be started after the entry is placed and would not know how many bars its been since the execution - that's likely why you're not seeing the exit.

    I should also note here that a strategy using IsAdoptAccountPositionAware = true and StartBehavior = StartBehavior.AdoptAccountPosition will only be able to adopt the current position when its started - entries submitted manually after the strategy is started would not be detected and would cause the strategy position to be out of sync with the account. You would need to disable the strategy each time, enter, and then restart the strategy.

    If you want to submit orders manually and then have the strategy manage those, it would be recommended to create custom buttons within the strategy to submit your entries when triggered, which you can then submit stop and target orders for from the strategy so everything is managed within it.

    You can see an example of submitting entries based on custom button presses on our User App Share here:



    Please let us know if we may be of further assistance to you.

    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X