# using iFractals to decide buy or sell

767

I have tried the following code logic. But I guess it is not the right one.

```   double UP[],DOWN[];
double fractal_output = iFractals(_Symbol,_Period);
ArraySetAsSeries(UP,true);
ArraySetAsSeries(DOWN,true);
CopyBuffer(fractal_output,0,0,5,UP);
CopyBuffer(fractal_output,1,0,5,DOWN);
if (UP[1])
{
}
if (DOWN[1])
{
Comment("SELL");
}```
I am getting the buy and sell simultaneously. Kindly, suggest me what I can do to improve my decision based on Fractals.
Moderator
7070

Your if() is false! UP and DOWN are double that are casted into a logical values: 0 or 1!

Check correctly the values of UP[] and DOWN[]!

767

Carl Schreiber:

Your if() is false! UP and DOWN are double that are casted into a logical values: 0 or 1!

Check correctly the values of UP[] and DOWN[]!

```void OnTick()
{
double UP[],DOWN[];
double fractal_output = iFractals(_Symbol,_Period);
ArraySetAsSeries(UP,true);
ArraySetAsSeries(DOWN,true);
CopyBuffer(fractal_output,0,0,5,UP);
CopyBuffer(fractal_output,1,0,5,DOWN);

printf("UP0 ==> " + DoubleToString(UP[0]));
printf("\nDOWN0 ==> " + DoubleToString(DOWN[0]));
printf("\nUP1 ==> " + DoubleToString(UP[1]));
printf("\nDOWN1 ==> " + DoubleToString(DOWN[1]));
if (UP[0]>DOWN[0])
{
Comment("SELL");
}
else{

}
if (UP[1]>DOWN[1])
{
Comment("SELL");