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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    368 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    571 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X