Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy that would exit a chart manually entered position

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

    strategy that would exit a chart manually entered position

    little direction please
    trying to create a strategy that would only EXIT already existing position on the chart, that was entered manually .

    So the strategy checks the ACCOUNT position

    if (Position.MarketPosition == MarketPosition.Long && Close[0]< SMA(10)[0]) ExitLong();

    Not exiting. What am I doing wrong?

    is it because the strategy has 0 position vs account ?
    I am starting the strategy with : StartBehavior = StartBehavior.AdoptAccountPosition;




    #2
    Hi dadarara, thanks for your question.

    Your strategy must adopt the account position, then detect the market position. I tested my entering the market and applying the following strategy, setting the start behavior to "Adopt account position" e.g.

    Code:
        public class ExitStrategy : Strategy
        {
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    //...
                    IsAdoptAccountPositionAware = true;
    
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                if(State == State.Historical) return;
    
                if (Position.MarketPosition == MarketPosition.Long)
                {
                    ExitLong();
                }
            }
        }
    ​​​​​​​Kind regards.

    Comment


      #3
      Chris
      How do I get the strategy periodically synced to the current account position (on every OnBarUpdate cycle ) and not only on strategy first run ?

      Comment


        #4
        Hi dadarara, thanks for your reply.

        The startup behavior runs once at the enablement of the strategy. The current design would not allow the strategy to re-sync after its enabled.

        Please let me know if I can assist any further.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        20 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        119 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        45 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X