I have very little programming experience and have two questions that are probably really simple.
1. How do you compare the opening or closing price to an indicator (specifically a 50 period DEMA)?
I tried:
if (Open[0] > DEMA(50))
{
Do the Following
}
// This gives me a CS0019 error which says the types of data can't be compared. Wouldn't the opening price be an int and the DEMA value also be an int?
After I tried to get the top code to work for a while I thought I had a smart idea of building the condition in the strategy builder and copying the code to the indicator I am trying to create. I copied this code from the Strategy Builder.
protected override void OnStateChange()
{
else if (State == State.DataLoaded)
{
DEMA1 = DEMA(Close, 50);
}
}
protected override void OnBarUpdate()
{
if ((Open[0] > DEMA1[0]) && (Close[0] > DEMA1[0]))
{
}
}
// This gives a CS103 error and says that DEMA1 does not exist in the current context.
2. I am trying to write: if the opening price of the previous candle plus x number of ticks equals the closing price of the current bar. Is the following code right?
if ((Open[1] + (x * TickSize)) == Close[0])
{
}
Thanks in advance for any help.
Comment