How do you compare indicators?

Created at 20 Sep 2020, 15:04
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!
CA

caglar_G

Joined 20.09.2020

How do you compare indicators?
20 Sep 2020, 15:04


Hi there!

I've recently began working on a simple bot that compares SMAs and gives a hint when the SMAs cross eachother.
The periods I wanted to compare were 5 and 25.

So I thought "Huh, how hard can it be?"

With that in mind, I imagined doing something like this:
 

#Definitions of res1 and 2

            Result1[index] = SMA1.Result[index];
            Result2[index] = SMA2.Result[index];            
#Comparison
            Result1 >= Result2 ? Console.WriteLine("This is where you should buy ") : Console.WriteLine("Don't buy");

This seemingly innocuous solution should've worked or so I thought. 

Thats when I got the error "Error CS0019: Operator '>=' cannot be applied to operands of type 'cAlgo.API.IndicatorDataSeries' and 'cAlgo.API.IndicatorDataSeries'"

Does anyone know the "proper" way to compare indicators like this?

 

Thank you in advance!


@caglar_G
Replies

PanagiotisCharalampous
21 Sep 2020, 08:53

Hi caglar_G,

Try this instead

Result1[index] >= Result2[index]

Best Regards,

Panagiotis 

Join us on Telegram 

 


@PanagiotisCharalampous