I don't plot the arrow. why?

 

Code

***

Averaging Price Series for Intermediate Calculations Without Using Additional Buffers
Averaging Price Series for Intermediate Calculations Without Using Additional Buffers
  • www.mql5.com
This article is about traditional and unusual algorithms of averaging packed in simplest and single-type classes. They are intended for universal usage in almost all developments of indicators. I hope that the suggested classes will be a good alternative to 'bulky' calls of custom and technical indicators.
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button

Thank you.


 
Thank you
 
// --- Sell
#property indicator_label1 "Sell"
#property indicator_type1 DRAW_ARROW
#property indicator_color1 clrAqua
#property indicator_width1 1
input bool SELL_ARROW = true;

// --- Buy
#property indicator_label2 "Buy"
#property indicator_type2 DRAW_ARROW
#property indicator_color2 clrAqua
#property indicator_width2 1
input bool BUY_ARROW = true;

//--- Buffa
double SELL[];
double BUY[];

// --- Global
int MA_HANDLE;
int MACD_HANDLE;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   // --- Sell

   SetIndexBuffer(0, SELL, INDICATOR_DATA);
   PlotIndexSetInteger(0, PLOT_ARROW, 226);
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 0);
   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0);
   ArraySetAsSeries(SELL, true);
   
   // --- Buy
   SetIndexBuffer(1, BUY, INDICATOR_DATA);
   PlotIndexSetInteger(1, PLOT_ARROW, 225);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, 0);
   PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0);
   ArraySetAsSeries(BUY, true);
   
   
   // --- Handle
   MA_HANDLE = iMA(NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE);
   MACD_HANDLE = iMACD(NULL, PERIOD_M5, 5, 25, 5, PRICE_CLOSE);
//---
   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[])
  {
//---
   // --- bar
   int limit, to_copy;
   
   if(prev_calculated>rates_total || prev_calculated<=0)
       limit = rates_total;
       else
           limit = rates_total - prev_calculated;
  
  if(prev_calculated>rates_total || prev_calculated<=0)
      to_copy = rates_total;
      else
          {
           to_copy = rates_total - prev_calculated;
           to_copy ++;
          }
   
   // --- MA&MACD
   double ma[], ma_past[], macd[];
   CopyBuffer(MA_HANDLE, 0, 0, to_copy, ma);
   CopyBuffer(MACD_HANDLE, 0, 1, to_copy, ma_past);
   CopyBuffer(MACD_HANDLE, 0, 0, to_copy, macd);
   ArraySetAsSeries(ma, true);
   ArraySetAsSeries(ma_past, true);
   ArraySetAsSeries(macd, true);
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   
   // --- Arrow
   for(int i = 0; i < 1000; i++)
       {
       if(ma[i] > close[i])
           {
           SELL[i] = high[i];
           //Print(ma[i]);
           }
       }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Kosei S :

Your error is here:

   // --- Handle
   MA_HANDLE = iMA(NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE);
   MACD_HANDLE = iMACD(NULL, PERIOD_M5, 5, 25, 5, PRICE_CLOSE);
 
Vladimir Karputov:

Your error is here:

Thank you for reply.
I changed it, but the arrow was still not displayed.
 MA_HANDLE = iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE);
 MACD_HANDLE = iMACD(NULL, PERIOD_CURRENT, 5, 25, 5, PRICE_CLOSE);
 
Kosei S :
Thank you for reply.
I changed it, but the arrow was still not displayed.

Please attach your file using the button Attach file

 
Vladimir Karputov:

Please attach your file using the button

Thank you
Files:
memo4.mq5  8 kb
 
Kosei S :
Thank you

Error: You did not specify the number of indicator buffers and did not specify the number of graphical plots.

#property indicator_chart_window

// --- Sell
#property indicator_label1 "Sell"

I recommend creating a template using the MQL Wizard

 
Vladimir Karputov:

Error: You did not specify the number of indicator buffers and did not specify the number of graphical plots.

I recommend creating a template using the MQL Wizard

Thank you so much

Reason: