correct way to let run something EXACTLY one time a day (on specific time)
correct way to let run something EXACTLY one time a day (on specific time)
23 Nov 2020, 10:48
Dear Panagiotis,
I have to run a set of functions exactly ONE time a day on a specific time, so onBar is not possible, so I use onTick with the following code:
if (Time.Hour == _tradingStartHour && Time.Minute == 37 && Time.Second > 0 && Time.Second < 5)
which results in multiple running some times.
So I tried
if (Time.Hour == _tradingStartHour && Time.Minute == 37 && Time.Second == 0)
whick results that the functions are not running every day depending from the tick data.
Can you point me in the right direction to solve this problem?
Kindest regards,
Replies
xabbu
23 Nov 2020, 11:22
Dear Panagiotis,
I'm so greatfull for your knowledge and the ability to share it here - without your kind support my journey with cTrader, which I started 4 months ago, have not been possible. Today, my cBot has more than 1000 lines of code (I had to learn a little coding first) - I will implemet your suggestions imidiatly...
Kindest regards,
@xabbu
xabbu
10 Dec 2020, 13:51
( Updated at: 10 Dec 2020, 13:53 )
Dear Panatiogis,
I implemented your suggested solution a few weeks ago. It's works great. I would like to learn and gain my understanding in cTrader programming, so I would like to ask you a followup question to your solution:
Instead of constructing an own method
private void _dailyBars_BarOpened(BarOpenedEventArgs obj)
{
_allowTrading = true;
}
would placing the "_allowTrading = true;" in the onBar method of the cBot works the same?
Why did you choose your solution instead of using the already existing onBar method? Is there any kind of difference or unwanted side effects when using onBar?
on a daily timeframe, I have to add
Kindest regards,
@xabbu
PanagiotisCharalampous
10 Dec 2020, 14:44
Hi xabbu,
if you plan to run the cBot only on D1 timeframe, then placing the code in OnBar() should work as well.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Nov 2020, 11:00
Hi xabbu,
Here is an approach
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous