Please i need on this indicator.

To add comments, please log in or register
kapoo
37
kapoo  

Am trying to change the signal symbol, I want another symbol instead of arrow.

//+------------------------------------------------------------------+
//|                                                       binary.mq4 |
//|                                                          johness |
//|                                                    		     |
//+------------------------------------------------------------------+
#property copyright "none"
#property link      "mmm"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters of the script 
input string            InpNameUP="ArrowUp";          // Sign name UP
input string            InpNameDOWN="ArrowDown";      // Sign name DOWN
input ENUM_ARROW_ANCHOR InpAnchorUP=ANCHOR_TOP;       // Anchor type 
input ENUM_ARROW_ANCHOR InpAnchorDOWN=ANCHOR_BOTTOM;  // Anchor type 
input color             InpColorUP=clrGreen;          // Sign color UP
input color             InpColorDOWN=clrRed;          // Sign color DOWN
input ENUM_LINE_STYLE   InpStyle=STYLE_DOT;           // Border line style 
input int               InpWidth=5;                   // Sign size 
input bool              InpBack=false;                // Background sign 
input bool              InpSelection=false;           // Highlight to move 
input bool              InpHidden=true;               // Hidden in the object list 
input long              InpZOrder=0;                  // Priority for mouse click 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int OnInit(void)
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Indicator                                                        |
//+------------------------------------------------------------------+
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[])
  {


   static datetime prev;
   int limit;
   if(prev_calculated==0) // first calculation or changed history
     {
      ObjectsDeleteAll(0,OBJ_ARROW);
      ChartRedraw();
      limit=rates_total-1-4;
      for(int i=limit;i>=0;i--)
        {
         if(time[i]>prev) // new bar
           {
            if( close[i+3]>open[i+3] && close[i+2]>open[i+2] && close[i+1]<open[i+2])
              {
               string SELLSIGNAL=InpNameDOWN+"_"+(string)time[i];
               ArrowDownCreate(0,SELLSIGNAL,0,time[i+1],high[i+1],InpAnchorDOWN,InpColorDOWN,InpStyle,
                               InpWidth,InpBack,InpSelection,InpHidden);
              }
            else if( close[i+3]<open[i+3] && close[i+2]<open[i+2] && close[i+1]>open[i+2])
              {
               string BUYSIGNAL=InpNameUP+"_"+(string)time[i];
               ArrowUpCreate(0,BUYSIGNAL,0,time[i+1],low[i+1],InpAnchorUP,InpColorUP,InpStyle,
                             InpWidth,InpBack,InpSelection,InpHidden);
              }
           }
         prev=time[i];
        }
      return(rates_total);
     }
   if(time[0]>prev) // new bar
     {
      //----
      if( close[3]>open[3] && close[2]>open[2] && close[1]<open[2])
        {
        Alert (Symbol()+" M"+Period()+": Sell Alert @ "+DoubleToStr(Bid,Digits));
         string SELLSIGNAL=InpNameDOWN+"_"+(string)time[0];
         ArrowDownCreate(0,SELLSIGNAL,0,time[1],high[1],InpAnchorDOWN,InpColorDOWN,InpStyle,
                         InpWidth,InpBack,InpSelection,InpHidden);
        }
      else if( close[3]<open[3] && close[2]<open[2] && close[1]>open[2])
        {
        Alert (Symbol()+" M"+Period()+": Buy Alert @ "+DoubleToStr(Ask,Digits));
         string BUYSIGNAL=InpNameUP+"_"+(string)time[0];
         ArrowUpCreate(0,BUYSIGNAL,0,time[1],low[1],InpAnchorUP,InpColorUP,InpStyle,
                       InpWidth,InpBack,InpSelection,InpHidden);
        }
     }
   prev=time[0];
//----
   return(rates_total);
  }
//+------------------------------------------------------------------+ 
//| Create Array Up sign                                             | 
//+------------------------------------------------------------------+ 
bool ArrowUpCreate(const long              chart_ID=0,           // chart's ID 
                   const string            name="ArrowUp",       // sign name 
                   const int               sub_window=0,         // subwindow index 
                   datetime                time=0,               // anchor point time 
                   double                  price=0,              // anchor point price 
                   const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // anchor type 
                   const color             clr=clrRed,           // sign color 
                   const ENUM_LINE_STYLE   style=STYLE_SOLID,    // border line style 
                   const int               width=3,              // sign size 
                   const bool              back=false,           // in the background 
                   const bool              selection=true,       // highlight to move 
                   const bool              hidden=true,          // hidden in the object list 
                   const long              z_order=0)            // priority for mouse click 
  {
//--- reset the error value 
   ResetLastError();
//--- create the sign 
   if(!ObjectCreate(chart_ID,name,OBJ_ARROW_UP,sub_window,time,price))
     {
      Print(__FUNCTION__,
            ": failed to create \"Arrow Up\" sign! Error code = ",GetLastError());
      return(false);
     }
//--- set anchor type 
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set a sign color 
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set the border line style 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set the sign size 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- display in the foreground (false) or background (true) 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the sign by mouse 
//--- when creating a graphical object using ObjectCreate function, the object cannot be 
//--- highlighted and moved by default. Inside this method, selection parameter 
//--- is true by default making it possible to highlight and move the object 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list 
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart 
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution 
   return(true);
  }
//+------------------------------------------------------------------+ 
//| Create Array Down sign                                           | 
//+------------------------------------------------------------------+ 
bool ArrowDownCreate(const long              chart_ID=0,           // chart's ID 
                     const string            name="ArrowDown",     // sign name 
                     const int               sub_window=0,         // subwindow index 
                     datetime                time=0,               // anchor point time 
                     double                  price=0,              // anchor point price 
                     const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // anchor type 
                     const color             clr=clrRed,           // sign color 
                     const ENUM_LINE_STYLE   style=STYLE_SOLID,    // border line style 
                     const int               width=3,              // sign size 
                     const bool              back=false,           // in the background 
                     const bool              selection=true,       // highlight to move 
                     const bool              hidden=true,          // hidden in the object list 
                     const long              z_order=0)            // priority for mouse click 
  {
//--- reset the error value 
   ResetLastError();
//--- create the sign 
   if(!ObjectCreate(chart_ID,name,OBJ_ARROW_DOWN,sub_window,time,price))
     {
      Print(__FUNCTION__,
            ": failed to create \"Arrow Down\" sign! Error code = ",GetLastError());
      return(false);
     }
//--- anchor type 
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set a sign color 
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set the border line style 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set the sign size 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- display in the foreground (false) or background (true) 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the sign by mouse 
//--- when creating a graphical object using ObjectCreate function, the object cannot be 
//--- highlighted and moved by default. Inside this method, selection parameter 
//--- is true by default making it possible to highlight and move the object 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list 
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart 
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution 
   return(true);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Print(__FUNCTION__);
   ObjectsDeleteAll(0,OBJ_ARROW);
   ChartRedraw();
  }
  
//+------------------------------------------------------------------+
kapoo
37
kapoo  

Your input will be appreciated.

whroeder1
17942
whroeder1  
kapoo: Am trying to change the signal symbol, I want another symbol instead of arrow.
  1. Help you with what? You haven't stated a problem. You have only four choices: We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem. No free help. urgent help.
  2. There are only a few choices Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Reference on algorithmic/automated trading language for MetaTrader 5 unless you use an OBJ_ARROW
  3. Really the indicator shouldn't be creating objects at all, it should use two arrow type buffers.
kapoo
37
kapoo  
whroeder1:
  1. Help you with what? You haven't stated a problem. You have only four choices: We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem. No free help. urgent help.
  2. There are only a few choices Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Reference on algorithmic/automated trading language for MetaTrader 5 unless you use an OBJ_ARROW
  3. Really the indicator shouldn't be creating objects at all, it should use two arrow type buffers.



Below is what have tried but am still having issue on it.

//+------------------------------------------------------------------+
//|                                                       binary.mq4 |
//|                                                          johness |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "none"
#property link      "mmm"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters of the script 
input string            InpNameUP="ArrowUp";          // Sign name UP
input string            InpNameDOWN="ArrowDown";      // Sign name DOWN
input ENUM_ARROW_ANCHOR InpAnchorUP=ANCHOR_TOP;       // Anchor type 
input ENUM_ARROW_ANCHOR InpAnchorDOWN=ANCHOR_BOTTOM;  // Anchor type 
input color             InpColorUP=clrGreen;          // Sign color UP
input color             InpColorDOWN=clrRed;          // Sign color DOWN
input ENUM_LINE_STYLE   InpStyle=STYLE_DOT;           // Border line style 
input int               InpWidth=5;                   // Sign size 
input bool              InpBack=false;                // Background sign 
input bool              InpSelection=false;           // Highlight to move 
input bool              InpHidden=true;               // Hidden in the object list 
input long              InpZOrder=0;                  // Priority for mouse click 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int OnInit(void)
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Indicator                                                        |
//+------------------------------------------------------------------+
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[])
  {


   static datetime prev;
   int limit;
   if(prev_calculated==0) // first calculation or changed history
     {
      ObjectsDeleteAll(0,OBJ_ARROW);
      ChartRedraw();
      limit=rates_total-1-4;
      for(int i=limit;i>=0;i--)
        {
         if(time[i]>prev) // new bar
           {
            if( close[i+3]>open[i+3] && close[i+2]>open[i+2] && close[i+1]<open[i+2])
              {
               string SELLSIGNAL=InpNameDOWN+"_"+(string)time[i];
               ArrowDownCreate(0,SELLSIGNAL,0,time[i+1],high[i+1],InpAnchorDOWN,InpColorDOWN,InpStyle,
                               InpWidth,InpBack,InpSelection,InpHidden);
              }
            else if( close[i+3]<open[i+3] && close[i+2]<open[i+2] && close[i+1]>open[i+2])
              {
               string BUYSIGNAL=InpNameUP+"_"+(string)time[i];
               ArrowUpCreate(0,BUYSIGNAL,0,time[i+1],low[i+1],InpAnchorUP,InpColorUP,InpStyle,
                             InpWidth,InpBack,InpSelection,InpHidden);
              }
           }
         prev=time[i];
        }
      return(rates_total);
     }
   if(time[0]>prev) // new bar
     {
      //----
      if( close[3]>open[3] && close[2]>open[2] && close[1]<open[2])
        {
        Alert (Symbol()+" M"+Period()+": Sell Alert @ "+DoubleToStr(Bid,Digits));
         string SELLSIGNAL=InpNameDOWN+"_"+(string)time[0];
         ArrowDownCreate(0,SELLSIGNAL,0,time[1],high[1],InpAnchorDOWN,InpColorDOWN,InpStyle,
                         InpWidth,InpBack,InpSelection,InpHidden);
        }
      else if( close[3]<open[3] && close[2]<open[2] && close[1]>open[2])
        {
        Alert (Symbol()+" M"+Period()+": Buy Alert @ "+DoubleToStr(Ask,Digits));
         string BUYSIGNAL=InpNameUP+"_"+(string)time[0];
         ArrowUpCreate(0,BUYSIGNAL,0,time[1],low[1],InpAnchorUP,InpColorUP,InpStyle,
                       InpWidth,InpBack,InpSelection,InpHidden);
        }
     }
   prev=time[0];
//----
   return(rates_total);
  }
//+------------------------------------------------------------------+ 
//| Create Array Up sign                                             | 
//+------------------------------------------------------------------+ 
bool ArrowUpCreate(const long              chart_ID=0,           // chart's ID 
                   const string            name="ArrowUp",       // sign name 
                   const int               sub_window=0,         // subwindow index 
                   datetime                time=0,               // anchor point time 
                   double                  price=0,              // anchor point price 
                   
                   //i try to include this , but am still getting error
                   const uchar             arrow_code=203,
                   
                   
                   const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // anchor type 
                   const color             clr=clrRed,           // sign color 
                   const ENUM_LINE_STYLE   style=STYLE_SOLID,    // border line style 
                   const int               width=3,              // sign size 
                   const bool              back=false,           // in the background 
                   const bool              selection=true,       // highlight to move 
                   const bool              hidden=true,          // hidden in the object list 
                   const long              z_order=0)            // priority for mouse click 
  {
//--- reset the error value 
   ResetLastError();
//--- create the sign 
   if(!ObjectCreate(chart_ID,name,OBJ_ARROW_UP,sub_window,time,price))
     {
      Print(__FUNCTION__,
            ": failed to create \"Arrow Up\" sign! Error code = ",GetLastError());
      return(false);
     }
     
     //with this also
      ObjectSetInteger(chart_ID,name,OBJPROP_ARROWCODE,arrow_code);
     
     
//--- set anchor type 
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set a sign color 
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set the border line style 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set the sign size 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- display in the foreground (false) or background (true) 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the sign by mouse 
//--- when creating a graphical object using ObjectCreate function, the object cannot be 
//--- highlighted and moved by default. Inside this method, selection parameter 
//--- is true by default making it possible to highlight and move the object 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list 
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart 
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution 
   return(true);
  }
//+------------------------------------------------------------------+ 
//| Create Array Down sign                                           | 
//+------------------------------------------------------------------+ 
bool ArrowDownCreate(const long              chart_ID=0,           // chart's ID 
                     const string            name="ArrowDown",     // sign name 
                     const int               sub_window=0,         // subwindow index 
                     datetime                time=0,               // anchor point time 
                     double                  price=0,              // anchor point price
                     
                     
                     //i try to include this , but am still getting error
                   const uchar             arrow_code=203,
                     
                      
                     const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // anchor type 
                     const color             clr=clrRed,           // sign color 
                     const ENUM_LINE_STYLE   style=STYLE_SOLID,    // border line style 
                     const int               width=3,              // sign size 
                     const bool              back=false,           // in the background 
                     const bool              selection=true,       // highlight to move 
                     const bool              hidden=true,          // hidden in the object list 
                     const long              z_order=0)            // priority for mouse click 
  {
//--- reset the error value 
   ResetLastError();
//--- create the sign 
   if(!ObjectCreate(chart_ID,name,OBJ_ARROW_DOWN,sub_window,time,price))
     {
      Print(__FUNCTION__,
            ": failed to create \"Arrow Down\" sign! Error code = ",GetLastError());
      return(false);
     }
     
     
      //with this also
      ObjectSetInteger(chart_ID,name,OBJPROP_ARROWCODE,arrow_code);
     
     
//--- anchor type 
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set a sign color 
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set the border line style 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set the sign size 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- display in the foreground (false) or background (true) 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the sign by mouse 
//--- when creating a graphical object using ObjectCreate function, the object cannot be 
//--- highlighted and moved by default. Inside this method, selection parameter 
//--- is true by default making it possible to highlight and move the object 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list 
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart 
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution 
   return(true);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Print(__FUNCTION__);
   ObjectsDeleteAll(0,OBJ_ARROW);
   ChartRedraw();
  }
  
//+------------------------------------------------------------------+


  

whroeder1
17942
whroeder1  
kapoo: Below is what have tried but am still having issue on it.
  1. Three posts and you still haven't stated a problem. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. const uchar             arrow_code=203,
    if(!ObjectCreate(chart_ID,name,OBJ_ARROW_UP,sub_window,time,price)) ...
    
    ObjectSetInteger(chart_ID,name,OBJPROP_ARROWCODE,arrow_code);
    You can't set a arrow code, for non-arrow objects.
  3. I already said "There are only a few choices Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Reference on algorithmic/automated trading language for MetaTrader 5 unless you use an OBJ_ARROW" Did you look at the links I provided?

    ID

     

    Description

    ID

     

    Description

    OBJ_ARROW_THUMB_UP


    Thumbs Up

    OBJ_ARROW_LEFT_PRICE


    Left Price Label

    OBJ_ARROW_THUMB_DOWN


    Thumbs Down

    OBJ_ARROW_RIGHT_PRICE


    Right Price Label

    OBJ_ARROW_UP


    Arrow Up

    OBJ_ARROW_BUY


    Buy Sign

    OBJ_ARROW_DOWN


    Arrow Down

    OBJ_ARROW_SELL


    Sell Sign

    OBJ_ARROW_STOP


    Stop Sign

    OBJ_ARROW


    Arrow

    OBJ_ARROW_CHECK


    Check Sign


    Those are your only options.
To add comments, please log in or register