Trade Signal from simple Method
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
Replies
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 codethis way you're comparing 2 values and it will work
Hi Cyfer,
works!
Thank you!
@Mikro
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 :
this way you're comparing 2 values and it will work
@cyfer