Adding an on chart up and down arrows to modify indicator variable directly

 

hi to all

how can we  modify variable of an indicator directly on the chart instead of opining the indicator and modify the variable and then click ok....this will save time and at the same time let me learn new feature in mql4

because am not a mql programmer i need some help to add a code to the attached indicator that will make it as in the attached pic(this pic is made using windows paint program not a ready made ind..^_^) 

iv searched the forum and found topics  ...but it's deal with EA and scripts ..not indicators 

any help and suggestions are welcomed 



demonistration

//+------------------------------------------------------------------+
//|                                                  Candle Size.mq4 |
//|                                                        |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
#property indicator_width1 3

extern double distance = 0.0010;
extern string  "on";

double v1[];
double val1;
int i;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexArrow(0,217);
   SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,3);
   SetIndexDrawBegin(0, i-1);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0,"Candle bigger than Distance");
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   i = Bars;
   while(i >= 0)
     {   
       val1 = (High[i]-Low[i]);
       //----
       if(val1 > distance) {
           v1[i] = Low[i]-0.0005;
       }
       else{
           v1[i] = 0;
       }
       //----
       i--;
     }
   if(= "on" && v1[0] != 0){
      Alert("Candle Bigger Than ",distance);
   }      
   return(0);
  }
   
   
//----
//+------------------------------------------------------------------+
 

Hi, it's not easy. To start, add a text input object. Then you need to track the text input event in the function "OnChartEvent". Then change the input variable and restart the indicator.

You'll have to deal with it if you want to do it.


The function creates an object if it doesn't already exist.

//redraw the rectangle using the new coordinates. if it doesn't exist, then create it
void RedrawEdit(long eChartId, int eWindow, string eName, long eXdistance, long eYdistance, long eXsize, long eYsize, ENUM_BASE_CORNER eCorner, ENUM_ALIGN_MODE eAlign, bool eReadOnly, string eText, string eFont, int eSize, color eColor, color eColorBG, color eColorBR)
   {
   if(ObjectFind(eChartId,eName)==-1)
      {
      if(!ObjectCreate(eChartId,eName,OBJ_EDIT,eWindow,0,0)) return;
      //angle of the graph, relative to which the coordinates of the point will be determined
      ObjectSetInteger(eChartId,eName,OBJPROP_CORNER,eCorner);
      //text font
      ObjectSetString(eChartId,eName,OBJPROP_FONT,eFont);
      //font size
      ObjectSetInteger(eChartId,eName,OBJPROP_FONTSIZE,eSize);
      //how to align text in an object
      ObjectSetInteger(eChartId,eName,OBJPROP_ALIGN,eAlign);
      //read-only mode
      ObjectSetInteger(eChartId,eName,OBJPROP_READONLY,eReadOnly);
      //in the foreground
      ObjectSetInteger(eChartId,eName,OBJPROP_BACK,false);
      ObjectSetInteger(eChartId,eName,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(eChartId,eName,OBJPROP_SELECTED,false);
      ObjectSetInteger(eChartId,eName,OBJPROP_HIDDEN,true);
      ObjectSetInteger(eChartId,eName,OBJPROP_ZORDER,0);
      }
   if(ObjectFind(eChartId,eName)==-1) return;
   //coordinate system
   if(ObjectGetInteger(eChartId,eName,OBJPROP_XDISTANCE)!=eXdistance) ObjectSetInteger(eChartId,eName,OBJPROP_XDISTANCE,eXdistance);
   if(ObjectGetInteger(eChartId,eName,OBJPROP_YDISTANCE)!=eYdistance) ObjectSetInteger(eChartId,eName,OBJPROP_YDISTANCE,eYdistance);
   //dimensions
   if(ObjectGetInteger(eChartId,eName,OBJPROP_XSIZE)!=eXsize) ObjectSetInteger(eChartId,eName,OBJPROP_XSIZE,eXsize);
   if(ObjectGetInteger(eChartId,eName,OBJPROP_YSIZE)!=eYsize) ObjectSetInteger(eChartId,eName,OBJPROP_YSIZE,eYsize);
   //background color
   if(ObjectGetInteger(eChartId,eName,OBJPROP_BGCOLOR)!=eColorBG) ObjectSetInteger(eChartId,eName,OBJPROP_BGCOLOR,eColorBG);
   //frame color
   if(ObjectGetInteger(eChartId,eName,OBJPROP_BORDER_COLOR)!=eColorBR) ObjectSetInteger(eChartId,eName,OBJPROP_BORDER_COLOR,eColorBR);
   //text color
   if(ObjectGetInteger(eChartId,eName,OBJPROP_COLOR)!=eColor) ObjectSetInteger(eChartId,eName,OBJPROP_COLOR,eColor);   
   //установим текст
   if(ObjectGetString(eChartId,eName,OBJPROP_TEXT)!=eText) ObjectSetString(eChartId,eName,OBJPROP_TEXT,eText);
   }

Call the function something like this

RedrawEdit(ChartID(),0,"InputName",359,1,55,18,CORNER_RIGHT_UPPER,ALIGN_RIGHT,false,IntegerToString(InputValue),"Arial",9,C'0x2E,0x2F,0x2E',C'0xF5,0xF5,0xF5',C'0x98,0xA6,0xB4');
 
1587

Aleksei Stepanenko

thanks for you...

i thought that adding a simple things("OnChartEvent") to the chart is an easy task..

i will tray to deal with it..

as you said (You'll have to deal with it if you want to do it.)

..thank again  


 
    abd-:
   as you said (You'll have to deal with it if you want to do it.)

I wanted to say that this needs to be studied

 

Events are tracked in this function

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
   {
   //text input event
   if(id==CHARTEVENT_OBJECT_ENDEDIT)
      {
      if(sparam=="InputName"))
         {
        //-------------------
        //Here you can change the parameter and restart the indicator
        //-------------------
         }
      }
   }
 
Aleksei Stepanenko:

Events are tracked in this function


thanks agine

------------------------

(I wanted to say that this needs to be studied .)

am not very good in english..

for that..i didn't understand the meaning  ^_^

 
  abd-:


am not very good in english..

me too

Reason: