Download MetaTrader 5

Arrow with Text (above/below) Question

To add comments, please log in or register
salexes
812
salexes  

I am currently struggeling to get text written directly below my drawn arrow.

This is my code right now 

//+------------------------------------------------------------------+
//|                             Indiv1.mq4 |
//+------------------------------------------------------------------+
#property copyright "© 2017"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1  clrLimeGreen
#property indicator_color2  clrRed

extern int             TrendPeriod = 10;
extern int             TrendPeriod2 = 9;

extern int             RSIPeriod = 9;
extern int             UpDownPeriod = 4;
extern int             ROCPeriod = 12;
extern int             Price  = 0;
extern int             RSIPeriod2 = 3;
extern int             UpDownPeriod2 = 4;
extern int             ROCPeriod2 = 27;

extern double          TrendMin     = -0.72;
extern double          TrendMax     = 0.76;
extern double          TrendMin2     = -0.77;
extern double          TrendMax2     = 0.70;
extern int             RSIMin = 30;
extern int             RSIMax = 69;

extern bool           alertsOn        = false;        // Turn alerts on?
extern bool           alertsOnCurrent = false;         // Alerts on current (still opened) bar?
extern bool           alertsMessage   = false;         // Alerts should show pop-up message?
extern bool           alertsSound     = false;        // Alerts should play alert sound?
extern bool           alertsPushNotif = false;        // Alerts should send push notification?
extern bool           alertsEmail     = false;        // Alerts should send email?
extern string         soundFile       = "alert2.wav"; // Sound file
extern int            ArrowCodeUp     = 233;          // Arrow code up
extern int            ArrowCodeDn     = 234;          // Arrow code down
extern double         ArrowGapUp      = 0.8;          // Gap for arrow up        
extern double         ArrowGapDn      = 0.8;          // Gap for arrow down
extern int            ArrowSize       = 2;            // Arrow size

double Up[];
double Down[];
double trend[];


int init()
{
   IndicatorBuffers(3);
   SetIndexBuffer(0,Up);    SetIndexStyle(0,DRAW_ARROW,0,ArrowSize); SetIndexArrow(0,ArrowCodeUp);
   SetIndexBuffer(1,Down);  SetIndexStyle(1,DRAW_ARROW,0,ArrowSize); SetIndexArrow(1,ArrowCodeDn);
   SetIndexBuffer(2,trend);
   SetIndexLabel(0, "CALL");
   SetIndexLabel(1, "PUT");
   ObjectCreate("Strength", OBJ_TEXT,0,0,0);
   return(0);
  }
//

int start()
{
    int i,counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
           int limit = fmin(Bars-counted_bars,Bars-1); 

   //
   //
   //
   //
   //

   for(i=limit; i>=0; i--)
   {
     // PUT YOUR DOUBLES HERE
     double td   = iCustom(NULL,0,"Trend direction & force index nmc",TrendPeriod,2,i);
     double crsi = iCustom(NULL,0,"Connors RSI",RSIPeriod,UpDownPeriod,ROCPeriod,Price,0,i);
     double td2   = iCustom(NULL,0,"Trend direction & force index nmc",TrendPeriod2,2,i);
     double crsi2 = iCustom(NULL,0,"Connors RSI",RSIPeriod2,UpDownPeriod2,ROCPeriod2,Price,0,i);   
     Up[i]   = EMPTY_VALUE;
     Down[i] = EMPTY_VALUE;
     trend[i] =  0;
     if (td<=TrendMin&&td2<=TrendMin2&&crsi<=RSIMin&&crsi2<=RSIMin) trend[i] = 1; 
     if (td>=TrendMax&&td2>=TrendMax2&&crsi>=RSIMax&&crsi2>=RSIMax) trend[i] =-1;
        if (i<Bars-1 && trend[i]!=trend[i+1])
         {
            if (trend[i] ==  1) Up[i]   = Low[i] -iATR(NULL,0,15,i)*ArrowGapUp;
            if (trend[i] == -1) Down[i] = High[i]+iATR(NULL,0,15,i)*ArrowGapDn;
         }
    } 
    
    if (alertsOn)
    {
       int whichBar = 1; if (alertsOnCurrent) whichBar = 0; 
       if (trend[whichBar] != trend[whichBar+1])
       {
          if (trend[whichBar] == 1) doAlert(" up");
          if (trend[whichBar] ==-1) doAlert(" down");       
       }         
     }        
return(0);
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];

          //
          //
          //
          //
          //

          message =  StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," PattiGold ",doWhat);
             if (alertsMessage)     Alert(message);
             if (alertsPushNotif )  SendNotification(message);
             if (alertsEmail)       SendMail(_Symbol+" PattiGold ",message);
             if (alertsSound)       PlaySound(soundFile);
      }
}

I want to put a text like in this example screenshot above the arrow, but I am not sure how to achive this (I am still very new to MQL4). Any help would be greatly appreciated. I need help placing the text above the arrows.


Kind regards,

salexes

whroeder1
16286
whroeder1  
salexes:

I am currently struggeling to get text written directly below my drawn arrow.

I am not sure how to achive this (I am still very new to MQL4).

  1. Help you with what? You haven't stated a problem.
  2. Perhaps you should read the manual.
  3. Where do you create your text object?
salexes
812
salexes  
whroeder1:
  1. Help you with what? You haven't stated a problem.
  2. Perhaps you should read the manual.
  3. Where do you create your text object?

1. I do not know how to place the created text object "ObjectCreate("Strength", OBJ_TEXT,0,0,0);" with the text depending on the strength of the signal (strong/medium/weak) above/below the arrows.

2. I did I still not know how to do it. That is why I ask here.

3. ObjectCreate("Strength", OBJ_TEXT,0,0,0);

whroeder1
16286
whroeder1  
salexes:

1. I do not know how

2. I did I still not know how

3. ObjectCreate("Strength", OBJ_TEXT,0,0,0);

  1. Go to the code base, find something that places text. Study it.
  2. 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.
  3. Babel. You know you can't create more than one with the same name. You know that is invalid price and time.
To add comments, please log in or register