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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        88 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        135 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        119 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        69 views
        0 likes
        Last Post PaulMohn  
        Working...
        X