Hey mate, Thanks for your time in replying. I have a handle on how to use the iHighest and BarShift to get the values, I am just unsure of how to go about getting the period count between the two crosses and the datetime of when the last cross happend.
Ahh, today some community coding... Hmm...
Someone should pay me for this.
double stoch_arr_R[]; double stoch_arr_D[]; const bool R_above_D = stoch_arr_R[index] > stoch_arr_D[index]; int cnt = index - 1; while( (cnt > NULL) && ((stoch_arr_R[cnt] > stoch_arr_D[cnt]) == R_above_D) && (!_StopFlag) ) { cnt--; } const int index_of_first_cross = cnt; cnt--; while( (cnt > NULL) && ((stoch_arr_R[cnt] > stoch_arr_D[cnt]) != R_above_D) && (!_StopFlag) ) { cnt--; } const int index_of_second_cross = cnt; const int distance_between_crosses = index_of_first_cross - index_of_second_cross; datetime first_cross = iTime(Symbol(), Period(), index - index_of_first_cross); datetime second_cross = iTime(Symbol(), Period(), index - index_of_second_cross);
index is equivalent to prev_calculated.
The index is taking into account to not analyze the current running period.
This is untested... should give an idea on how to do the job, shouldnt it.
Ahh, today some community coding... Hmm...
Someone should pay me for this.
index is equivalent to prev_calculated.
This is untested... should give an idea on how to do the job, shouldnt it.
Thanks so much Dominik, Ill have a play and try and make sense of it. Input and guidance from guys like you when learning to code is invaluable and cant thank you enough for your time.
Cheers,
Dale
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, Very new to coding and am writing up EA that requires a stop loss to be placed at the highest price between the lastest stochastic cross (buy signal) and the previous stochastic cross.
Below is the code for reference.
Any help or push in the right direction would be greatly appreciated.
Cheers,
Dale