you can have a state variable .
0 means you have nothing and are expecting a cross above 70
1 means you have a cross above 70 and you are expecting a cross below 30
2 means you have all
You then check your state everytime a cross occurs
If a cross occurs above 70:
- if you are at 0 you set state to 1
- if you are at 1 you keep it 1
if a cross occurs 30->70:
- you set the state to 0
if a cross occurs below 30:
- if you are at 0 you stay at 0
- if you are at 1 you go to 2
- if you are at 2 you stay at 2
you can have a state variable .
0 means you have nothing and are expecting a cross above 70
1 means you have a cross above 70 and you are expecting a cross below 30
2 means you have all
You then check your state everytime a cross occurs
If a cross occurs above 70:
- if you are at 0 you set state to 1
- if you are at 1 you keep it 1
if a cross occurs 30->70:
- you set the state to 0
if a cross occurs below 30:
- if you are at 0 you stay at 0
- if you are at 1 you go to 2
- if you are at 2 you stay at 2
Thanks for your reply. Another image is attached (with levels adjusted to 40-60 for illustration only).
In your message you kindly suggested that
if a cross occurs below 30:
- if you are at 0 you stay at 0
- if you are at 1 you go to 2
- if you are at 2 you stay at 2
I'd like to know if there could be two criteria?
1. Your suggestion which could be Cycle A.
2. Cycle B : A cross below 30 (if you are already at 0) becomes 3 and then a further cross above 70 becomes 4.
If this is possible how might you decide (if doing a look back) which cycle you are in?
Finally, if trying to code this, should I start with a loop operator, or something else?
Thanks again for your help.
Can anyone offer some advice to my last reply?
Many thanks
I'm not totally sure if I got your points right, but I have a brief idea, hopefully it'll work. So basically you store the past signals in a buffer list of say length 4. Whenever a cross happens, you check whether it's above 70 or below 30, if so you append it into the buffer list(above 70 signal is 1 and below 20 signal is 0), when the buffer list is full, you pop the first one so that the buffer list always is the most recent 4 signals. Then whenever you have a signal, you look back on the buffer list and check the order accordingly, if there're consecutively same numbers then this is false signal and vice versa.
Hi, that sounds logical. I'm currently trying to understand which functions to use to create a suitable code. Do you have any examples you could show me?
Thanks
Hi, that sounds logical. I'm currently trying to understand which functions to use to create a suitable code. Do you have any examples you could show me?
Thanks
i recommend that you search codebase and look for indicators and eas for candle patterns and oscilator deviations. The deviations search should help you most. But both deviations and candle pattern keep track of where price or the maximum and minimums of some indicator was in the past to detect either a deviation of an indicator, OR whether a special candle formation has happened.
Hi, that sounds logical. I'm currently trying to understand which functions to use to create a suitable code. Do you have any examples you could show me?
Thanks
I think that hard thing about this is that they don't have pushback() function for array to automatically adjust the whole array. So I think you probably have to create a function yourself to 1.delete the last value in the global buffer array. 2. move every value to the next index. 3. add the new value to index 0.
ArraySize() will be a useful function for this task.

- 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,
I'm trying to create a function that would check for a previous / developing crossover pattern using the stochastic oscillator.
Attached is an image to better explain what I'm trying to achieve.
Essentially I'd like to know when a multi part crossover occurs, the criteria is a first cross above the level 70, and then a move down through the level 30, without another cross occurring between the levels.
Crossing whilst between the levels would reset the count?
Because I'm a beginner, I can't quite grasp which function/expressions to use.
If anyone can give some advice / links where to start, or model an idea, it would be great. I'm keen to do the work myself, I just need pointing in the right direction.
Thanks.