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
But the way I need is:
But when I use it that way the whole System crashes.
Pls See my full code:
//--- //Special Loop to avoid Array Out of Range int counted_bars = IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; //int limit = Bars-counted_bars; int limit = MathMin(Bars-3,Bars-counted_bars); //+------------------------------------------------------------------+ //LongTrariling for(int i=limit;i>=0;i--){ if(Close[i+1]>High[i+2]){ lastDirection = 1; int bar=i+2; double lowCheck=Low[bar]; while(bar<Bars-1){ if(lowCheck>Low[i+1]){ bar++; lowCheck=Low[bar]; }else{ upStop_1[i+1]=lowCheck; break; } } //THIS IS THE PROBLEM PART THIS IS THE PROBLEM PART THIS IS THE PROBLEM PART THIS IS THE PROBLEM PART THIS IS THE PROBLEM PART THIS IST THE PROBLEM PART }else if(Close[i+1]<High[i+2]){ lastDirection =-1; int bar=i+2; //Remember high of Position double highNumber=High[i+2]; //Remember Position of Index double lowCheck=Low[bar]; while(bar<Bars-1){ if(highNumber>Close[i+1]){ if(lowCheck>Low[i+1]){ bar++; lowCheck=Low[bar]; }else{ upStop_1[i+1]=lowCheck; break; } } } }else{ if(lastDirection == 1) upStop_1[i+1]=upStop_1[i+2]; if(lastDirection ==-1) upStop_2[i+1]=upStop_2[i+2]; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+Pls See also the attached Picture to understand it better:
Every time when it detects another Close[I+1]<High[I+2] it starts a new sequence but it need to hold the Stop until Close[I+1]>Than the saved High[I+2]
Thats the way how I need it to work "Stay in Loop until Close[I+1] > than the saved highNumber (But when I use it that way the System crashes