Nie wiem jak zachować sygnał.Przy zmianie świecy zmienia się na 0.
Kod: Zaznacz cały
datetime LastActiontime;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int sygnal;
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
{
double s=iMACD(NULL,0,30,52,28,PRICE_CLOSE,MODE_SIGNAL,0);
double m=iMACD(NULL,0,30,52,28,PRICE_CLOSE,MODE_MAIN,0);
double s1=iMACD(NULL,0,30,52,28,PRICE_CLOSE,MODE_SIGNAL,1);
double m1=iMACD(NULL,0,30,52,28,PRICE_CLOSE,MODE_MAIN,1);
//---
//Comparing LastActionTime with the current starting time for the candle
if(LastActiontime!=Time[0])
{
if ((s<m)&&(s1>m1))
{
sygnal=1;
Alert("SYGNAL ",sygnal);
}
if ((s>m)&&(s1<m1)&&(sygnal==1))
{
// Otwieramy zlecenie
}
LastActiontime=Time[0];
}
}
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
}