I am trying to code a system that acts based on the order of fractals prior to price breakout. One example is if price is breaking over the high of the last bull fractal, the system acts differently, if that bull fractal is the last fractal recorded or if a bear fractal happened between the time the bull fractal was recorded and the time that price breaks that bull fractals high.
The way I have tried to achieve this by trying to record the time of every bullFractal into bullFractalArray and the time of every bearFractal into bearFractalArray. Then, if price breaks above a bull fractal, the system acts differently based on whether the time of bearFractalArray[0] is greater or less than the time of bullFractalArray[0].
I am using a copy of the chaos fractals indicator to insert/test the code. I am only posting the code I am adding to it because Im not sure if posting the entire thing is allowed. If its allowed I can post the entire thing to make it easier for you guys.
First I declare the 2 arrays that will hold the times of the fractals above the indicator constructor.
Code: Select all
VariableSeries<DateTime> bullFractalArray;
VariableSeries<DateTime> bearFractalArray;
Code: Select all
DateTime currentTime = Bars.Time.Value;
Original function:
Code: Select all
if (PublicFunctions.DoubleGreater(m_value1, -1)){
Plot1.Set(0, m_value1);
}
Code: Select all
if (PublicFunctions.DoubleGreater(m_value1, -1)){
Plot1.Set(0, m_value1);
bullFractalArray = currentTime;
}
I then get this error:
Severity Code Description Project File Line Suppression State
Error CS0029 Cannot implicitly convert type 'System.DateTime' to 'PowerLanguage.VariableSeries<System.DateTime>
I have tried playing around with the type of the VariableSeries<DateTime> by setting it as VariableSeries<double> and trying to return a double from the year 1900 with Bars.TimeValue as well as Bars.Time.Value but still could not test it successfully to see if I got it right.
I have also tried setting the first index of bullFractalArray but it says that it is read only.
Code: Select all
bullFractalArray[0] = currentTime;
Let me know if I could improve my help post.
Thank you for your time.