Download MetaTrader 5
To add comments, please log in or register
Take active part in the life of the community. Improve your rating!
Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.02 18:18 

Hello my dear friends as am new here in forum i need a help and hope to be helped by you all expert over here.

 

As i want to know that how can i change the name of the custom indicator  

for example if the name of the indicator is MACD and i want to change its name to NONAME how can i do this ?

secondly i want that this indicator only used by one whom i allow to use . for example his account number(log in id ) is 12345 , and the second person whom i allowed to use his account number(log in id) is 78910.

(i want that my indicator only to be used by one whom i select. and they are more than 70 or even more than in my group)

waiting for your help  

honest_knave
Moderator
1913
honest_knave 2015.11.03 09:36  
ankit_fx:

As i want to know that how can i change the name of the custom indicator  

for example if the name of the indicator is MACD and i want to change its name to NONAME how can i do this ?

 

int OnInit()
  {
   IndicatorShortName("NONAME");
   return(INIT_SUCCEEDED);
  }

 

ankit_fx:

secondly i want that this indicator only used by one whom i allow to use . for example his account number(log in id ) is 12345 , and the second person whom i allowed to use his account number(log in id) is 78910.

(i want that my indicator only to be used by one whom i select. and they are more than 70 or even more than in my group)

 Lots of different ways. Here is one example:

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[])
  {
   if(!ValidAcc()) { return(rates_total); }
   
   // rest of your code

   return(rates_total);
  }

bool ValidAcc()
  {
   switch(AccountNumber())
     {
      case 12345: return(true);
      case 78910: return(true);
      // add more account numbers here
     }   
   return(false);
  }
Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.03 17:15  
honest_knave:

 

 

 Lots of different ways. Here is one example:

  

thanks dear but its not compiled error. please send me mail on ankitkumarsjs@gmail.com 

or comment your mail so that i can contact you. please setup it 

honest_knave
Moderator
1913
honest_knave 2015.11.03 18:09  
ankit_fx:

thanks dear but its not compiled error. please send me mail on ankitkumarsjs@gmail.com 

or comment your mail so that i can contact you. please setup it 

The code compiles without error at my end:

 

 

 

I'm afraid I don't offer support by email, but if you post up your code here (using SRC) the community should be able to help

 

Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.04 01:20  
honest_knave:

 

 

 Lots of different ways. Here is one example:

  Sir as i am new in this i put your pasted your cord at the end of the mq.4 flie. Shall i paste at the staring of the file , middle of it or at bottom.

Thanks 

Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.04 03:52  
i am getting this error can you say where to insert the code you gave ?
Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.04 03:55  
honest_knave:

The code compiles without error at my end:

 

 

 

I'm afraid I don't offer support by email, but if you post up your code here (using SRC) the community should be able to help

 

 

am getting this error can you please say where to insert the cord ? for example i tried in macd
honest_knave
Moderator
1913
honest_knave 2015.11.04 07:53  

That error tells you that your indicator already has OnCalculate. There can only be one in an indicator.

If you are using the standard MACD indicator, it would look like this (new code highlighted in yellow):

 

//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              https://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "https://www.mql4.com"
#property description "Moving Averages Convergence/Divergence"
#property strict

#include <MovingAverages.mqh>

//--- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Silver
#property  indicator_color2  Red
#property  indicator_width1  2
//--- indicator parameters
input int InpFastEMA=12;   // Fast EMA Period
input int InpSlowEMA=26;   // Slow EMA Period
input int InpSignalSMA=9;  // Signal SMA Period
//--- indicator buffers
double    ExtMacdBuffer[];
double    ExtSignalBuffer[];
//--- right input parameters flag
bool      ExtParameters=false;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   IndicatorDigits(Digits+1);
//--- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,InpSignalSMA);
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer);
   SetIndexBuffer(1,ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
//--- check for input parameters
   if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
     {
      Print("Wrong input parameters");
      ExtParameters=false;
      return(INIT_FAILED);
     }
   else
      ExtParameters=true;
//--- initialization done
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
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[])
  {
   if(!ValidAcc()) { return(rates_total); }
   int i,limit;
//---
   if(rates_total<=InpSignalSMA || !ExtParameters)
      return(0);
//--- last counted bar will be recounted
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit++;
//--- macd counted in the 1-st buffer
   for(i=0; i<limit; i++)
      ExtMacdBuffer[i]=iMA(NULL,0,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
                    iMA(NULL,0,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//--- signal line counted in the 2-nd buffer
   SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
//--- done
   return(rates_total);
  }
//+------------------------------------------------------------------+

bool ValidAcc()
  {
   switch(AccountNumber())
     {
      case 12345: return(true);
      case 78910: return(true);
      // add more account numbers here
     }   
   return(false);
  }
Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.05 08:48  
honest_knave:

That error tells you that your indicator already has OnCalculate. There can only be one in an indicator.

If you are using the standard MACD indicator, it would look like this (new code highlighted in yellow):

 

 

please do in this 4 indicator am unable to compile succesfully
Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.06 00:39  

AM UNABLE TO TO IN THIS PLEASE DO IN THIS AS I DID IN MACD 

THANKS 

Ankit Kumar Bhagat
270
Ankit Kumar Bhagat 2015.11.06 00:41  
ankit_fx:

AM UNABLE TO TO IN THIS PLEASE DO IN THIS AS I DID IN MACD 

THANKS 

Files:
sidusv3.mq4 4 kb
/ /12
To add comments, please log in or register