Please , i am just learning to write mql language from the basics. i dont really know much for now.
i am trying to add code to some indicators so that it will expire automatically after 30days or 45 days of trial without me , interferring it all the time. this means any time it is being used, after 30 days (or 45 days,) it automatically expire and shows pop up alert like ' THE INDICATOR HAS EXPIRED, CONTACT [email protected] FOR FURTHER ASSISTANCE", just in a simple and easy way to protect it
but it is not just working and compliling as i have been doing it.
PLEASE CAN SOME ONE JUST ASSIST ME IN ITS SIMPLEST FORM,
1.THE CODE I WILL COPY AND PASTE ACCORDING TO WHAT I EXPLAINED
2. WHERE TO INSERT IT (ATTACHED IS 2 DIFFRENT INDICATORS SO THAT IT CAN BE OF HELP BY SHOWING the inserted codes IN DIFFRENT COLORS SO THAT I CAN GET IT ONCE AND FOR ALL.
I WILL REALLY APPRECIATE IT IF I GET ASSISTANCE,MATES
THE SAMPLE CODES, GETTING PROBLEMS FROM HIGHTED REGIONS
//+------------------------------------------------------------------+
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3
double CrossUp[];
double CrossDown[];
int CurrentTrend = 0;
int starttime = 0;
bool last_signal_down;
bool last_signal_up;
extern int BB_value = 14;
extern int Arrow_Pip_Distance = 100;
extern int Show_Alert = 1;
extern int Play_Sound = 1;
extern int Send_Mail = 0;
extern string SoundFilename = "alert.wav";
int init()
{
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
starttime = TimeLocal();
return(0);
}
int deinit()
{
Comment(" ");
return(0);
}
int start(if (TimeMonth(TimeCurrent()) >= 1 && validindicator == true)
{
Alert("The Indicator has expired");
validindicator=false;
}
if(validindicator == false)
{
return(0);
}) {
int limit, i, counter, loop;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1); //---- check for possible errors
if(counted_bars>0) counted_bars--; //---- last counted bar will be recounted
limit=Bars-counted_bars;
loop = 0;
for(i = 0; i <= limit; i++) {
double currbull = MathAbs(iBullsPower(NULL, 0, BB_value, 0, i));
double currbear = MathAbs(iBearsPower(NULL, 0, BB_value, 0, i));
double prevbull = MathAbs(iBullsPower(NULL, 0, BB_value, 0, i+1));
double prevbear = MathAbs(iBearsPower(NULL, 0, BB_value, 0, +i+1));
if (currbull>currbear && prevbull<prevbear)//ORDER ENTRY CONDITION LONG
{
CrossUp[i] = Low[i] - Arrow_Pip_Distance*Point;
last_signal_down=false;
last_signal_up=true;
if ((loop == 0) && (CurrentTrend != 1) && (TimeLocal() - starttime >= 10)) {
if (Show_Alert == 1) {
Alert("(M"+Period()+") "+Symbol()+" Bull-Bear Buy " + Hour()+":"+Minute()+" Ask: "+Ask);
}
if (Play_Sound == 1) {
PlaySound(SoundFilename);
}
if (Send_Mail == 1) {
SendMail("Bull-Bear MTF Buy " + Symbol() + " " + Hour()+":"+Minute()+" Ask: "+Ask+" (M"+Period()+")"," ");
}
CurrentTrend = 1;
}
if (loop == 0) {
loop = 1;
}
}
else
if (currbull<currbear && prevbull>prevbear)//ORDER ENTRY CONDITION LONG
{
CrossDown[i] = High[i] + Arrow_Pip_Distance*Point;
last_signal_down=true;
last_signal_up=false;
if ((loop == 0) && (CurrentTrend != -1) && (TimeLocal() - starttime >= 10)) {
if (Show_Alert == 1) {
Alert("(M"+Period()+") "+Symbol()+" Bull-Bear Sell " + Hour()+":"+Minute()+" Bid: "+Bid);
}
if (Play_Sound == 1) {
PlaySound(SoundFilename);
}
if (Send_Mail == 1) {
SendMail("Bull-Bear Sell " + Symbol() + " " + Hour()+":"+Minute()+" Bid: "+Bid+" (M"+Period()+")"," ");
}
CurrentTrend = -1;
}
if (loop == 0) {
loop = 1;
}
}
}
return(0);
}
ANOTHER PLAIN SAMPLE ONE WITHOUT ERROR
//+------------------------------------------------------------------+
//| |
//| |
//| |
//+------------------------------------------------------------------+
#property link ""
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_color1 DimGray
#property indicator_style1 STYLE_DOT
#property indicator_color2 DimGray
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_width3 2
#property indicator_width4 2
//---- input parameters
//
// nice setings for trend = 35,10,1
//
//
extern string note1 = "Stochastic settings";
extern int KPeriod = 30;
extern int Slowing = 10;
extern int DPeriod = 10;
extern string note4 = "0=sma, 1=ema, 2=smma, 3=lwma";
extern int MAMethod = 0;
extern string note5 = "0=high/low, 1=close/close";
extern int PriceField = 1;
extern string note6 = "overbought level";
extern int overBought = 80;
extern string note7 = "oversold level";
extern int overSold = 20;
//---- buffers
//
//
//
//
//
double KFull[];
double DFull[];
double Upper[];
double Lower[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,DFull);
SetIndexBuffer(1,KFull);
SetIndexBuffer(2,Upper);
SetIndexBuffer(3,Lower);
SetIndexLabel(1,"Fast");
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);
//
//
//
//
//
DPeriod = MathMax(DPeriod,1);
if (DPeriod==1) {
SetIndexStyle(0,DRAW_NONE);
SetIndexLabel(0,NULL);
}
else {
SetIndexStyle(0,DRAW_LINE);
SetIndexLabel(0,"Slow");
}
//
//
//
//
//
string shortName = "Stochastic ("+KPeriod+","+Slowing+","+DPeriod+","+maDescription(MAMethod)+","+priceDescription(PriceField);
if (overBought < overSold) overBought = overSold;
if (overBought < 100) shortName = shortName+","+overBought;
if (overSold > 0) shortName = shortName+","+overSold;
IndicatorShortName(shortName+")");
return(0);
}
//
//
//
//
//
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit;
int i;
if(counted_bars<0) return(-1);
limit=Bars-counted_bars;
//
//
//
//
//
for(i=limit; i>=0; i--)
{
KFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_MAIN,i);
DFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_SIGNAL,i);
//
//
//
//
//
if (KFull[i] > overBought) { Upper[i] = KFull[i]; Upper[i+1] = KFull[i+1]; }
else { Upper[i] = EMPTY_VALUE;
if (Upper[i+2] == EMPTY_VALUE)
Upper[i+1] = EMPTY_VALUE; }
if (KFull[i] < overSold) { Lower[i] = KFull[i]; Lower[i+1] = KFull[i+1]; }
else { Lower[i] = EMPTY_VALUE;
if (Lower[i+2] == EMPTY_VALUE)
Lower[i+1] = EMPTY_VALUE; }
}
//
//
//
//
//
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string priceDescription(int mode)
{
string answer;
switch(mode)
{
case 0: answer = "Low/High" ; break;
case 1: answer = "Close/Close" ; break;
default: answer = "Invalid price field requested";
Alert(answer);
}
return(answer);
}
string maDescription(int mode)
{
string answer;
switch(mode)
{
case MODE_SMA: answer = "SMA" ; break;
case MODE_EMA: answer = "EMA" ; break;
case MODE_SMMA: answer = "SMMA" ; break;
case MODE_LWMA: answer = "LWMA" ; break;
default: answer = "Invalid MA mode requested";
Alert(answer);
}
return(answer);
}
i am trying to add code to some indicators so that it will expire automatically after 30days or 45 days of trial without me , interferring it all the time. this means any time it is being used, after 30 days (or 45 days,) it automatically expire and shows pop up alert like ' THE INDICATOR HAS EXPIRED, CONTACT [email protected] FOR FURTHER ASSISTANCE", just in a simple and easy way to protect it
but it is not just working and compliling as i have been doing it.
PLEASE CAN SOME ONE JUST ASSIST ME IN ITS SIMPLEST FORM,
1.THE CODE I WILL COPY AND PASTE ACCORDING TO WHAT I EXPLAINED
2. WHERE TO INSERT IT (ATTACHED IS 2 DIFFRENT INDICATORS SO THAT IT CAN BE OF HELP BY SHOWING the inserted codes IN DIFFRENT COLORS SO THAT I CAN GET IT ONCE AND FOR ALL.
I WILL REALLY APPRECIATE IT IF I GET ASSISTANCE,MATES
THE SAMPLE CODES, GETTING PROBLEMS FROM HIGHTED REGIONS
//+------------------------------------------------------------------+
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3
double CrossUp[];
double CrossDown[];
int CurrentTrend = 0;
int starttime = 0;
bool last_signal_down;
bool last_signal_up;
extern int BB_value = 14;
extern int Arrow_Pip_Distance = 100;
extern int Show_Alert = 1;
extern int Play_Sound = 1;
extern int Send_Mail = 0;
extern string SoundFilename = "alert.wav";
int init()
{
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
starttime = TimeLocal();
return(0);
}
int deinit()
{
Comment(" ");
return(0);
}
int start(if (TimeMonth(TimeCurrent()) >= 1 && validindicator == true)
{
Alert("The Indicator has expired");
validindicator=false;
}
if(validindicator == false)
{
return(0);
}) {
int limit, i, counter, loop;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1); //---- check for possible errors
if(counted_bars>0) counted_bars--; //---- last counted bar will be recounted
limit=Bars-counted_bars;
loop = 0;
for(i = 0; i <= limit; i++) {
double currbull = MathAbs(iBullsPower(NULL, 0, BB_value, 0, i));
double currbear = MathAbs(iBearsPower(NULL, 0, BB_value, 0, i));
double prevbull = MathAbs(iBullsPower(NULL, 0, BB_value, 0, i+1));
double prevbear = MathAbs(iBearsPower(NULL, 0, BB_value, 0, +i+1));
if (currbull>currbear && prevbull<prevbear)//ORDER ENTRY CONDITION LONG
{
CrossUp[i] = Low[i] - Arrow_Pip_Distance*Point;
last_signal_down=false;
last_signal_up=true;
if ((loop == 0) && (CurrentTrend != 1) && (TimeLocal() - starttime >= 10)) {
if (Show_Alert == 1) {
Alert("(M"+Period()+") "+Symbol()+" Bull-Bear Buy " + Hour()+":"+Minute()+" Ask: "+Ask);
}
if (Play_Sound == 1) {
PlaySound(SoundFilename);
}
if (Send_Mail == 1) {
SendMail("Bull-Bear MTF Buy " + Symbol() + " " + Hour()+":"+Minute()+" Ask: "+Ask+" (M"+Period()+")"," ");
}
CurrentTrend = 1;
}
if (loop == 0) {
loop = 1;
}
}
else
if (currbull<currbear && prevbull>prevbear)//ORDER ENTRY CONDITION LONG
{
CrossDown[i] = High[i] + Arrow_Pip_Distance*Point;
last_signal_down=true;
last_signal_up=false;
if ((loop == 0) && (CurrentTrend != -1) && (TimeLocal() - starttime >= 10)) {
if (Show_Alert == 1) {
Alert("(M"+Period()+") "+Symbol()+" Bull-Bear Sell " + Hour()+":"+Minute()+" Bid: "+Bid);
}
if (Play_Sound == 1) {
PlaySound(SoundFilename);
}
if (Send_Mail == 1) {
SendMail("Bull-Bear Sell " + Symbol() + " " + Hour()+":"+Minute()+" Bid: "+Bid+" (M"+Period()+")"," ");
}
CurrentTrend = -1;
}
if (loop == 0) {
loop = 1;
}
}
}
return(0);
}
ANOTHER PLAIN SAMPLE ONE WITHOUT ERROR
//+------------------------------------------------------------------+
//| |
//| |
//| |
//+------------------------------------------------------------------+
#property link ""
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_color1 DimGray
#property indicator_style1 STYLE_DOT
#property indicator_color2 DimGray
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_width3 2
#property indicator_width4 2
//---- input parameters
//
// nice setings for trend = 35,10,1
//
//
extern string note1 = "Stochastic settings";
extern int KPeriod = 30;
extern int Slowing = 10;
extern int DPeriod = 10;
extern string note4 = "0=sma, 1=ema, 2=smma, 3=lwma";
extern int MAMethod = 0;
extern string note5 = "0=high/low, 1=close/close";
extern int PriceField = 1;
extern string note6 = "overbought level";
extern int overBought = 80;
extern string note7 = "oversold level";
extern int overSold = 20;
//---- buffers
//
//
//
//
//
double KFull[];
double DFull[];
double Upper[];
double Lower[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,DFull);
SetIndexBuffer(1,KFull);
SetIndexBuffer(2,Upper);
SetIndexBuffer(3,Lower);
SetIndexLabel(1,"Fast");
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);
//
//
//
//
//
DPeriod = MathMax(DPeriod,1);
if (DPeriod==1) {
SetIndexStyle(0,DRAW_NONE);
SetIndexLabel(0,NULL);
}
else {
SetIndexStyle(0,DRAW_LINE);
SetIndexLabel(0,"Slow");
}
//
//
//
//
//
string shortName = "Stochastic ("+KPeriod+","+Slowing+","+DPeriod+","+maDescription(MAMethod)+","+priceDescription(PriceField);
if (overBought < overSold) overBought = overSold;
if (overBought < 100) shortName = shortName+","+overBought;
if (overSold > 0) shortName = shortName+","+overSold;
IndicatorShortName(shortName+")");
return(0);
}
//
//
//
//
//
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit;
int i;
if(counted_bars<0) return(-1);
limit=Bars-counted_bars;
//
//
//
//
//
for(i=limit; i>=0; i--)
{
KFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_MAIN,i);
DFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_SIGNAL,i);
//
//
//
//
//
if (KFull[i] > overBought) { Upper[i] = KFull[i]; Upper[i+1] = KFull[i+1]; }
else { Upper[i] = EMPTY_VALUE;
if (Upper[i+2] == EMPTY_VALUE)
Upper[i+1] = EMPTY_VALUE; }
if (KFull[i] < overSold) { Lower[i] = KFull[i]; Lower[i+1] = KFull[i+1]; }
else { Lower[i] = EMPTY_VALUE;
if (Lower[i+2] == EMPTY_VALUE)
Lower[i+1] = EMPTY_VALUE; }
}
//
//
//
//
//
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string priceDescription(int mode)
{
string answer;
switch(mode)
{
case 0: answer = "Low/High" ; break;
case 1: answer = "Close/Close" ; break;
default: answer = "Invalid price field requested";
Alert(answer);
}
return(answer);
}
string maDescription(int mode)
{
string answer;
switch(mode)
{
case MODE_SMA: answer = "SMA" ; break;
case MODE_EMA: answer = "EMA" ; break;
case MODE_SMMA: answer = "SMMA" ; break;
case MODE_LWMA: answer = "LWMA" ; break;
default: answer = "Invalid MA mode requested";
Alert(answer);
}
return(answer);
}
We Win Some, We Loose Some, But Let your Win Rates be More to be Successful