Blocking Trading for a certain period after a certain amount of consecutive losses

Created at 30 Sep 2020, 23:23
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!
IU

iucpxleps

Joined 01.11.2017

Blocking Trading for a certain period after a certain amount of consecutive losses
30 Sep 2020, 23:23


Hi

I'm using the sample code here https://ctrader.com/forum/calgo-reference-samples/62#post-1 and getting the consecutive losses.

After it hits the limit let's say _consecutiveLosses > 5 how can pause trading until next day or any number of hours and then continue until it hits the limit again? Because there can be periods of 10 losses in a row when markets are choppy in close proximity so I want to avoid those times.

I tried getting server time (and/or daily bar open time) and adding 1 day to it with AddDays(1) when the limit is hit which is OK but I couldn't make it dynamic.

I just want to block the below Execute order according to the day or hour pause I pick after limit is hit.

ExecuteMarketOrder(TradeType.Buy, SymbolName, VolumeInUnits, label);

Below logic has some fault but not sure what exactly :)

            if (limitPause <= _consecutiveLosses)
            {
                string expirytime = Server.Time.AddDays(1).ToShortDateString();
                string expirytime2 = Server.Time.ToShortDateString();
                }

expirytime > expirytime2; then resume executing orders.

 

-thanks

 

 


@iucpxleps