arrows and wrong object being added to chart. - page 2

 
Vladimir Karputov #:
Example: Alert Crossing Two MA

this one.

 
Revo Trades # :

this one.

Okay. I propose to take the Alert Crossing Two MA code as a basis and gradually (step by step) make changes. Add a third Moving Average ('MA Medium'). We will also have three indicator buffers ('Fast', 'Medium', 'Slow').

You also need to add indicator buffers of the 'Arrow' - 'Up' and 'Down' type.

I like to create a blank using the 'MQL5 Wizard':



Got this setup:

//+------------------------------------------------------------------+
//|                                     Alert Crossing Three MAs.mq5 |
//|                              Copyright © 2022, Vladimir Karputov |
//|                      https://www.mql5.com/en/users/barabashkakvn |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2022, Vladimir Karputov"
#property link      "https://www.mql5.com/en/users/barabashkakvn"
#property version   "1.000"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   5
//--- plot MA_Fast_
#property indicator_label1  "MA_Fast_"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDarkOrange
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot MA_Medium_
#property indicator_label2  "MA_Medium_"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrPurple
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot MA_Slow_
#property indicator_label3  "MA_Slow_"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrSlateGray
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- plot UP
#property indicator_label4  "UP"
#property indicator_type4   DRAW_ARROW
#property indicator_color4  clrSteelBlue
#property indicator_style4  STYLE_SOLID
#property indicator_width4  1
//--- plot DOWN
#property indicator_label5  "DOWN"
#property indicator_type5   DRAW_ARROW
#property indicator_color5  clrRed
#property indicator_style5  STYLE_SOLID
#property indicator_width5  1
//--- input parameters
input int      Input1=9;
//--- indicator buffers
double   MA_Fast_Buffer[];
double   MA_Medium_Buffer[];
double   MA_Slow_Buffer[];
double   UPBuffer[];
double   DOWNBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,MA_Fast_Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,MA_Medium_Buffer,INDICATOR_DATA);
   SetIndexBuffer(2,MA_Slow_Buffer,INDICATOR_DATA);
   SetIndexBuffer(3,UPBuffer,INDICATOR_DATA);
   SetIndexBuffer(4,DOWNBuffer,INDICATOR_DATA);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(3,PLOT_ARROW,159);
   PlotIndexSetInteger(4,PLOT_ARROW,159);
   
//---
   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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Preparation after making changes:

//+------------------------------------------------------------------+
//|                                     Alert Crossing Three MAs.mq5 |
//|                              Copyright © 2022, Vladimir Karputov |
//|                      https://www.mql5.com/en/users/barabashkakvn |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2022, Vladimir Karputov"
#property link      "https://www.mql5.com/en/users/barabashkakvn"
#property version   "1.001"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   5
//--- plot MA_Fast_
#property indicator_label1  "MA_Fast_"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDarkOrange
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot MA_Medium_
#property indicator_label2  "MA_Medium_"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrPurple
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot MA_Slow_
#property indicator_label3  "MA_Slow_"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrSlateGray
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- plot UP
#property indicator_label4  "UP"
#property indicator_type4   DRAW_ARROW
#property indicator_color4  clrSteelBlue
#property indicator_style4  STYLE_SOLID
#property indicator_width4  1
//--- plot DOWN
#property indicator_label5  "DOWN"
#property indicator_type5   DRAW_ARROW
#property indicator_color5  clrRed
#property indicator_style5  STYLE_SOLID
#property indicator_width5  1
//--- input parameters
input group             "MA Fast"
input int                  Inp_MA_Fast_ma_period      = 50;             // MA Fast: averaging period
input int                  Inp_MA_Fast_ma_shift       = 0;              // MA Fast: horizontal shift
input ENUM_MA_METHOD       Inp_MA_Fast_ma_method      = MODE_EMA;       // MA Fast: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_Fast_applied_price  = PRICE_CLOSE;    // MA Fast: type of price
input group             "MA Medium"
input int                  Inp_MA_Medium_ma_period    = 100;            // MA Medium: averaging period
input int                  Inp_MA_Medium_ma_shift     = 0;              // MA Medium: horizontal shift
input ENUM_MA_METHOD       Inp_MA_Medium_ma_method    = MODE_EMA;       // MA Medium: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_Medium_applied_price= PRICE_CLOSE;    // MA Medium: type of price
input group             "MA Slow"
input int                  Inp_MA_Slow_ma_period      = 240;            // MA Slow: averaging period
input int                  Inp_MA_Slow_ma_shift       = 0;              // MA Slow: horizontal shift
input ENUM_MA_METHOD       Inp_MA_Slow_ma_method      = MODE_LWMA;      // MA Slow: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_Slow_applied_price  = PRICE_CLOSE;    // MA Slow: type of price
input group             "Alerts"
input string               InpSoundName               = "alert.wav"; // Sound Name
input uchar                InpSoundRepetitions        = 3;           // Repetitions
input uchar                InpSoundPause              = 3;           // Pause, in seconds
//--- indicator buffers
double   MA_Fast_Buffer[];
double   MA_Medium_Buffer[];
double   MA_Slow_Buffer[];
double   UPBuffer[];
double   DOWNBuffer[];
//---
int      handle_iMA_Fast;                    // variable for storing the handle of the iMA indicator
int      handle_iMA_Medium;                  // variable for storing the handle of the iMA indicator
int      handle_iMA_Slow;                    // variable for storing the handle of the iMA indicator
//---
int      bars_calculated         = 0;        // we will keep the number of values in the Moving Averages Convergence/Divergence indicator
int      start                   = 0;
datetime m_last_sound            = 0;        // "0" -> D'1970.01.01 00:00';
uchar    m_repetitions           = 0;        //
string   m_text                  = "";       //
datetime m_prev_bars             = 0;        // "0" -> D'1970.01.01 00:00';
bool     m_init_error            = false;    // error on InInit
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,MA_Fast_Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,MA_Medium_Buffer,INDICATOR_DATA);
   SetIndexBuffer(2,MA_Slow_Buffer,INDICATOR_DATA);
   SetIndexBuffer(3,UPBuffer,INDICATOR_DATA);
   SetIndexBuffer(4,DOWNBuffer,INDICATOR_DATA);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(3,PLOT_ARROW,241);
   PlotIndexSetInteger(4,PLOT_ARROW,242);
//--- create handle of the indicator iMA
   handle_iMA_Fast=iMA(Symbol(),Period(),Inp_MA_Fast_ma_period,Inp_MA_Fast_ma_shift,
                       Inp_MA_Fast_ma_method,Inp_MA_Fast_applied_price);
//--- if the handle is not created
   if(handle_iMA_Fast==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator ('Fast') for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      m_init_error=true;
      return(INIT_SUCCEEDED);
     }
//--- create handle of the indicator iMA
   handle_iMA_Medium=iMA(Symbol(),Period(),Inp_MA_Medium_ma_period,Inp_MA_Medium_ma_shift,
                         Inp_MA_Medium_ma_method,Inp_MA_Medium_applied_price);
//--- if the handle is not created
   if(handle_iMA_Medium==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator ('Medium') for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      m_init_error=true;
      return(INIT_SUCCEEDED);
     }
//--- create handle of the indicator iMA
   handle_iMA_Slow=iMA(Symbol(),Period(),Inp_MA_Slow_ma_period,Inp_MA_Slow_ma_shift,
                       Inp_MA_Slow_ma_method,Inp_MA_Slow_applied_price);
//--- if the handle is not created
   if(handle_iMA_Slow==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator ('Slow') for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      m_init_error=true;
      return(INIT_SUCCEEDED);
     }
//---
   int fast=Inp_MA_Fast_ma_period+Inp_MA_Fast_ma_shift;
   int medium=Inp_MA_Medium_ma_period+Inp_MA_Medium_ma_shift;
   int slow=Inp_MA_Slow_ma_period+Inp_MA_Slow_ma_shift;
   start=(fast<medium)?medium:fast;
   start=(start<slow)?slow:start;
//---
   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[])
  {
//---
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Alert Crossing Two MA
Alert Crossing Two MA
  • www.mql5.com
Alert при пересечении двух iMA: 'Fast' и 'Slow'
 

version "1.002" - almost ready indicator: all three indicators are created and drawn on the chart.

It remains to clarify in which cases to put 'Arrow UP' and 'Arrow DOWN'

//+------------------------------------------------------------------+
//|                                     Alert Crossing Three MAs.mq5 |
//|                              Copyright © 2022, Vladimir Karputov |
//|                      https://www.mql5.com/en/users/barabashkakvn |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2022, Vladimir Karputov"
#property link      "https://www.mql5.com/en/users/barabashkakvn"
#property version   "1.002"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   5
//--- plot MA_Fast_
#property indicator_label1  "MA_Fast_"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDarkOrange
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot MA_Medium_
#property indicator_label2  "MA_Medium_"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrPurple
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot MA_Slow_
#property indicator_label3  "MA_Slow_"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrSlateGray
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- plot UP
#property indicator_label4  "UP"
#property indicator_type4   DRAW_ARROW
#property indicator_color4  clrSteelBlue
#property indicator_style4  STYLE_SOLID
#property indicator_width4  1
//--- plot DOWN
#property indicator_label5  "DOWN"
#property indicator_type5   DRAW_ARROW
#property indicator_color5  clrRed
#property indicator_style5  STYLE_SOLID
#property indicator_width5  1
//--- input parameters
input group             "MA Fast"
input int                  Inp_MA_Fast_ma_period      = 50;             // MA Fast: averaging period
input int                  Inp_MA_Fast_ma_shift       = 0;              // MA Fast: horizontal shift
input ENUM_MA_METHOD       Inp_MA_Fast_ma_method      = MODE_EMA;       // MA Fast: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_Fast_applied_price  = PRICE_CLOSE;    // MA Fast: type of price
input group             "MA Medium"
input int                  Inp_MA_Medium_ma_period    = 100;            // MA Medium: averaging period
input int                  Inp_MA_Medium_ma_shift     = 0;              // MA Medium: horizontal shift
input ENUM_MA_METHOD       Inp_MA_Medium_ma_method    = MODE_EMA;       // MA Medium: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_Medium_applied_price= PRICE_CLOSE;    // MA Medium: type of price
input group             "MA Slow"
input int                  Inp_MA_Slow_ma_period      = 240;            // MA Slow: averaging period
input int                  Inp_MA_Slow_ma_shift       = 0;              // MA Slow: horizontal shift
input ENUM_MA_METHOD       Inp_MA_Slow_ma_method      = MODE_LWMA;      // MA Slow: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_Slow_applied_price  = PRICE_CLOSE;    // MA Slow: type of price
input group             "Alerts"
input string               InpSoundName               = "alert.wav"; // Sound Name
input uchar                InpSoundRepetitions        = 3;           // Repetitions
input uchar                InpSoundPause              = 3;           // Pause, in seconds
//--- indicator buffers
double   MA_Fast_Buffer[];
double   MA_Medium_Buffer[];
double   MA_Slow_Buffer[];
double   UPBuffer[];
double   DOWNBuffer[];
//---
int      handle_iMA_Fast;                    // variable for storing the handle of the iMA indicator
int      handle_iMA_Medium;                  // variable for storing the handle of the iMA indicator
int      handle_iMA_Slow;                    // variable for storing the handle of the iMA indicator
//---
int      bars_calculated         = 0;        // we will keep the number of values in the Moving Averages Convergence/Divergence indicator
int      start                   = 0;
datetime m_last_sound            = 0;        // "0" -> D'1970.01.01 00:00';
uchar    m_repetitions           = 0;        //
string   m_text                  = "";       //
datetime m_prev_bars             = 0;        // "0" -> D'1970.01.01 00:00';
bool     m_init_error            = false;    // error on InInit
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,MA_Fast_Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,MA_Medium_Buffer,INDICATOR_DATA);
   SetIndexBuffer(2,MA_Slow_Buffer,INDICATOR_DATA);
   SetIndexBuffer(3,UPBuffer,INDICATOR_DATA);
   SetIndexBuffer(4,DOWNBuffer,INDICATOR_DATA);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(3,PLOT_ARROW,241);
   PlotIndexSetInteger(4,PLOT_ARROW,242);
//--- an empty value for plotting, for which there is no drawing
   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,0.0);
//--- create handle of the indicator iMA
   handle_iMA_Fast=iMA(Symbol(),Period(),Inp_MA_Fast_ma_period,Inp_MA_Fast_ma_shift,
                       Inp_MA_Fast_ma_method,Inp_MA_Fast_applied_price);
//--- if the handle is not created
   if(handle_iMA_Fast==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator ('Fast') for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      m_init_error=true;
      return(INIT_SUCCEEDED);
     }
//--- create handle of the indicator iMA
   handle_iMA_Medium=iMA(Symbol(),Period(),Inp_MA_Medium_ma_period,Inp_MA_Medium_ma_shift,
                         Inp_MA_Medium_ma_method,Inp_MA_Medium_applied_price);
//--- if the handle is not created
   if(handle_iMA_Medium==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator ('Medium') for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      m_init_error=true;
      return(INIT_SUCCEEDED);
     }
//--- create handle of the indicator iMA
   handle_iMA_Slow=iMA(Symbol(),Period(),Inp_MA_Slow_ma_period,Inp_MA_Slow_ma_shift,
                       Inp_MA_Slow_ma_method,Inp_MA_Slow_applied_price);
//--- if the handle is not created
   if(handle_iMA_Slow==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator ('Slow') for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      m_init_error=true;
      return(INIT_SUCCEEDED);
     }
//---
   int fast=Inp_MA_Fast_ma_period+Inp_MA_Fast_ma_shift;
   int medium=Inp_MA_Medium_ma_period+Inp_MA_Medium_ma_shift;
   int slow=Inp_MA_Slow_ma_period+Inp_MA_Slow_ma_shift;
   start=(fast<medium)?medium:fast;
   start=(start<slow)?slow:start;
//---
   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[])
  {
   if(m_init_error)
      return(0);
   if(rates_total<start+1)
      return(0);
//--- number of values copied from the iMA indicator
   int values_to_copy;
//--- determine the number of values calculated in the indicator
   int calculated_fast=BarsCalculated(handle_iMA_Fast);
   if(calculated_fast<=0)
     {
      PrintFormat("BarsCalculated(handle_iMA_Fast) returned %d, error code %d",calculated_fast,GetLastError());
      return(0);
     }
   int calculated_medium=BarsCalculated(handle_iMA_Medium);
   if(calculated_medium<=0)
     {
      PrintFormat("BarsCalculated(handle_iMA_Medium) returned %d, error code %d",calculated_medium,GetLastError());
      return(0);
     }
   int calculated_slow=BarsCalculated(handle_iMA_Slow);
   if(calculated_slow<=0)
     {
      PrintFormat("BarsCalculated(handle_iMA_Slow) returned %d, error code %d",calculated_slow,GetLastError());
      return(0);
     }
//---
   if(calculated_fast!=calculated_medium)
     {
      PrintFormat("BarsCalculated(handle_iMA_Fast) returned %d, BarsCalculated(handle_iMA_Medium) returned %d",calculated_fast,calculated_medium);
      return(0);
     }
   if(calculated_medium!=calculated_slow)
     {
      PrintFormat("BarsCalculated(handle_iMA_Medium) returned %d, BarsCalculated(handle_iMA_Slow) returned %d",calculated_medium,calculated_slow);
      return(0);
     }
   int calculated=calculated_fast;
//--- if it is the first start of calculation of the indicator or if the number of values in the iMA indicator changed
//---or if it is necessary to calculated the indicator for two or more bars (it means something has changed in the price history)
   if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)
     {
      //--- if the iMABuffer array is greater than the number of values in the iMA indicator for symbol/period, then we don't copy everything
      //--- otherwise, we copy less than the size of indicator buffers
      if(calculated>rates_total)
         values_to_copy=rates_total;
      else
         values_to_copy=calculated;
     }
   else
     {
      //--- it means that it's not the first time of the indicator calculation, and since the last call of OnCalculate()
      //--- for calculation not more than one bar is added
      values_to_copy=(rates_total-prev_calculated)+1;
     }
//--- fill the MA_Fast_Buffer array with values of the Moving Average indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArrayFromBuffer(MA_Fast_Buffer,Inp_MA_Fast_ma_shift,handle_iMA_Fast,values_to_copy))
      return(0);
//--- fill the MA_Fast_Buffer array with values of the Moving Average indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArrayFromBuffer(MA_Medium_Buffer,Inp_MA_Fast_ma_shift,handle_iMA_Medium,values_to_copy))
      return(0);
//--- fill the SlowBuffer array with values of the Moving Average indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArrayFromBuffer(MA_Slow_Buffer,Inp_MA_Slow_ma_shift,handle_iMA_Slow,values_to_copy))
      return(0);
//--- memorize the number of values in the Moving Average indicator
   bars_calculated=calculated;
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Filling indicator buffers from the MA indicator                  |
//+------------------------------------------------------------------+
bool FillArrayFromBuffer(double &values[],   // indicator buffer of Moving Average values
                         int shift,          // shift
                         int ind_handle,     // handle of the iMA indicator
                         int amount          // number of copied values
                        )
  {
//--- reset error code
   ResetLastError();
//--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 index
   if(CopyBuffer(ind_handle,0,-shift,amount,values)<0)
     {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
//--- everything is fine
   return(true);
  }
//+------------------------------------------------------------------+
//| Indicator deinitialization function                              |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   if(handle_iMA_Fast!=INVALID_HANDLE)
      IndicatorRelease(handle_iMA_Fast);
   if(handle_iMA_Medium!=INVALID_HANDLE)
      IndicatorRelease(handle_iMA_Medium);
   if(handle_iMA_Slow!=INVALID_HANDLE)
      IndicatorRelease(handle_iMA_Slow);
  }
//+------------------------------------------------------------------+
 
Vladimir Karputov #:

version "1.002" - almost ready indicator: all three indicators are created and drawn on the chart.

It remains to clarify in which cases to put 'Arrow UP' and 'Arrow DOWN'

when fast ma crosses from above to below the middle ma, place a down arrow. opoosite for up.

EDIT: i am following along fine so far, mine just wasnt drawing the arrows on the historical/closed candles.

EDIT2: When arrow draws on open candle, the arrow should stick. Even if the ma line rebounds on wrong side of other ma, the arrow should stay.

 

version 1.004

New: 

  • added group "Arrows"
  • expanded group "Alerts"
  • if a signal has appeared, this signal is not deleted (even if the indicator made a reverse movement). ATTENTION: this focus will not work on historical data, since only four prices are available for the indicator on history (OHLC is taken from OnCalculate)

 
Vladimir Karputov #:

version 1.004

New: 

  • if a signal has appeared, this signal is not deleted (even if the indicator made a reverse movement). ATTENTION: this focus will not work on historical data, since only four prices are available for the indicator on history (OHLC is taken from OnCalculate)

yep. i understand that. thanks for mentioning it, because now i know i wasnt going craazy :)

 
Revo Trades # :

yep. i understand that. thanks for mentioning it, because now i know i wasnt going craazy :)

Today I will finish the code for group "Alerts"...

 

version "1.005"

Check, please. If everything is in order - I will publish this code in CodeBase.

 
Vladimir Karputov #:

version "1.005"

Check, please. If everything is in order - I will publish this code in CodeBase.

ok. next msg wil be, yes it works, or not :)

 
Vladimir Karputov #:

version "1.005"

Check, please. If everything is in order - I will publish this code in CodeBase.

fast test, but have proven all things working as asked for:

arrows are right direction as requested. they are painted on closed and historic candles when first initialised, and they are not flickering when price is going up and down or when the fast ma moves back and forth, under and over the slower ma.

Only possible issue i am going to investigate, is when i get an alert i hear the alert.wav, but there's a "buzz" at the beginning, as if it is playing the sound at same times as displaying the alert. am going to investigate that now. Maybe you have the sound and the alert being displayed at same time, if so, i am sure i can fix that myself.

EDIT: yep, i was correct. when the sound setting has a filename and alert setting is true, the indicator does both: displays the alert window, with the sound, but also plays the sound. This gives a "buzz" when each alert and sound is played. But i can fix that easy.
Reason: