Custom events creation

Created at 02 Dec 2013, 19:49
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!
FU

Futuresmo

Joined 13.09.2013

Custom events creation
02 Dec 2013, 19:49


Not sure if i missed it. I want create custom event. Like onPriceLevelAttained()  or onTargetAttained() for example, that would work similiar to OnTick().

The issue experienced so far with OnTick() event so far is that any complex logic overloads memory and causes cAlgo to freeze.


 


@Futuresmo
Replies

Kate
02 Dec 2013, 21:21

Something like this :)

protected override void OnTick()
{
    if (Symbol.Ask > targetPrice)
        OnTargetAttained();
}

private void OnTargetAttained()
{
    // Do something
}

 


@Kate

Futuresmo
09 Dec 2013, 17:41

Thanks Kate :)

 

I am more interested on custom event that will react on certain price attained oppose to comparing price on every tick that causes lots of CPU resources being used.


@Futuresmo

hichem
09 Dec 2013, 18:07

RE:

If you want to raise an event on a certain condition then there is no way it can be done without executing a condition clause. And since price changes at each tick, it should be done on each Tick. You can use a separate thread to do the calculations and to not block the rest of the robot, but it should be done on each tick.

comparing price on every tick is not going to use a lot of CPU resources.

Futuresmo said:

Thanks Kate :)

 

I am more interested on custom event that will react on certain price attained oppose to comparing price on every tick that causes lots of CPU resources being used.

 


@hichem

Futuresmo
09 Dec 2013, 18:57

Thanks for reply hichem. To my mind it sounds like standard event in Positions class like Positions.PriceAttained

 

 

If you want to raise an event on a certain condition then there is no way it can be done without executing a condition clause. And since price changes at each tick, it should be done on each Tick. You can use a separate thread to do the calculations and to not block the rest of the robot, but it should be done on each tick.

comparing price on every tick is not going to use a lot of CPU resources.


@Futuresmo

hichem
09 Dec 2013, 19:01

RE:

Yes it can be added to the API but internally it wouldn't be different from executing a condition on each Tick

Futuresmo said:

Thanks for reply hichem. To my mind it sounds like standard event in Positions class like Positions.PriceAttained

 

 

If you want to raise an event on a certain condition then there is no way it can be done without executing a condition clause. And since price changes at each tick, it should be done on each Tick. You can use a separate thread to do the calculations and to not block the rest of the robot, but it should be done on each tick.

comparing price on every tick is not going to use a lot of CPU resources.

 


@hichem