How to retrieve PLOT_ARROW code and current Indicator Buffer Color from any DRAW_ARROW type indicator?

 

Dear community,

I need a help to discover a way for dynamically identify the PLOT_ARROW code and Color used by DRAW_ARROW indicator type. My project is create an EA that sends orders using any DRAW_ARROW type indicator as  buy/sell signal

Here is a test indicator source code. 

#property indicator_chart_window
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
#property indicator_type1   DRAW_ARROW
#property indicator_color1  Red
#property indicator_label1  "Arrow Test Sell"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  Blue
#property indicator_label2  "Arrow Test Buy"

double ab1[];
double ab2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping 0
   SetIndexBuffer(0,ab1,INDICATOR_DATA);
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   PlotIndexSetInteger(0,PLOT_ARROW,250);
   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT, -10);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//--- indicator buffers mapping 1
   SetIndexBuffer(1,ab2,INDICATOR_DATA);
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   PlotIndexSetInteger(1,PLOT_ARROW,230);
   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT, 10);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);
   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[]) {
//---
   for ( int i = ( prev_calculated > 0 ? prev_calculated -1 : 0 ); i < rates_total; i++ ){
      ab1[i] = high[i];
      ab2[i] = low[i];
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }

And here is the information that I have until this moment.

int OnInit()
  {
//--- create timer
   EventSetTimer(60);
//--- start list de indicators 
   int totalIndicators = ChartIndicatorsTotal( ChartID(), 0 );
   printf( "Encontrados %s indicadores neste gráfico.", IntegerToString(totalIndicators));
   for ( int i = 0; i < totalIndicators; i++ ){
      string indicatorName = ChartIndicatorName( ChartID(), 0, i );
      int indicatorHandle = ChartIndicatorGet(ChartID(), 0, indicatorName );      
      printf( "%sº indicador é %s e handle %s", IntegerToString(i+1), indicatorName, IntegerToString(indicatorHandle) );   
      MqlParam indicatorParams[];      
      ENUM_INDICATOR indicatorType;
      long totalIndicatorsParameters = IndicatorParameters((int) indicatorHandle, indicatorType, indicatorParams );           
      printf( "===> Encontrados %s paramêtros para¨%s do tipo %s.", IntegerToString(totalIndicatorsParameters), indicatorName, EnumToString(indicatorType));   
      for ( int j = 0; j < totalIndicatorsParameters; j++ ){
         printf( "===> %sº parâmetro do tipo %s e valor %s.", IntegerToString(j+1), EnumToString(indicatorParams[j].type), ( indicatorParams[j].type == TYPE_STRING ? indicatorParams[j].string_value : indicatorParams[j].type == TYPE_INT ? IntegerToString(indicatorParams[j].integer_value) : DoubleToString(indicatorParams[j].double_value) ) );      
      }
      
      bool counting = true;
      int indexBuffer = 0;            
      while ( counting ){
         double buffers[];   
         int r = CopyBuffer(indicatorHandle, indexBuffer, 0, BarsCalculated(indicatorHandle) -1, buffers );         
         if ( r < 0 ){
            counting = false;
         }
         else{
            string valuesBuffer = "|";
            int countDistict = 0;            
            int bufferSize = ArraySize(buffers);
            for ( int j = 0; j < bufferSize; j++ ){
               if ( StringFind( valuesBuffer, "|" + DoubleToString(buffers[j]) + "|") < 0 ){
                  if ( countDistict > 20 ){
                     valuesBuffer += "...";
                     break;
                  }                  
                  valuesBuffer += DoubleToString(buffers[j]) + "|";
                  countDistict++;
               }
            }
            printf("===> valores encontrados no buffer (%s)",  valuesBuffer );  
            indexBuffer++;
            
         }
      }           
      printf("===> Encontrados %s buffers.", IntegerToString(indexBuffer));      
   }        
//---
   return(INIT_SUCCEEDED);
  }

Thanks!

Trading Signals in MetaTrader 5: A Better Alternative to PAMM Accounts!
Trading Signals in MetaTrader 5: A Better Alternative to PAMM Accounts!
  • www.mql5.com
We are pleased to announce that MetaTrader 5 now features Trading Signals, thus giving a powerful tool to investors and managers. While you are following the trades of a successful trader, the terminal will be automatically reproducing them in your account!
 
Luiz Antonio De Sousa Marcon: . My objective is create an EA

There are no colors or arrow codes from iCustom. EAs have no eyes.

 
William Roeder #:

There are no colors or arrow codes from iCustom. EAs have no eyes.

Hi William, 

How do you think that this indicator shows arrow used code ( Wingdings - Constantes de Objetos - Constantes, Enumeradores e Estruturas - Referência MQL5 - Referência sobre algorítimo/automatização de negociação na linguagem para MetaTrader 5 ) and colors used in my sample code ?

In first step, it list indicators that has two buffers with property_type DRAW_ARROW

After choose my sample indicator, it list buffers and values that I set on PlotIndexSetInteger(0,PLOT_ARROW,250); and PlotIndexSetInteger(1,PLOT_ARROW,230);


And sorry for my bad english.


Thanks for help!

Documentação sobre MQL5: Constantes, Enumeradores e Estruturas / Constantes de Objetos / Wingdings
Documentação sobre MQL5: Constantes, Enumeradores e Estruturas / Constantes de Objetos / Wingdings
  • www.mql5.com
Wingdings - Constantes de Objetos - Constantes, Enumeradores e Estruturas - Referência MQL5 - Referência sobre algorítimo/automatização de negociação na linguagem para MetaTrader 5
 
No need writing this twice
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
I don't know if that is possible, reason is indicator buffer only holds double, Arrowcode would be of uchar data type. You could store the value in another buffer, which would read in your program and formatted to uchar.
e.g 
double dynamicArrowcode;
SetIndexBuffer(3,dynamicArrowcode,INDICATOR_DATA);
dynamicArrowcode[i] =123.0;

//Then formatting empty spots with EMPTY_VALUE
 
Luiz Antonio De Sousa Marcon #: How do you think that this indicator shows arrow used code ( Wingdings - Constantes de Objetos - Constantes, Enumeradores e Estruturas - Referência MQL5 - Referência sobre algorítimo/automatização de negociação na linguagem para MetaTrader 5 ) and colors used in my sample code ? In first step, it list indicators that has two buffers with property_type DRAW_ARROW After choose my sample indicator, it list buffers and values that I set on PlotIndexSetInteger(0,PLOT_ARROW,250); and PlotIndexSetInteger(1,PLOT_ARROW,230); And sorry for my bad english.

I think you have misunderstood William's post.

In the indicator itself you can set the arrow codes and the plot colours, however, from the EA retrieving the Indicator's buffer data, it is irrelevant what arrow codes were chosen or what colours. The EA can ONLY retrieve the buffer data and nothing else.

Also, the Indicators that are instantiated by an EA, do not display. It is hidden, so there are no colours or arrows to consider. That is why William stated that it is "blind". It does not see. Only the buffer data is available.

In your case the the first buffer will have the "Arrow Test Sell" values and the second buffer will have the "Arrow Test Buy" values, irrespective of arrow codes or plot colour or style.

 
Fernando Carreiro #:

I think you have misunderstood William's post.

In the indicator itself you can set the arrow codes and the plot colours, however, from the EA retrieving the Indicator's buffer data, it is irrelevant what arrow codes were chosen or what colours. The EA can ONLY retrieve the buffer data and nothing else.

Also, the Indicators that are instantiated by an EA, do not display. It is hidden, so there are no colours or arrows to consider. That is why William stated that it is "blind". It does not see. Only the buffer data is available.

In your case the the first buffer will have the "Arrow Test Sell" values and the second buffer will have the "Arrow Test Buy" values, irrespective of arrow codes or plot colour or style.

Dear Fernando, 


Thanks for reply.


I understood what William's posted! And I knew that plot colour or style are in theory, unaccessable from EA. 


But what I'm trying to say/show here is that I have an  EA's .ex5  that read this data and I would like to understand how it is possible? 


Perhaps I must make a youtube video to demonstrate it, because in this case I have some binary that make something that everybody is saing that is impossible. 

 
Luiz Antonio De Sousa Marcon #: I understood what William's posted! And I knew that plot colour or style are in theory, unaccessable from EA. But what I'm trying to say/show here is that I have an  EA's .ex5  that read this data and I would like to understand how it is possible? Perhaps I must make a youtube video to demonstrate it, because in this case I have some binary that make something that everybody is saing that is impossible.  I understood what William say e I knew that plot colour or style are unacs But I'm saing here that I have an EA that read this data and I wold like to understand how it is possible. 

No, it is not possible in normal MQL and even if done via DLL calls to Windows API, it would be very difficult!

If you have such an EA, then it is most likely that the colours and arrow codes are passed by the "input" parameters and not via the normal terminal properties. I have done that before for some of my indicators.

Another possibility, is when the indicator is using Graphical Objects instead of buffers, and there it is possible to retrieve the colours and the arrow codes of the objects, but not the buffers.

Which ever way you look at it, it is only possible if the Indicator uses and alternative method to allow access to those properties, but it is not possible for normal Indicators.

 
Fernando Carreiro #:

No, it is not possible in normal MQL and even if done via DLL calls to Windows API, it would be very difficult!

If you have such an EA, then it is most likely that the colours and arrow codes are passed by the "input" parameters and not via the normal terminal properties. I have done that before for some of my indicators.

Another possibility, is when the indicator is using Graphical Objects instead of buffers, and there it is possible to retrieve the colours and the arrow codes of the objects, but not the buffers.

Which ever way you look at it, it is only possible if the Indicator uses and alternative method to allow access to those properties, but it is not possible for normal Indicators.

Dear Fernando, 


My code on this topic do not use Graphical Objects neither inputs. And the EA detect any color or code that I use on my source code.


You mentioned about use of Windows API, and I really d'ont know if the EA uses external dll's, because I haven't its source code. 


But  I d'ont know if is possible use Windows API without security alerts, and the EA d'ont issue this alerts. Do you know if is possible? 

 
Luiz Antonio De Sousa Marcon #: Dear Fernando, My code on this topic do not use Graphical Objects neither inputs. And the EA detect any color or code that I use on my source code. You mentioned about use of Windows API, and I really d'ont know if the EA uses external dll's, because I haven't its source code. But  I d'ont know if is possible use Windows API without security alerts, and the EA d'ont issue this alerts. Do you know if is possible? 

Without testing that EA of yours I cannot provide any answer to what it is doing. All I can say, is that it is not using normal standard methods of MQL to achieve that.

It may be probing the chart ".chr" files or using the "save template" as a way to read it from the template file, or some other indirect method. It may also happen that it is using some undocumented feature, but that seems highly unlikely.

Only by analysing and testing that EA could one perhaps find out how it is doing it.

EDIT: If this is a Market product (which can't be discussed here) and you wish to discuss it privately in order to analyse it, then you are welcome to send me a PM.

 
Fernando Carreiro #:

Without testing that EA of yours I cannot provide any answer to what it is doing. All I can say, is that it is not using normal standard methods of MQL to achieve that.

It may be probing the chart ".chr" files or using the "save template" as a way to read it from the template file, or some other indirect method. It may also happen that it is using some undocumented feature, but that seems highly unlikely.

Only by analysing and testing that EA could one perhaps find out how it is doing it.

EDIT: If this is a Market product (which can't be discussed here) and you wish to discuss it privately in order to analyse it, then you are welcome to send me a PM.


Dear Fernando, 

You are The MQL5 Sherlock Holmes!!!

It's using  ChartSaveTemplate - Operações de Gráficos - Referência MQL5 - Referência sobre algorítimo/automatização de negociação na linguagem para MetaTrader 5 and reading the tpl file of chart to discovery information! 

<indicator>
        name=Custom Indicator
        path=Indicators\ArrowTest.ex5
        apply=0
        show_data=1
        scale_inherit=0
        scale_line=0
        scale_line_percent=50
        scale_line_value=0.000000
        scale_fix_min=0
        scale_fix_min_val=0.000000
        scale_fix_max=0
        scale_fix_max_val=0.000000
        expertmode=0
        fixed_height=-1
        <graph>
                name=Arrow Test Sell
                draw=3
                style=0
                width=1
                arrow=250
                shift_y=-10
                
color=16776960
        </graph>
        <graph>
                name=Arrow Test Buy
                draw=3
                style=0
                width=1
                
arrow=230
                shift_y=10
                
color=65280

        </graph>
</indicator>

The tpl file contains < graph> tag with  type (draw), arrow(PLOT_ARROW code) and color(color)!

Thank you so much for help!  

Documentação sobre MQL5: Operações de Gráficos / ChartSaveTemplate
Documentação sobre MQL5: Operações de Gráficos / ChartSaveTemplate
  • www.mql5.com
ChartSaveTemplate - Operações de Gráficos - Referência MQL5 - Referência sobre algorítimo/automatização de negociação na linguagem para MetaTrader 5
 
Luiz Antonio De Sousa Marcon #: Dear Fernando, You are The MQL5 Sherlock Holmes!!! It's using  ChartSaveTemplate - Operações de Gráficos - Referência MQL5 - Referência sobre algorítimo/automatização de negociação na linguagem para MetaTrader 5 and reading the tpl file of chart to discovery information! The tpl file contains < graph> tag with  type (draw), arrow(PLOT_ARROW code) and color(color)! Thank you so much for help!  

You are welcome!