Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position does not close

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

    Position does not close

    I tryed a symple system with the fisherTransform Indicator. The Problem is, if I call the strategy, the long / short positions does not change. If the first trade is long in the chart, it is always long. When fisherTransform moved from <0, this trade is not (never) closed.



    if (FisherTransform(Fisher)[0] > 0) // now go long, after closing short trade
    {

    if(Position.MarketPosition == MarketPosition.Short)
    {
    ExitShort("", "ExShort");
    }

    if(Position.MarketPosition == MarketPosition.Flat)
    {
    EnterLong(1, "GoLong");
    }

    }


    // Condition set 2


    if (FisherTransform(Fisher)[0] < 0) // now go short after closing long trade
    {
    PrintWithTimeStamp("S..01.. , "+Position.MarketPosition+"");
    if(Position.MarketPosition == MarketPosition.Long)
    {
    PrintWithTimeStamp("S..02.. , "+Position.MarketPosition+"");
    ExitLong("", "ExLong");
    PrintWithTimeStamp("S..03.. , "+Position.MarketPosition+"");
    }
    PrintWithTimeStamp("S..04.. , "+Position.MarketPosition+"");

    if(Position.MarketPosition == MarketPosition.Flat)
    {

    EnterShort(1, "GoShort");
    }
    }


    The problem is, that the trade in the chart is starting with long, but the longside is never closing. Now is the fisherTransform < 0 and I get in my output window

    S..01.. , long
    S..02.. , long
    S..03.. , long
    S..04.. , long

    But, why is the position not closed between S..02 and S..03 ??

    Thanks, Torso

    #2
    Hello,

    Thank you for your forum post.

    The reasoning for this is the Market Position Instrument is only updated at the End of OnBarUpdate. So when you ExitLong(), MarketPosition is not guaranteed to be updated until after the OnBarUpdate, this is due to the delay in processing the order and the object oriented nature of the approach.

    So you would need to wait for one OnBarUpdate to make this change or do not use MarketPosition to determine entry condition in the same OnBarUpdate call.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    60 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    148 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    98 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    286 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X