how to add arrows to indicator

 

Hello, I need to develope and indicator who show arrow down with this condition:

if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,1)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,1) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,2)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,2))


and arrow up with this condition:

if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,1)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,1) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,2)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,2))


I tryed to search how to do on last days but with no result. I tryed adapting this one iI found but it doesn't works:


#property copyright "MAX"
#property link      "max"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_color1 clrRed
#property indicator_color1 clrGreen
double Buffer1[],Buffer2[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 242);
   //initialize myPoint

   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   int limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,1)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,1) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,2)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,2))
        {
         Buffer1[i] = Low[i] - 10; //Set indicator value at Candlestick Low - fixed value
        }
      //Indicator Buffer 2
      if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,1)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,1) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,2)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,2))
        {
         Buffer2[i] = High[i] + 10; //Set indicator value at Candlestick High + fixed value
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
Files:
m10_m40.mq4  3 kb
 
actarus1:

Hello, I need to develope and indicator who show arrow down with this condition:

if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,1)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,1) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,2)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,2))


and arrow up with this condition:

if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,1)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,1) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,2)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,2))


I tryed to search how to do on last days but with no result. I tryed adapting this one iI found but it doesn't works:


ok.corrected

#property copyright "MAX"
#property link      "max"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 3
#property indicator_width2 3

#property indicator_color1 clrRed
#property indicator_color2 clrGreen
double Buffer1[],Buffer2[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
      SetIndexStyle(0,DRAW_ARROW);
      SetIndexArrow(0,241);
      
      SetIndexStyle(1,DRAW_ARROW);
      SetIndexArrow(1,242);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexEmptyValue(1, 0);
    SetIndexBuffer(1, Buffer2);
   //initialize myPoint

   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
  
  
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   int limit=Bars-counted_bars;
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,i)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,i) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,i+1)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,i+1))
        {
         Buffer1[i] = Low[i] - 10*Point; //Set indicator value at Candlestick Low - fixed value
        
        }
      //Indicator Buffer 2
      if (iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,i)>iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,i) && iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,i+1)<iMA(Symbol(),0,40,0,MODE_SMA,PRICE_CLOSE,i+1))
        {
         Buffer2[i] = High[i] + 10*Point; //Set indicator value at Candlestick High + fixed value
         
        }
     }
   return(rates_total);
  }