Download MetaTrader 5
To add comments, please log in or register
Store your source codes in MQL5 Storage. It is secure!
texoro
113
texoro 2014.07.09 14:31 
#property copyright ""
#property link      ""

#property indicator_buffers 2
#property indicator_color1 DarkGreen
#property indicator_width1 3
#property indicator_color2 Green
#property indicator_width2 3

extern string note1 = "Stochastic settings";
extern string note2 = "default = Stoch(5,3,3)";
extern int      kPeriod     =  5;
extern int      dPeriod     =  3;
extern int      slowing     =  3;
extern double LimitUpIpercompr=100.00;
extern double LimitDownIpercompr=80.00;
extern double LimitUpIpervend=20.00;
extern double LimitDownIpervend=0.00;
extern int    DistTraLinee = 4;
void DrawAllert(string text, int xdistance, int ydistance, color C=LightGray)
{

         ObjectCreate         ("rect",OBJ_LABEL,0,0,0,0,0);
         ObjectSet            ("rect",OBJPROP_XDISTANCE,xdistance);
         ObjectSet            ("rect",OBJPROP_YDISTANCE,ydistance);
         ObjectSetText ("rect",text,10,"Times New Roman",C);
}
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+ 
int deinit()
{
    for(int i = ObjectsTotal() - 1; i >= 0; i--)
    {
      ObjectDelete("rect");   
   
    }
     
    return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int countedBars = IndicatorCounted();
   int limit = Bars - countedBars, cross=0;
   double mainLine[11], signalLine[11];
   bool iperVenduto=false, iperComprato=false, crossdown= false,crossup = false, crossingDown=false,  crossingUp = false ;
   for(int i = 0; i <= 10 ; i++)
   {
      mainLine[i] = iStochastic(NULL, 0, kPeriod, dPeriod, slowing, MODE_SMA, 0, MODE_MAIN,i);
      signalLine[i] = iStochastic(NULL, 0, kPeriod, dPeriod, slowing, MODE_SMA, 0, MODE_SIGNAL, i);    
      DrawAllert("Signal:" + signalLine[i] +" Main:" + mainLine[i],1,20,Green);
      if ((mainLine[i] > signalLine[i]) && (mainLine[i+1] > signalLine[i+1]) )//&& (signalLine[i-1] < mainLine[i-1])) 
      {    
         DrawAllert("Put", 5,10,Green);
      }
      if ((mainLine[i] < signalLine[i]) && (mainLine[i+1] > signalLine[i+1]) && (signalLine[i-1] > mainLine[i-1]))
      {    
         DrawAllert("cal", 5,10,Green);
      }
   }
      
   return 0;
 }
       

I created an index but when i mark the "If" what happends is: The index works, but if i fill the mistake do not appear but if i "Attach"to the graph the errors is "array out of rage"
whroeder1
13596
whroeder1 2014.07.09 15:12  
texcs:  errors is "array out of rage"
Or course you do.
double mainLine[11], signalLine[11] indexs are 0 .. 10   
for(int i = 0; i <= 10 ; i++){
   :
   if ((mainLine[i] > signalLine[i]) && (mainLine[i+1]
When i == 10, i+1 == 11 but the indexes are 0 .. 10
/
To add comments, please log in or register