
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
simoncs:
Each time Swingdate[0] changes
- calculate the number of bars that have crossed the Fib61 line
despite having read all the help docs, loops and arrays always screw me. let me know if this isn't clear and i will try to put together a visual example.4. that was just the last iteration that i tried - i have tried too many examples to list all that code.
Another example of a loop - - I thought maybe that i could use...
thinking that i make the start of the loop equal Swingdate[0] and then count forward to the current bar, but i don't think i constructed this properly.My thinking being each time there is a new Swingdate[0],start the loop at that bar, then count forward to the current bar, and increase RetraceBarCount only if the criteria is met.
as for the code where the Swingdate[0] and fib61 is reset...
Swingdate[0] being part of the SwingDate[Found] array is continually changing.
each time there is a new zigzag i reset a number of variables including the LowRetracePrice and the HighRetracePrice
ihave amended as follows, so that the once per bar code is inside the loop,but the Retrace Bar count still seems to increment each new bar without considering the criteria.
any ideas?
Trend=UpTrend; } else Trend=DownTrend;
If not make them so, or replace with:{
Fib38Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* Fib38 - MathMax(SwingValue[0],SwingValue[1])),Digits);
Fib50Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* 0.5 + MathMin(SwingValue[0],SwingValue[1])),Digits);
Fib61Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* Fib61 - MathMax(SwingValue[0],SwingValue[1])),Digits);
Fib73Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* Fib73 - MathMax(SwingValue[0],SwingValue[1])),Digits);
}
else if(Trend==DownTrend)
{
Fib38Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* Fib38 + MathMin(SwingValue[0],SwingValue[1])),Digits);
Fib50Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* 0.5 + MathMin(SwingValue[0],SwingValue[1])),Digits);
Fib61Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* Fib61 + MathMin(SwingValue[0],SwingValue[1])),Digits);
Fib73Line = NormalizeDouble(MathAbs(MathAbs(SwingValue[0] - SwingValue[1])* Fib73 + MathMin(SwingValue[0],SwingValue[1])),Digits);
}
}
yes that is neater :)
but essentially my code was calculating the correct values each time, so i don't think this is the problem.
re the code that does the counting,i had provided snippets of it in previous posts, but here is the whole function. in this latest iteration, it seems to increment once per bar, but not taking into account the criteria.
iBarShift(Symbol(),ExtZZSwingTF,i)