I currently have an indicator I am coding which works in two stages.
Stage 1: To detect signal
Stage 2: confirm the detected signal
When I try to use flag to confirm signal in stage 2, it doesn't work. But same flaging method works well for EA.
Please anyone with help on how I can flag and achieve this with indicators??
Like in the example below. When arrow signal is detected, the indicator should print another confirmation when
Previous candle (candle 1) closed below the low of the candle befor it (candle 2 low). Attached image below
If you're able to do it via CopyBuffer() in your EA, then you can code it into your indicator.
In the indicator, you can create a nested lookback loop with the main indicator loop, conditionally detect nonzero/non-EMPTY values (of arrows) inside the lookback loop, and save those values to variables.
It's tough to provide any specific example without seeing your code.
I currently have an indicator I am coding which works in two stages.
Stage 1: To detect signal
Stage 2: confirm the detected signal
When I try to use flag to confirm signal in stage 2, it doesn't work.
well you might have to show us what way you're trying to confirm the signal
signal
Have attached an image of the indicator. The two sell arrows represent the main signal. But I want to use this main signal as first confirmation. Then a second confirmation should happen when any proceeding candle (after the main signal ) closes below the low of another candle before it. So trying to use a flag to achieve this but find it hard
What you need to think about is creating a signal window from the time that the signal arrow came to the time that you want the signal to remain valid, because when the arrow comes, you can't be looking to confirm the signal 20 bars later as then the signal is too old...so what you want to do is make a signal window, and making a signal window is the only effective solution seeing as markets are volatile and prone to sudden changes in direction.
There are only few ways to make this work when the main calculation index is always moving.
1. Create an input to control the size of the signal window
input int InpArrowPersistBars = 5; // Signal window (0=off)
2. Create some global variables to track the state of the arrow signal (and set them when the arrow condition is met)
int lastPivotBar = -1; int lastPivotTrend = 0;
3. Adopt the following logic...lastPivotBar being the index of your arrow signal...lastPivotTrend being the arrow trend (1 for down arrow and -1 for up arrow):
if(InpArrowPersistBars > 0 && lastPivotBar >= 0) { static int updateState = 0; static int confirmationBar = 0; int barsSincePivot = i - lastPivotBar; if(barsSincePivot >= 0) { if(lastPivotTrend == 1) // down arrow { if(updateState != 1) { confirmationBar = i; // lock the index of the last down arrow updateState = 1; } int age = i - confirmationBar; if(age > 1 && age < InpArrowPersistBars && close[i] < close[i-1]) // limit the window for the signal HighPivotBuffer[i] = close[i]; } else if (lastPivotTrend == -1) // up arrow { if(updateState != 2) { confirmationBar = i; // lock the index of the last up arrow updateState = 2; } int age = i - confirmationBar; if(age > 1 && age < InpArrowPersistBars && close[i] > close[i-1]) // limit the window for the signal LowPivotBuffer[i] = close[i]; } } }
What you need to think about is creating a signal window from the time that the signal arrow came to the time that you want the signal to remain valid, because when the arrow comes, you can't be looking to confirm the signal 20 bars later as then the signal is too old...so what you want to do is make a signal window, and making a signal window is the only effective solution seeing as markets are volatile and prone to sudden changes in direction.
There are only few ways to make this work when the main calculation index is always moving.
1. Create an input to control the size of the signal window
2. Create some global variables to track the state of the arrow signal (and set them when the arrow condition is met)
3. Adopt the following logic...lastPivotBar being the index of your arrow signal...lastPivotTrend being the arrow trend (1 for down arrow and -1 for up arrow):
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I currently have an indicator I am coding which works in two stages.
Stage 1: To detect signal
Stage 2: confirm the detected signal
When I try to use flag to confirm signal in stage 2, it doesn't work. But same flaging method works well for EA.
Please anyone with help on how I can flag and achieve this with indicators??
Like in the example below. When arrow signal is detected, the indicator should print another confirmation when
Previous candle (candle 1) closed below the low of the candle befor it (candle 2 low). Attached image below