Daily Strategy with execution on Timer

Created at 30 May 2016, 21:02
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!
DE

DELETED_USER

Joined 08.04.2016 Blocked

Daily Strategy with execution on Timer
30 May 2016, 21:02


Hello, 

I am running a daily strategy, which updates all indicators and variables on OnBar() event (Daily bar).

In the current strategy a trade is opened after the new bar was generated and the strategy conditions are met. 

Rather than waiting for the close, I would like to place the order 5 minutes before the close (21:55). 

Using a simple example: 

If current close > 100D MA buy 1m EUR/USD. 

So if this condition is met I want to open the trade at 21:55 (before the daily bar is generated). 

Any help would be much appreciated. 

Cheers

 

 


Replies

... Deleted by UFO ...

cyfer
31 May 2016, 16:03

You can go for something like this 

  protected override void OnBar()
        {
            if (Time.Hour == 21 && Time.Minute >= 55)
            {
                Print("Execution Time");
            }
            else
            {
                Print("We wait for the proper time");
            }
        }

You can also test Server.Time.Hour instead of Time.Hour and see what suites you 

If your strategy is based on a specific time of the day , I strongly advise against using OnTick() , its an overhead for nothing

 


@cyfer

DELETED_USER
23 Jun 2016, 11:48

Thanks for your reply. OnBar() is set to Daily, so would your code actually execute?

The strategy is based on daily bars however I want to generate the trading signal before 10pm close due to tighter spread than wait for the day open at 22:05 and just execute the order OnBar() Open. 


DELETED_USER
29 Jun 2016, 00:25

RE:

Hi Cyfer, 

Does Time.Hour use the CurrentTime in Calgo and Server.Time.Hour the Windows time of the server?

Thanks

 

cyfer said:

You can go for something like this 

  protected override void OnBar()
        {
            if (Time.Hour == 21 && Time.Minute >= 55)
            {
                Print("Execution Time");
            }
            else
            {
                Print("We wait for the proper time");
            }
        }

You can also test Server.Time.Hour instead of Time.Hour and see what suites you 

If your strategy is based on a specific time of the day , I strongly advise against using OnTick() , its an overhead for nothing

 

 


cyfer
29 Jun 2016, 02:53

Hello Marc

This Uses Your Windows Time

DateTime.Now.Hour

And Server.Time Sure uses the Server Time

There was something about the difference between Time.Hour & Server.Time.Hour that Spotware mentioned in a Thread but I Can't remember what it was . 

Is your bot using other TimeZone than UTC ?  If no , I think Time.Hour & Server.Time.Hour will be the same . but i'm not sure

best way is to Log them(Print their Values) to see the difference between them . 

 

 

 

 


@cyfer