Topics
01 Jun 2018, 14:40
 1
 1301
 1
Replies

SYUNHUA
01 Nov 2021, 08:47

RE:

amusleh said:

This sample might help you:

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class PauseEvents : Robot
    {
        private bool _isPaused;

        protected override void OnStart()
        {
            Chart.MouseDown += Chart_MouseDown;
        }

        private void Chart_MouseDown(ChartMouseEventArgs obj)
        {
            if (obj.ShiftKey)
            {
                _isPaused = true;

                Print("Events paused");
            }
            else if (obj.CtrlKey)
            {
                _isPaused = false;

                Print("Events running");
            }
        }

        protected override void OnTick()
        {
            if (_isPaused) return;
        }

        protected override void OnBar()
        {
            if (_isPaused) return;
        }
    }
}

If you press shift + click then it will pause the OnTick/Bar, and if you press Ctrl + Click then it will allow the code on OnTick/Bar after is pause check to execute.

it is not working, just printed log, I have deleted onBar or Ontick to test. what else do I need to do


@SYUNHUA