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

Entry, Exit and Position Issue

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

    Entry, Exit and Position Issue

    Using v6.5
    I have an issue with Entry and Exit in a Multi Time Frame Strategy when an Exit Condition and Entry Condition fires on the same bar. I don't believe the problem is due to the Multi Time Frame as I set the entries/exits on the condition of BarsInProgress =0. I'm attempting to manage the position/direction using local variables, but I'm sure there may be a cleaner way to do this. On the same OnBarUpdate event, can the strategy Exit one direction and Enter the other, as I've coded in the code below?

    Logs from the Executions tab;

    Time E/X Position Name
    8:40:56 Entry 1L LONG_ENTRY
    9:10:41 Exit - Sell
    9:10:41 Entry 1S Close Position
    9:10:42 Entry 2S SHORT_ENTRY
    9:49:40 Exit 1S Buy to cover



    if (BarsInProgress == 0)
    {
    //Exit Conditions
    if (_position = true)
    {
    if (_longposition = true)
    {
    if (exit_condition)
    {
    ExitLong("LONG_ENTRY");
    _longposition = false;
    _position = false;
    }
    }
    if (_shortposition = true)
    {
    if (exit_condition)
    {
    ExitShort("SHORT_ENTRY");
    _shortposition = false;
    _position = false;
    }
    }
    }

    //Entry Conditions
    if (_position == true) return;

    if (long_entry_condition)
    {
    EnterLong("LONG_ENTRY");
    _longposition = true;
    _position = true;
    }
    if (short_entry_condition)
    {
    EnterShort("SHORT_ENTRY");
    _shortposition = true;
    _position = true;
    }
    }

    #2
    Hello RhinoGG,

    You are running into our internal order handling rules here. An exit and entry will not be processed on the same bar.

    By default entries will reverse a position. If you want reversal behaviour you can combine your conditions for exit and entry and then only submit the entry order.



    Methods that generate orders to exit a position will be ignored if a strategy position is open and:
    • An order submitted by an enter method (EnterLongLimit() for example) is active and this entry order is used to open a position in the opposite direction
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kempotrader, Today, 08:56 AM
    0 responses
    6 views
    0 likes
    Last Post kempotrader  
    Started by kempotrader, Today, 08:54 AM
    0 responses
    4 views
    0 likes
    Last Post kempotrader  
    Started by mmenigma, Today, 08:54 AM
    0 responses
    2 views
    0 likes
    Last Post mmenigma  
    Started by halgo_boulder, Today, 08:44 AM
    0 responses
    1 view
    0 likes
    Last Post halgo_boulder  
    Started by drewski1980, Today, 08:24 AM
    0 responses
    4 views
    0 likes
    Last Post drewski1980  
    Working...
    X