Fractals (Indicator) - using multiple timeframes
Fractals (Indicator) - using multiple timeframes
15 May 2023, 17:42
Hello traders...
Got a quick question. I have a fair amount of experience with cAlgo and I'm creating a new Robot and would like to be able to use the Fractals indicator against a number of timeframes simultaneously.
However, the Fractals Indicator appears to be an abstract class implementation that only takes a single parameter of period. This therefore would indicate that any results from the base.Indicator.Fractal(period) will only be based on the current timeframe.
In my scenario, I'd like to do something like the following:
// get H1 and H4 timeframe bars
_h1Bars = MarketData.GetBars(TimeFrame.Hour);
_h4Bars = MarketData.GetBars(TimeFrame.Hour4);
// Check for fractals on H1 and H4 timeframe
Fractals fractalH1 = base.Indicators.Fractals(_h1Bars, 5);
Fractals fractalH4 = base.Indicators.Fractals(_h4Bars, 5);
I'd then like to make a number of comparisons on these as well as a few other values, i.e.
if (fractalH1 != null && fractalH1.UpFractal.LastValue > _h1Bars.LastBar.Close
&& fractalH4 != null && fractalH4.UpFractal.LastValue > _h4Bars.LastBar.Close)
{
// do something
}
However, I cannot see an override on the Fractals indicator that will allow me to create a pair of Fractals indicators assigned to different timeframes.
I must be missing something REALLY obvious, but can't fathom it out. Any pointers appreciated.
All the best
jim
[edit] - i did find this, which has a code section which serves up multi timeframe fractals, but wondered if there was something inbuilt:
Replies
jim.tollan
16 May 2023, 13:27
RE:
firemyst said:
That is one thing that is soooooooooooooooooo annoying with the API's Spotware created as they're not consistent across indicators.
I wrote my own multi time frame fractal indicator. Basically, I did it by getting the bars data series time frame I wanted, and then doing the calculations (eg, looking for the midpoint between x number of bars, making sure "x" is an odd number).
Is this something that you'd be willing to share?? I'm not so interested in a visual indicator,. I'm more interested in using the data generated from the multiple instances... You of course kindly point out an approach, but it would be nice to have (even a cut down) version of the code if that wasn't giving away any IP.
cheers
jim
@jim.tollan
firemyst
17 May 2023, 03:17
RE: RE:
jim.tollan said:
firemyst said:
That is one thing that is soooooooooooooooooo annoying with the API's Spotware created as they're not consistent across indicators.
I wrote my own multi time frame fractal indicator. Basically, I did it by getting the bars data series time frame I wanted, and then doing the calculations (eg, looking for the midpoint between x number of bars, making sure "x" is an odd number).
Is this something that you'd be willing to share?? I'm not so interested in a visual indicator,. I'm more interested in using the data generated from the multiple instances... You of course kindly point out an approach, but it would be nice to have (even a cut down) version of the code if that wasn't giving away any IP.
cheers
jim
1) Go to the top of this webpage and under "algorithms", select "indicators".
2) Click the magnifying glass search icon on the top right
3) in the search box, put in the word "fractals" and then click search
4) discover how the world is your oyster with all the samples you find
@firemyst
firemyst
16 May 2023, 05:43
That is one thing that is soooooooooooooooooo annoying with the API's Spotware created as they're not consistent across indicators.
I wrote my own multi time frame fractal indicator. Basically, I did it by getting the bars data series time frame I wanted, and then doing the calculations (eg, looking for the midpoint between x number of bars, making sure "x" is an odd number).
@firemyst