Keep cbot running but pause new orders

Created at 14 Jul 2016, 11:47
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!
KR

Krecha99

Joined 21.06.2016

Keep cbot running but pause new orders
14 Jul 2016, 11:47


Hi,

I am new to C# and would like to know if there is a way to halt any new orders when equity drops below a certain level but leave the cbot running so it can still modify positions if needed. I have tried multiple searches on here to see if someone else has asked, but could not find anything. 

I have the below code which stops the cbot when a set trailing equity level is reached. I would like the cbot to keep running when the equity drops below the set level (which are set in parameters) but no new orders are placed. Then once equity is back within the limits, new order's can be placed again..

Any advice would be appreciated 

Code;

protected override void OnTick()
        {
            if (CountOfTradesOfType(TradeType.Buy) > 0)
                AdjustBuyPositionTakeProfits(CalculateAveragePositionPrice(TradeType.Buy), AverageTakeProfit);
            if (CountOfTradesOfType(TradeType.Sell) > 0)
                AdjustSellPositionTakeProfits(CalculateAveragePositionPrice(TradeType.Sell), AverageTakeProfit);
            if (CurrentSpread <= MaxSpread && !_accountIsOutOfMoney)
                ProcessTrades();


            if (!isTriggered)
            {
                if (Account.Equity >= Target)
                {
                    isTriggered = true;
                    trailingEquity = Account.Equity;
                    Print("Triggered at {0}", Account.Equity);
                }
            }
            else
            {
                if (Account.Equity - trailingEquity >= TrailDistance)
                {
                    trailingEquity = Account.Equity;
                    Print("Trailing Equity {0}", trailingEquity);
                }
                else if (Account.Equity - trailingEquity <= -TrailDistance)
                {
                    Print("Retraced equity = {0}", Account.Equity);
                    Stop();
                }
            }


            if (!this.IsBacktesting)
                DisplayStatusOnChart();


@Krecha99
Replies

... Deleted by UFO ...