indicator refresh problem - page 2

 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

#property indicator_width1 4
#property indicator_width2 4

double CrossUp[];
double CrossDown[];
extern int FasterEMA1     = 6;
extern int SlowerEMA1     = 12;
extern int FasterEMA2     = 7;
extern int SlowerEMA2     = 14;
extern int RSInowPeriod   = 6;
extern int barsBack       = 2000;
extern bool AlertsMessage = true;
extern bool AlertsSound   = true;
extern bool debug         = false;
extern double K           = 1.0 ;

bool EMACrossedUp = false;
bool RSICrossedUp = false;
bool EMACrossedDown = false;
bool RSICrossedDown = false;
int SignalLabeled = 0; // 0: initial state; 1: up; 2: down.
int upalert=false,downalert=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 241);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 242);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   for (counter=i ;counter<=i+9;counter++);  // LB=9
   double fasterEMA1now, slowerEMA1now, fasterEMA1previous, slowerEMA1previous, fasterEMA2now, slowerEMA2now, fasterEMA2previous, slowerEMA2previous;
   double RSInow;
   double Range;
  
   for(i = limit; i>=0; i--) {
  
      CrossUp[i] = EMPTY_VALUE;
      CrossDown[i] = EMPTY_VALUE;
      Range=0;

      fasterEMA1now = iMA(NULL, 0, FasterEMA1, 0, MODE_EMA, PRICE_CLOSE, i);
      fasterEMA1previous = iMA(NULL, 0, FasterEMA1, 0, MODE_EMA, PRICE_CLOSE, i+1);
      
      fasterEMA2now = iMA(NULL, 0, FasterEMA2, 0, MODE_EMA, PRICE_CLOSE, i);
      fasterEMA2previous = iMA(NULL, 0, FasterEMA2, 0, MODE_EMA, PRICE_CLOSE, i+1);
      
      slowerEMA1now = iMA(NULL, 0, SlowerEMA1, 0, MODE_EMA, PRICE_CLOSE, i);
      slowerEMA1previous = iMA(NULL, 0, SlowerEMA1, 0, MODE_EMA, PRICE_CLOSE, i+1);
      
      slowerEMA2now = iMA(NULL, 0, SlowerEMA2, 0, MODE_EMA, PRICE_CLOSE, i);
      slowerEMA2previous = iMA(NULL, 0, SlowerEMA2, 0, MODE_EMA, PRICE_CLOSE, i+1);
      
      EMACrossedUp   = fasterEMA1now >= slowerEMA1now && fasterEMA1previous <= slowerEMA1previous && fasterEMA2now >= slowerEMA2now && fasterEMA2previous <= slowerEMA2previous;
      EMACrossedDown = fasterEMA1now <= slowerEMA1now && fasterEMA1previous >= slowerEMA1previous && fasterEMA2now <= slowerEMA2now && fasterEMA2previous >= slowerEMA2previous;
      
      RSInow=iRSI(NULL,0,RSInowPeriod,PRICE_CLOSE,i);
      
      if (RSInow > 50) {
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" RSI UP ");
         RSICrossedUp=true;
         RSICrossedDown=false;
      }
      
      if (RSInow < 50) {
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" RSI DOWN ");
         RSICrossedUp=false;
         RSICrossedDown=true;
      }
      
      if ((fasterEMA1now >= slowerEMA1now) && (fasterEMA1previous <= slowerEMA1previous) && (fasterEMA2now >= slowerEMA2now) && (fasterEMA2previous <= slowerEMA2previous)) {
         EMACrossedUp=true;
         EMACrossedDown=false;
      }

      if ((fasterEMA1now <= slowerEMA1now) && (fasterEMA1previous >= slowerEMA1previous) && (fasterEMA2now <= slowerEMA2now) && (fasterEMA2previous >= slowerEMA2previous)) {
         EMACrossedUp=false;
         EMACrossedDown=true;
      }

      if ((EMACrossedUp) && (RSICrossedUp) && (SignalLabeled != 1)) {
         CrossUp[i] = Low[i] - K*Range;
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" SIGNAL UP ");
         if(i<=2 && AlertsMessage && !upalert)
           {
            Alert (Symbol()," ",Period(),"M  BUY SIGNAL ");
            //SendMail("EMA Cross Up on "+Symbol(),"");
            upalert=true;
            downalert=false;
           }          
         if(i<=2 && AlertsSound && !upalert)
           {
            PlaySound("alert.wav");
            upalert=true;
            downalert=false;
           }
         SignalLabeled = 1;
      }

      else if ((EMACrossedDown) && (RSICrossedDown) && (SignalLabeled != 2)) {
         CrossDown[i] = High[i] + K*Range;
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" SIGNAL DOWN ");
         if(i<=2 && AlertsMessage && !downalert)
           {
            Alert (Symbol()," ",Period(),"M  SELL SIGNAL ");
            //SendMail("EMA Cross Down on "+Symbol(),"");
            downalert=true;
            upalert=false;
           }
         if(i<=2 && AlertsSound && !downalert)
           {
            PlaySound("alert.wav");
            downalert=true;
            upalert=false;
           }
         SignalLabeled = 2;
      }
   }
   return(0);
}
//end
I did theese changes but with no effects.. The arrows doesn't appear...
 
Where do you assign a value to limit?
 
Keith Watford:
Where do you assign a value to limit?
what do you mean ?
 
danizani95: what do you mean ?
  1. The question is simple. What is the value of limit?
       int limit, i, counter;
       for(i = limit; i>=0; i--) {

  2. What do you think this code does?
    for (counter=i ;counter<=i+9;counter++);  // LB=9

  3. Where did you #2, #5, #7?
 
whroeder1:
  1. The question is simple. What is the value of limit?
       int limit, i, counter;
       for(i = limit; i>=0; i--) {

  2. What do you think this code does?
    for (counter=i ;counter<=i+9;counter++);  // LB=9

  3. Where did you #2, #5, #7?
I don't know what those lines means and I don't have the knowledges to understand it...
 
Keith Watford:
Where do you assign a value to limit?


danizani95:

what do you mean ?

It should be quite obvious what I mean.

if I say to you "Go out and buy x oranges"

would you be able to?

No, because you don't know wnat the value of x is.


You declare limit, but you don't give it a value.

 
danizani95: I don't know what those lines means and I don't have the knowledges to understand it...
  1. Then you've been wasting our time as there is no common language to communicate.
  2. learn to code it, or pay (Freelance) someone. We're not going to code it FOR you.
    We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
 

As far as I can see, if the original code that you posted works correctly except for changed signals during the current bar not being deleted all you should need to do is add what I suggested earlier.

In your most recent posted code, for some reason, you have deleted



   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=MathMin(Bars-counted_bars,barsBack);


that is why I asked you where limit gets assigned a value, you have removed the code

 
Keith Watford:

As far as I can see, if the original code that you posted works correctly except for changed signals during the current bar not being deleted all you should need to do is add what I suggested earlier.

In your most recent posted code, for some reason, you have deleted



   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=MathMin(Bars-counted_bars,barsBack);


that is why I asked you where limit gets assigned a value, you have removed the code

I tried also with that part of the code but I had no changes...
Reason: