OnBar() lastValue

10 May 2019, 15:28OnBar() lastValue#1
Alexander Fedorovposts: 267since: 02 Jan 2018

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

 

10 May 2019, 15:32#2
Panagiotis Charalampousposts: 2715since: 13 Jan 2017

Hi Sasha,

OnBar is executed only whenever a new bar is created. 

Best Regards,

Panagiotis


Head of Community Management at cTrader
10 May 2019, 17:00#3
Alexander Fedorovposts: 267since: 02 Jan 2018

Then I probably have to think about 1 minute timeframe

 

10 May 2019, 17:29#4
Alexander Fedorovposts: 267since: 02 Jan 2018

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

It is available for alerts...

10 May 2019, 17:33#5
Panagiotis Charalampousposts: 2715since: 13 Jan 2017

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


Head of Community Management at cTrader
12 May 2019, 11:53#6
Alexander Fedorovposts: 267since: 02 Jan 2018

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.

 

 

12 May 2019, 11:53#7
Alexander Fedorovposts: 267since: 02 Jan 2018

Best regards

 

Alexander