Keep cbot running but pause new orders

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