Trade Signal from simple Method

Created at 15 Feb 2016, 23:57
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!
Mikro's avatar

Mikro

Joined 20.06.2015

Trade Signal from simple Method
15 Feb 2016, 23:57


Hi Folks,

It probably is a simple issue but I am struck.

In my trading logic I want a method to generate a Trading Signal and return a Boolean with the reslut.

As an ease start I want to compare open and close price of a timeframe with a Moving Average.

My Code looks like this:

 public bool LongSigLT()
        {
            var LTSeries = MarketData.GetSeries(TimeFrame.Hour );
            var LTSigOpen = Indicators.SimpleMovingAverage(LTSeries.Open,LTSigPeriod) ;
            var LTSigClose = Indicators.SimpleMovingAverage(LTSeries.Close,LTSigPeriod) ;
            if (LTSigOpen < LTSigClose )
            {
                return true;
            }
            else
            {
                return false;
            }
        }

The errorr Message says that the Operand "<" cannot be applied to cAlgo.API.Indicators.SimpleMovingAverage.

What am I missing?

THX


@Mikro
Replies

cyfer
16 Feb 2016, 02:10

LTSigOpen or LTSigClose is a Series of data (in this case Moving Average).. not a single value 

you should be comparing the X Value in the moving average with the Y Value in price  or Y Value in another moving average

so you should be going like that : 

LTSigOpen.Close.Last(0) < LTSigClose.Close.Last(0) //pseudo code 

this way you're comparing 2 values and it will work 

 

 


@cyfer

Mikro
22 Feb 2016, 00:03

RE:

cyfer said:

LTSigOpen or LTSigClose is a Series of data (in this case Moving Average).. not a single value 

you should be comparing the X Value in the moving average with the Y Value in price  or Y Value in another moving average

so you should be going like that : 

LTSigOpen.Close.Last(0) < LTSigClose.Close.Last(0) //pseudo code 

this way you're comparing 2 values and it will work 

 

 

Hi Cyfer,

works!

Thank you!


@Mikro