Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BOT open position after CloseStrategy()

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

    BOT open position after CloseStrategy()

    Hello.

    I created condition for Stop BOT after some Profit/Loss.

    But When I try to Stop it - I see that BOT after Stop opening next positions. If I use conditions Exit orders and Cancel orders - BOT close all positions correctly but it's not gives me conditions for stop BOT.
    Attached Files

    #2
    Hello vitaly_p,

    If your script is not behaving as expected you may need to use prints to debug it. The description you gave really does not provide any details on what part of your code you are having trouble with. We would only be able to answer your direct questions, if you have a general problem like you described you would need to debug the code further to find what part is having a problem. Once you do that if you are unsure why you could post that part of your code along with a questions about that code.

    Comment


      #3
      Thank you Jesse for your answer.

      I reopened my BOT and now I don't see problem Sorry for false signal.
      ​​​​​​​If I'll see this problem again - I'll send part of the code with conditions CloseStrategy().

      Have a nice day!

      Comment


        #4
        Hello Jesse

        I see problem again.
        This is part of code with Stop Conditions:
        if (Position.MarketPosition != MarketPosition.Flat && (currentPnL + Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency)) < -DailyLossDollars && DailyLossEnabled)
        {
        Print("Daily LOSS limit hit, exiting order " + Time[0].ToString());
        if (DisableImmediately)
        {
        Print("current PnL before stop : " + (currentPnL + Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency)));
        CloseStrategy("STOP BOT");
        return;
        }
        else if (ExitImmediatelyL) WiExitCancel();
        }
        if (Position.MarketPosition != MarketPosition.Flat && (currentPnL + Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency)) > DailyProfitDollars && DailyProfitEnabled)
        {
        Print("Daily Goal limit hit, exiting order " + Time[0].ToString());
        if (DisableImmediately)
        {
        Print("current PnL before stop: " + (currentPnL + Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency)));
        CloseStrategy("STOP BOT");
        return;
        }
        else if (ExitImmediatelyP) WiExitCancel();
        }

        And in attachment screenshot from Log when you can see that BOT opened position with Name from CloseStrategy...
        Could you explane me why?

        Thank you.​
        Attached Files

        Comment


          #5

          Hello vitaly_p,

          From the given code you are calling CloseStrategy with the name "STOP BOT". That is within a condition checking if the position is not flat, based on that the log image shows the strategy is closing a position it had with an order named "STOP BOT"

          You likely need to use an exit order here rather than close strategy if that is for a historical order.


          CloseStrategy() will work of the current strategy position and will not factor in any StartBehavior setting, i.e. calling CloseStrategy() while the script is in a virtual historical position could result in an unwanted position

          Comment


            #6
            Jesse, Thank you for explaining.
            I use exit orders for closing positions with conditions "Flatten" ( this condition working well) but I wold like to create additional condition for Disable BOT after closing positions by PnL limits

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            55 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            132 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X