OnBar() lastValue

Created at 10 May 2019, 15:28
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!
alexander.n.fedorov's avatar

alexander.n.fedorov

Joined 02.01.2018

OnBar() lastValue
10 May 2019, 15:28


Hi Panagiotis,

 

What is going to happen if I put

protected override void OnBar()

{

                    if (MarketSeries.High.LastValue>= orderData[0, 1] )
                    {
                        ClosePosition(position);
                    }

}

The reason I am asking that it is not OnTick(), so how ofter OnBar() checks the last MarketSeries.High.LastValue?

I assume it should be as soon as the value changes. Correct?

Regards, Sasha

 


@alexander.n.fedorov
Replies

... Deleted by UFO ...

PanagiotisCharalampous
10 May 2019, 15:32

Hi Sasha,

OnBar is executed only whenever a new bar is created. 

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexander.n.fedorov
10 May 2019, 17:00

Then I probably have to think about 1 minute timeframe

 


@alexander.n.fedorov

alexander.n.fedorov
10 May 2019, 17:29

Maybe there are any events, like when the price crosses a certain line (number)

It is available for alerts...


@alexander.n.fedorov

PanagiotisCharalampous
10 May 2019, 17:33

Hi Sasha,

There is no such event available in the API, You need to make the checks yourself in the OnTick method.

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexander.n.fedorov
12 May 2019, 11:53 ( Updated at: 21 Dec 2023, 09:21 )

Hi, Panagiotis.

All of your comments and suggestions I considered  and used. Thanks a lot. As matter of fact instead of messing with Tick I used Timer.Start (10)

Did not have chance to try in a battle yet, but I think for the portfolio of about 40 pair it wll make a lot of difference in processor occupation.

The fact is even thou I am using Xeon (R) CPU E3-1230 3.50 Ghz with 32 G RAM dedicated VPS if was almost freezing on tick.

So, I think , 10 sec is quite an improvement

I will let you know when the signal comes.

It looks nice too. And the first week of exploatation made me about 5% . It is a lot of improvement in comparisson with the former version

Tell me, if you interested, I could send you a bot. In a mean time I could send you a pic.

 

 


@alexander.n.fedorov

alexander.n.fedorov
12 May 2019, 11:53

Best regards

 

Alexander

 


@alexander.n.fedorov