Calculating bar size help please

Created at 28 Feb 2024, 19:21
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!
CO

coppard.steve

Joined 28.02.2024

Calculating bar size help please
28 Feb 2024, 19:21


Hi there, I am new to cBot coding.

I want to open a market order to buy when the following conditions exist:

 

  1. a specific timeframe when the London and New York markets overlap. 
  2. a specific currency pair
  3. when the last 3 bars are greater than 10 pips.

how can I test for the pip size of the last bar closed?

thanks for your help.

Steve from New Zealand.


@coppard.steve
Replies

PanagiotisCharalampous
29 Feb 2024, 07:45

Hi there,

how can I test for the pip size of the last bar closed?

Here you go

 var barPipSize = Math.Abs(Bars.ClosePrices.Last(1) - Bars.OpenPrices.Last(1)) / Symbol.PipSize;

Best Regards,

Panagiotis


@PanagiotisCharalampous

coppard.steve
01 Mar 2024, 21:57 ( Updated at: 02 Mar 2024, 07:22 )

RE: Calculating bar size help please

PanagiotisCharalampous said: 

Hi there,

how can I test for the pip size of the last bar closed?

Here you go

 var barPipSize = Math.Abs(Bars.ClosePrices.Last(1) - Bars.OpenPrices.Last(1)) / Symbol.PipSize;

Best Regards,

Panagiotis

Thanks very much Panagiotis!

I've noticed at particular times when the London and New York hours overlap that the big banks move the markets, so I am trying to develop a cBot to look for these large aggressive buy and sell candles and “follow the whales” with a long or short trade. So 3 candles on a short time frame more than 20 pips could trigger an automated trade with a take profit and stop loss.

What method can I use to trigger a trade between specific UTC+3 times?

Really appreciate your help.

Thanks 
Steve


@coppard.steve

PanagiotisCharalampous
02 Mar 2024, 07:37

RE: RE: Calculating bar size help please

coppard.steve said: 

PanagiotisCharalampous said: 

Hi there,

how can I test for the pip size of the last bar closed?

Here you go

 var barPipSize = Math.Abs(Bars.ClosePrices.Last(1) - Bars.OpenPrices.Last(1)) / Symbol.PipSize;

Best Regards,

Panagiotis

Thanks very much Panagiotis!

I've noticed at particular times when the London and New York hours overlap that the big banks move the markets, so I am trying to develop a cBot to look for these large aggressive buy and sell candles and “follow the whales” with a long or short trade. So 3 candles on a short time frame more than 20 pips could trigger an automated trade with a take profit and stop loss.

What method can I use to trigger a trade between specific UTC+3 times?

Really appreciate your help.

Thanks 
Steve

Hi Steve,

There is no specific method, you would need to implement the specific checks yourself by checking Server.Time.

Best regards,

Panagiotis


@PanagiotisCharalampous

coppard.steve
04 Mar 2024, 21:54

RE: RE: RE: Calculating bar size help please

PanagiotisCharalampous said: 

coppard.steve said: 

PanagiotisCharalampous said: 

Hi there,

how can I test for the pip size of the last bar closed?

Here you go

 var barPipSize = Math.Abs(Bars.ClosePrices.Last(1) - Bars.OpenPrices.Last(1)) / Symbol.PipSize;

Best Regards,

Panagiotis

Thanks very much Panagiotis!

I've noticed at particular times when the London and New York hours overlap that the big banks move the markets, so I am trying to develop a cBot to look for these large aggressive buy and sell candles and “follow the whales” with a long or short trade. So 3 candles on a short time frame more than 20 pips could trigger an automated trade with a take profit and stop loss.

What method can I use to trigger a trade between specific UTC+3 times?

Really appreciate your help.

Thanks 
Steve

Hi Steve,

There is no specific method, you would need to implement the specific checks yourself by checking Server.Time.

Best regards,

Panagiotis

Thanks again for you help.


@coppard.steve