Next bar needs to match direction CONFIRM 2

Created at 06 Jul 2021, 21:59
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!
WM

wmclennan77

Joined 29.06.2021

Next bar needs to match direction CONFIRM 2
06 Jul 2021, 21:59


Hi, I am in need of a specialized entry confirmation that compares the previous close price of a bar to the close of the current bar.

 

For instance, if the previous bar was in a buy direction, the current bar also needs to close in a buy direction in order to trigger the ExecuteMarketOrder(TradeType.Buy). This means that at the close of the second bar, the first and second need to be compared.

 

This works along with another type of confirmation, which is confirmed with a boolean being set to true. This first confirmation is what will tell me the direction of the first bar.

 

So far I have this from the cAlgo API:

 

if (confirm_1 == true)

{

       if (Bars.Close.Last(0) >= Bars.Close.Last(1))

       {

              confirm_2 = true;

       }

}

 

if (confirm_1 == true && confirm_2 == true)

{

       ExecuteMarketOrder(TradeType.Buy)

}

 

Please advise if possible.


@wmclennan77
Replies

PanagiotisCharalampous
07 Jul 2021, 08:32

Hi wmclennan77,

I am not sure what is the question here. What advice do you need?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

wmclennan77
07 Jul 2021, 09:23

RE:

PanagiotisCharalampous said:

Hi wmclennan77,

I am not sure what is the question here. What advice do you need?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis,

Essentially there are two confirmations required for entry. 

The first one is not mentioned here, as it's not relevant to my question. The only important thing to note about this first confirmation is that it will give me the direction of the first bar in the comparison.

After this, the second bar needs to be compared to the first on the closure of the second. If the direction matches (eg. the first bar is a buy, the second is also a buy), it's good to enter.

Basically, I need to tell if the second bar is a buy or sell relative to the first one.


@wmclennan77

PanagiotisCharalampous
07 Jul 2021, 09:26

Hi wmclennan77,

Well the condition seems correct to me.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

wmclennan77
07 Jul 2021, 21:37

RE:

PanagiotisCharalampous said:

Hi wmclennan77,

Well the condition seems correct to me.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis,

On building, there is an error described as:

"Error CS1061: 'cAlgo.API.Bars' does not contain a definition for 'Close' and no extension method 'Close' accepting a first argument of type 'cAlgo.API.Bars' could be found (are you missing a using directive or an assembly reference?)"

Am I using the wrong interface/property?


@wmclennan77

PanagiotisCharalampous
08 Jul 2021, 09:27

Hi wmclennan77,

Yes, use ClosePrices instead.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous