Separate Windows Techinical Indicator Scale

To add comments, please log in or register
Pedro Henrique Vieira
228
Pedro Henrique Vieira  

Hello,

I searched the forum for a similar issue but unfortunately did not find it.

I am creating a very simple indicator, it just reads the volume and plots in a separate window. Despite this simplicity the chart is out of scale and the values ​​on Windows Data are totally wrong and random.

Does anyone have any ideas?

Thanks


William Roeder
19843
William Roeder  
Pedro Henrique Vieira: Does anyone have any ideas?
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
Pedro Henrique Vieira
228
Pedro Henrique Vieira  
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

Do not need to be so rude, that was my first time I used the forum. I am not get used to.

But even so, you are right.


Complete code is Attached


Files:
Jefferson Metha
1752
Jefferson Metha  
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

Sometimes it is best not to reply. 

Pedro Henrique Vieira:


Complete code is Attached


We don't see the code, please use copy and paste code, if u on PC there is a toolbox like this </> please select it and paste ur code there, 
if on Mobile phone please use the Attach file at the bottom of the typing Box

Pedro Henrique Vieira
228
Pedro Henrique Vieira  

Thank tou Jefferson!

The code is properly attached now, but i will send the entire code because I do not know where the bug is:

</

#property copyright "Copyright 2019, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#include <MovingAverages.mqh>

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_plots   4

//--- plot Venda



#property indicator_label1  "Venda"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrRed

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot Compra

#property indicator_label2  "Compra"

#property indicator_type2   DRAW_ARROW

#property indicator_color2  clrAqua

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1 

//--- plot Media



#property indicator_label3  "Media"

#property indicator_type3 DRAW_LINE

#property indicator_color3  clrYellow

#property indicator_style3  STYLE_SOLID

#property indicator_width3 1



//--- plot AD

#property indicator_label4  "A/D"

#property indicator_type4 DRAW_LINE

#property indicator_color4 clrOrange

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1







//--- input parameters

input int      Periodo=17;

input ENUM_APPLIED_VOLUME InpVolumeType=VOLUME_REAL;  // Tipo de tick



//--- indicator buffers

double         VendaBuffer[];

double         CompraBuffer[];

double         MediaBuffer[];

double         ADBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+



int AD_Handle;



int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,VendaBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,CompraBuffer,INDICATOR_DATA);

   SetIndexBuffer(2,MediaBuffer,INDICATOR_DATA);

   SetIndexBuffer(3,ADBuffer,INDICATOR_DATA);

//--- setting a code from the Wingdings charset as the property of PLOT_ARROW

   PlotIndexSetInteger(0,PLOT_ARROW,234);

   PlotIndexSetInteger(1,PLOT_ARROW,233);

  

   //--- indicator digits

   IndicatorSetInteger(INDICATOR_DIGITS,0);

//--- indicator short name

   //IndicatorSetString(INDICATOR_SHORTNAME,"A/D");

//--- set index draw begin

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,1);

   

   AD_Handle =  iAD(_Symbol,_Period,VOLUME_REAL);

   

   //ArraySetAsSeries(MediaBuffer,true);

   //ArraySetAsSeries(ADBuffer,true);

   

    ArrayInitialize( VendaBuffer,0);

    ArrayInitialize( CompraBuffer,0);

    ArrayInitialize( MediaBuffer,0);

    ArrayInitialize( ADBuffer,0);

//---

   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[])

  {

//---

   CopyBuffer(AD_Handle,0,0,rates_total,ADBuffer);

   



//--- return value of prev_calculated for next call



   int backstep=Periodo-1;

   int i=MathMax(backstep,prev_calculated-1);

   for( i; i<rates_total;i++)

   {

   

  

     double soma=0.0;

     for(int j=0; j<Periodo;j++)

     {

        soma=soma+ ADBuffer[i-j];

      

     }

     MediaBuffer[i]=soma/Periodo;

     

    

   

    if(MediaBuffer[i]>ADBuffer[i])

         {

            if(MediaBuffer[i-1]<ADBuffer[i-1])

            CompraBuffer[i]=low[i];

            else 

            EMPTY_VALUE;

         }

        

     if(MediaBuffer[i]<ADBuffer[i])

         {

            if(MediaBuffer[i-1]>ADBuffer[i-1])

            VendaBuffer[i]=high[i];

            else 

            EMPTY_VALUE; 

          }

   }

   

   return(rates_total);

  

  }

>
To add comments, please log in or register