Only two trades per day

Created at 19 Jan 2014, 17:03
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!
Cerunnos's avatar

Cerunnos

Joined 27.06.2013

Only two trades per day
19 Jan 2014, 17:03


Hi guys. Can somebody help me with a code where only 2 trades per day are possible: Server.Time and...??


@Cerunnos
Replies

Old Account
19 Jan 2014, 18:07

Something like this?

 

private int _TradeCount;
        private int _TradeDay;

        protected override void OnStart()
        {
            _TradeCount = 0;
        }

        protected override void OnTick()
        {

            bool _TradeOk = _TradeCount <= 2;

            if (Server.Time.Day == _TradeDay + 1)
                _TradeCount = 0;

            if (......&& _TradeOk)
            {
                _TradeDay = Server.Time.Day;
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000);
                _TradeCount = _TradeCount + 1;

            }


        }

 


@Old Account

Cerunnos
19 Jan 2014, 18:54

RE:

Exactly :-) Thanks for your help

MRSV said:

Something like this?

 

private int _TradeCount;
        private int _TradeDay;

        protected override void OnStart()
        {
            _TradeCount = 0;
        }

        protected override void OnTick()
        {

            bool _TradeOk = _TradeCount <= 2;

            if (Server.Time.Day == _TradeDay + 1)
                _TradeCount = 0;

            if (......&& _TradeOk)
            {
                _TradeDay = Server.Time.Day;
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000);
                _TradeCount = _TradeCount + 1;

            }


        }

 

 


@Cerunnos

Cerunnos
21 Jan 2014, 16:00

I think because of the weekends you have to code:

if (Server.Time.Day > Trade_Day)
                {
                _TradeCount = 0;
                }                  

instead of

if (Server.Time.Day == _TradeDay + 1)
                _TradeCount = 0;

 


@Cerunnos