Hello Forum, my newbie understanding is getting me into trouble with this code and I desperately need some help after going in circles for hours.
I am trying to adapt the fractals indicator to include additional buffers that draw arrows on the chart when price closes above the current upper fractal or below the current lower fractal.
I am not sure how to get the Close price to reference only the current upper or lower fractal, think I have the rest of the code right (see below)
I experimented with positioning of my definitions for my additional buffers, even duplicated them in each relevant { }
Also when I look at the Data Window, candles that have not got fractals attached, do not have a current fractal value and not sure how to combat this
I tried another version of the fractal indicator specified in terms of iFractal...but again struck problems referencing the current fractal
The buffers that hold the fractal values, ExtUpFractalsBuffer, ExtDownFractalsBuffer will not contain a price value for every bar, they will only have the High/Low where the bar in question is a Fractal . . . so to find the last/current upper fractal you have to look back and find it.
Strangely enough I re-wrote an indicator the other day to do exactly this.
Remember that buffers start each new bar with EMPTY_VALUE, whereas internal variables remain at the same value unless actively changed. One simple method is to use two type double variables (declared on a global scale at the beginning) - one for the "top" fractal and one for the "bottom" fractal.
Whenever a "top" fractal occurs, in the same command section where the buffer to display that peak is, you could set the relevant variable to that value. That variable will then stay as that value forevermore, until a new "top" fractal occurs.
Then you simply have a subsequent conditional which checks the close of the current bar against that variable, and draws a new buffer in whenever it is triggered. Reverse for the other direction.
This requires less code than having to check back x many bars every time. It just effectively keeps a running tally, and has no limit on the number of bars to check back.
Firstly you need to understand the code you are trying to modify . . . go through it line by line, looking up any functions you do not understand. If you will not or cannot do this then you don't have much hope of correctly modifying it.
The buffers that hold the fractal values, ExtUpFractalsBuffer, ExtDownFractalsBuffer will not contain a price value for every bar, they will only have the High/Low where the bar in question is a Fractal . . . so to find the last/current upper fractal you have to look back and find it.
thanks really good advice, generally it is individual functions that trouble me, and working out exactly how they work, regards David (ps realyl appreciate your assistance)
Strangely enough I re-wrote an indicator the other day to do exactly this.
Remember that buffers start each new bar with EMPTY_VALUE, whereas internal variables remain at the same value unless actively changed. One simple method is to use two type double variables (declared on a global scale at the beginning) - one for the "top" fractal and one for the "bottom" fractal.
Whenever a "top" fractal occurs, in the same command section where the buffer to display that peak is, you could set the relevant variable to that value. That variable will then stay as that value forevermore, until a new "top" fractal occurs.
Then you simply have a subsequent conditional which checks the close of the current bar against that variable, and draws a new buffer in whenever it is triggered. Reverse for the other direction.
This requires less code than having to check back x many bars every time. It just effectively keeps a running tally, and has no limit on the number of bars to check back.
thanks for your help
will try and implement suggested ideas
thanks really good advice, generally it is individual functions that trouble me, and working out exactly how they work, regards David (ps realyl appreciate your assistance)
thanks everyone
took me some trial and error until I understood, but got a version working that plots an arrow of one color if previous fractal was support and now the close is below that fractal level
and an arrow of a different color if the previous fractal was resistance and candle now closing above that fractal level (code attached if useful for others)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Forum, my newbie understanding is getting me into trouble with this code and I desperately need some help after going in circles for hours.
I am trying to adapt the fractals indicator to include additional buffers that draw arrows on the chart when price closes above the current upper fractal or below the current lower fractal.
I am not sure how to get the Close price to reference only the current upper or lower fractal, think I have the rest of the code right (see below)
I experimented with positioning of my definitions for my additional buffers, even duplicated them in each relevant { }
Also when I look at the Data Window, candles that have not got fractals attached, do not have a current fractal value and not sure how to combat this
I tried another version of the fractal indicator specified in terms of iFractal...but again struck problems referencing the current fractal
Hoping for some help.....and yes I am struggling with concept of arrays
thanks in advance
dave