Heiken Ashi in Cbot

Created at 01 Dec 2018, 18:10
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!
NG

nguyendan81985

Joined 24.10.2018

Heiken Ashi in Cbot
01 Dec 2018, 18:10


Hi, 

Im writing Cbot with HA candle, but i dont know how to convert HA candle to Cbot, Anybody help me to use HA candel in Cbot?

for example :

If (HAclose.result.last(1) > ema34.result.last(1)) 

{ Open Buy position

...

}

or

if (HAclose.result.HascrossAbove(ema34.result, 1)

{Open Buy position

...

}

Thanks.


@nguyendan81985
Replies

PanagiotisCharalampous
03 Dec 2018, 10:59

Hi nguyendan81985,

Heikin Ashi are currently not available in cTrader Desktop and cTrader Automate API. If you are using the Heikin Ashi indicator, then you need to develop an Output parameter first before using in in your cBot.

Best Regards,

Panagiotis


@PanagiotisCharalampous

nguyendan81985
03 Dec 2018, 11:32

RE:

Panagiotis Charalampous said:

Hi nguyendan81985,

Heikin Ashi are currently not available in cTrader Desktop and cTrader Automate API. If you are using the Heikin Ashi indicator, then you need to develop an Output parameter first before using in in your cBot.

Best Regards,

Panagiotis

Hi Panagiotis Charalampous,

 

i am using HA indicator as link: https://ctrader.com/algos/indicators/show/60

and i convert to Cbot as code below, and ther is Error when Cbot running: "Error CS0103: The name 'haOpen' does not exist in the current context"

Could you help me to fix it?

protected override void OnBar()
        {
            var open2 = MarketSeries.Open.Last(2);
            var high2 = MarketSeries.High.Last(2);
            var low2 = MarketSeries.Low.Last(2);
            var close2 = MarketSeries.Close.Last(2);

            var open1 = MarketSeries.Open.Last(1);
            var high1 = MarketSeries.High.Last(1);
            var low1 = MarketSeries.Low.Last(1);
            var close1 = MarketSeries.Close.Last(1);

            var haClose1 = (open2 + high2 + low2 + close2) / 4;
           var haClose = (open1 + high1 + low1 + close1) / 4;

            if (haOpen > 0)
            {
                haOpen = (haOpen + haClose1) / 2;
            }
            if (haOpen == 0)
            {
                haOpen = (open1 + close1) / 2;
            }

            var haHigh = Math.Max(Math.Max(high1, haOpen), haClose);
            var haLow = Math.Min(Math.Min(low1, haOpen), haClose);
            
        }

 


@nguyendan81985

PanagiotisCharalampous
03 Dec 2018, 12:15

Hi nguyendan81985,

You get this error because haOpen is not declared. I am a bit confused about what you are trying to do. Why don't you just call the indicator from within the cBot?

Best Regards,

Panagiotis


@PanagiotisCharalampous

nguyendan81985
03 Dec 2018, 12:36

RE:

Panagiotis Charalampous said:

Hi nguyendan81985,

You get this error because haOpen is not declared. I am a bit confused about what you are trying to do. Why don't you just call the indicator from within the cBot?

Best Regards,

Panagiotis

Hi Panagiotis Charalampous,

as my first post, i want to wite Cbot as example:

If haopen(1) > ema34(1)

Buy Open ...

and i want to declare haopen, haclose ... value. but there is error and i dont know to fix it. 


@nguyendan81985

PanagiotisCharalampous
04 Dec 2018, 10:44

Hi nguyendan81985,

The proper solution to this would be to make haOpen and haClose as output parameters in the indicator, call the indicator from the cBot and then use HasCrossedAbove and HAsCrossedBelow from the cBot to make the check. It will require some effort to do this so if you need some professional help, I would suggest that you post a Job or contact a Consultant.

Best Regards,

Panagiotis


@PanagiotisCharalampous