Ragazzi buongiorno sto provando ad inserire l'allert su un indicatore, ho fatto varie prove, ma una volta mi da l'allert su ogni candeel un'altra volte me lo da pure sui segnalili precedenti, qualcuno mi aiuterebbe a sistemarlo?
Indicatore originale senza allert
Prova di inserimento allert
Vi ringrazio in anticipo
Indicatore originale senza allert
PHP Code:
//+------------------------------------------------------------------+
//| Bulls.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Fractals Tanya"
#property strict
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrAliceBlue
#property indicator_color2 clrAliceBlue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
//--- input parameter
input int B_F=20;
//extern int AllB=240;
//--- buffers
double ExtFractalsUPBuffer[];
double ExtFractalsDownBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexBuffer(0, ExtFractalsUPBuffer);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 234);
SetIndexLabel(0, NULL);
SetIndexEmptyValue(0, 0.0);
SetIndexBuffer(1, ExtFractalsDownBuffer);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 233);
SetIndexLabel(1, NULL);
SetIndexEmptyValue(1, 0.0);
SetIndexDrawBegin(0,B_F);
SetIndexDrawBegin(1,B_F);
IndicatorShortName("FractalsTanya");
IndicatorDigits(Digits);
}
//+------------------------------------------------------------------+
//| Bulls Power |
//+------------------------------------------------------------------+
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[])
{
int limit=rates_total-prev_calculated;
//---
if(rates_total<=B_F || B_F<=0)
return(0);
//---
if(prev_calculated>0)
limit++;
int i=0,j=0,k=0;
double upFratal=0.0;
double downFratal=0.0;
int x=0;
int y=0;
for(int t=0; t<limit+B_F; t++)
{
double upTempFractal=iFractals(NULL,Period(),MODE_UPPER,t );
double downTempFractal=iFractals(NULL,Period(),MODE_LOWER ,t);
if(upTempFractal!=0&&upTempFractal>upFratal)
{
upFratal=upTempFractal;
j=t;
}
if(downTempFractal!=0.0&&downFratal==0.0)
{
downFratal=downTempFractal;
}
if(downTempFractal!=0.0&&downTempFractal<=downFrat al)
{
downFratal=downTempFractal;
k=t;
}
i++;
if(i==B_F)
{
if(upFratal!=0.0)
{
if(x==0||(j-x)>=B_F)
{
x=j;
ExtFractalsUPBuffer[j]=upFratal;
}
}
if(downFratal!=0.0)
{
if(y==0||(k-y)>=B_F)
{
y=k;
ExtFractalsDownBuffer[k]=downFratal;
}
}
i=0;
upFratal=0.0;
downFratal=0.0;
}
}
//for(int t=0; t<limit; t++)
//{
//double upFratal=iFractals(NULL,Period(),MODE_UPPER,t);
//double downFratal=iFractals(NULL,Period(),MODE_LOWER,t);
//if(upFratal!=0.0)
// ExtFractalsUPBuffer[t]=upFratal;
//else
// if(downFratal!=0.0)
// ExtFractalsDownBuffer[t]=downFratal;
//}
return(rates_total);
}
//+------------------------------------------------------------------+
PHP Code:
//+------------------------------------------------------------------+
//| Bulls.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Fractals Tanya"
#property strict
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrAliceBlue
#property indicator_color2 clrAliceBlue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
//--- input parameter
input int B_F=20;
//extern int AllB=240;
//--- buffers
double ExtFractalsUPBuffer[];
double ExtFractalsDownBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexBuffer(0, ExtFractalsUPBuffer);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 234);
SetIndexLabel(0, NULL);
SetIndexEmptyValue(0, 0.0);
SetIndexBuffer(1, ExtFractalsDownBuffer);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 233);
SetIndexLabel(1, NULL);
SetIndexEmptyValue(1, 0.0);
SetIndexDrawBegin(0,B_F);
SetIndexDrawBegin(1,B_F);
IndicatorShortName("FractalsTanya");
IndicatorDigits(Digits);
}
//+------------------------------------------------------------------+
//| Bulls Power |
//+------------------------------------------------------------------+
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[])
{
int limit=rates_total-prev_calculated;
//---
if(rates_total<=B_F || B_F<=0)
return(0);
//---
if(prev_calculated>0)
limit++;
int i=0,j=0,k=0;
double upFratal=0.0;
double downFratal=0.0;
int x=0;
int y=0;
for(int t=0; t<limit+B_F; t++)
{
double upTempFractal=iFractals(NULL,Period(),MODE_UPPER,t );
double downTempFractal=iFractals(NULL,Period(),MODE_LOWER ,t);
if(upTempFractal!=0&&upTempFractal>upFratal)
{
upFratal=upTempFractal;
j=t;
}
if(downTempFractal!=0.0&&downFratal==0.0)
{
downFratal=downTempFractal;
}
if(downTempFractal!=0.0&&downTempFractal<=downFrat al)
{
downFratal=downTempFractal;
k=t;
}
i++;
if(i==B_F)
{
if(upFratal!=0.0)
{
if(x==0||(j-x)>=B_F)
{
x=j;
ExtFractalsUPBuffer[j]=upFratal;
Alert("New upper fractal at ", TimeToString(time[j], TIME_DATE|TIME_MINUTES), " Price: ", upFratal);
}
}
if(downFratal!=0.0)
{
if(y==0||(k-y)>=B_F)
{
y=k;
ExtFractalsDownBuffer[k]=downFratal;
Alert("New lower fractal at ", TimeToString(time[k], TIME_DATE|TIME_MINUTES), " Price: ", downFratal);
}
}
i=0;
upFratal=0.0;
downFratal=0.0;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
Comment