How to generate buy/sell signals

 

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);
}