I am using Swing_ZZ indicator, and simply want to buy at a red dot, and sell at the blue dot. However, the following is not working. How can I generate appropriate buy/sell signals. Using the following code, but don't get signals at the correct spots.
int start()
{
//----
string UpName,DownName;int UpCounter,DownCounter;
for(int i=Bars;i>0;i--)
{
if(DailySignal()==1)
{
//Print("Long Triggered at Month : ",Month(), " and Day : ",Day()," & Daily Signal = ",DailySignal());
UpName="UP"+i;//UpCounter;
GoLong=true;GoShort=false;
ObjectCreate(UpName, OBJ_ARROW, 0, Time[0], Open[0]+20*Point); //draw an up arrow
ObjectSet(UpName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(UpName, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet(UpName, OBJPROP_COLOR, White);
}
if(DailySignal()==-1)
{
//Print("Short Triggered at Month : ",Month(), " and Day : ",Day()," & Daily Signal = ",DailySignal());
DownName="Down"+i;//DownCounter;
GoLong=false;GoShort=true;
ObjectCreate(DownName, OBJ_ARROW, 0, Time[0], Open[0]+20*Point); //draw an up arrow
ObjectSet(DownName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(DownName, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
ObjectSet(DownName, OBJPROP_COLOR, Red);
}
return(0);
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I am using Swing_ZZ indicator, and simply want to buy at a red dot, and sell at the blue dot. However, the following is not working. How can I generate appropriate buy/sell signals. Using the following code, but don't get signals at the correct spots.
int start()
{
//----
string UpName,DownName;int UpCounter,DownCounter;
for(int i=Bars;i>0;i--)
{
if(DailySignal()==1)
{
//Print("Long Triggered at Month : ",Month(), " and Day : ",Day()," & Daily Signal = ",DailySignal());
UpName="UP"+i;//UpCounter;
GoLong=true;GoShort=false;
ObjectCreate(UpName, OBJ_ARROW, 0, Time[0], Open[0]+20*Point); //draw an up arrow
ObjectSet(UpName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(UpName, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet(UpName, OBJPROP_COLOR, White);
}
if(DailySignal()==-1)
{
//Print("Short Triggered at Month : ",Month(), " and Day : ",Day()," & Daily Signal = ",DailySignal());
DownName="Down"+i;//DownCounter;
GoLong=false;GoShort=true;
ObjectCreate(DownName, OBJ_ARROW, 0, Time[0], Open[0]+20*Point); //draw an up arrow
ObjectSet(DownName, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(DownName, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
ObjectSet(DownName, OBJPROP_COLOR, Red);
}
return(0);
}
//----
return(0);
}
int DailySignal()
{
double swingzz_up = iCustom(NULL, 0, "Swing_ZZ",1,1,0);
double swingzz_down = iCustom(NULL, 0, "Swing_ZZ",1,2,0);
double swingzz_buffer = iCustom(NULL, 0, "Swing_ZZ",1,0,0);
if (swingzz_down != 0)
{
return(1);
}
if (swingzz_up != 0)//2147483647)
{
return(-1);
}
return(0);
}