Stopping bot issue

Created at 08 Aug 2019, 17:24
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
FU

furko.zoltan1989

Joined 29.07.2019

Stopping bot issue
08 Aug 2019, 17:24


Hello,

There is an issue with my bot:

        void OnPositionsOpened(PositionOpenedEventArgs obj)
        {
            Notifications.SendEmail("furko.zoltan1989@gmail.com", "furko.zoltan1989@gmail.com", "Sell has begun!", "Opened");

           Stop();
        }

This stop my bot after opening the position. But the only problem that this code stop all of instances which is under that bot. Could you help me how to stop just the opened instances?

Or any other suggestion to stop the bot?


@furko.zoltan1989
Replies

PanagiotisCharalampous
08 Aug 2019, 17:31

Hi furko.zoltan1989,

If you run the same code in all instances, then all instances will stop. The solution would be to filter the positions by instance and stop the cBot only if the opened position has been opened by the specific instance. You can use the position label for this puprose and have a different label for each instance. Then on OnPositionsOpened check if the position has the instance's label and act accordingly.

Best Regards,

Panagiotis


@PanagiotisCharalampous