why these codes dont work in my ea ?

 

i created a new ea base on some strategy from tsd, im sure this is the simplest and easiest codes but i just cant figure out where is wrong, any help would be appreciate

rules :

buy when there are 3 complete 15 minutes bars close down and sell when 3 are close up

int start()
  {
  int gs, gs2, trade,vla;
  gs = 0;
double high1 = iHigh(Symbol(), PERIOD_M15,1);
double low1 = iLow(Symbol(),PERIOD_M15,1);
double open1 = iOpen(Symbol(),PERIOD_M15,1);
double close1 = iClose(Symbol(),PERIOD_M15,1);
double low2 = iLow(Symbol(),PERIOD_M15,12);
double high2 = iHigh(Symbol(),PERIOD_M15,2);
double open2 = iOpen(Symbol(),PERIOD_M15,2);
double close2 = iClose(Symbol(),PERIOD_M15,2);
double high3 = iHigh(Symbol(), PERIOD_M15,3);
double low3 = iLow(Symbol(),PERIOD_M15,3);
double open3 = iOpen(Symbol(),PERIOD_M15,3);
double close3 = iClose(Symbol(),PERIOD_M15,3);

if ((high1 -low1) > 4*Point) gs = 1;
if ((high2- low2) > 4*Point) gs = 2;

for (int i =0; i<2;i++)
{
double aclose = iClose(Symbol(),PERIOD_M15,i);
double aopen = iOpen(Symbol(),PERIOD_M15,i);
   if (aclose < aopen) vla = 1;
  return(0);
  }
  int range, ticket,cnt;
//double open1 = iOpen(Symbol(),PERIOD_M15,1);
//double close1 = iClose(Symbol(),PERIOD_M15,1);
//if (close1 > open1) range = 1; //bar was close up
//if (close1 < open1) range = 2; // bar was close down
// rule
if (gs ==1 && gs==2 && vla == 1)
   {
   RefreshRates();
      ticket = OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0);
         if (ticket > 0)
            {
            if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
            }
            else Print("Error opening BUY order : ",GetLastError()); 
         
   return(0);        
      }
return(0);
}
 
Is this correct -
double low2 = iLow(Symbol(),PERIOD_M15,12);

 

This

for (int i =0; i<2;i++)
{
double aclose = iClose(Symbol(),PERIOD_M15,i);
double aopen = iOpen(Symbol(),PERIOD_M15,i);
   if (aclose < aopen) vla = 1;
  return(0);
  }

is not understandable.

This

if (gs ==1 && gs==2 && vla == 1)

as well.

 

sorry about the coding, i tryed many different ways just try to get the right resurlts but it still doesnt make a single trade, so all the codes above are what i tryed before i make this post, i change some to commands so i dont confuse together

if (gs ==1 && gs==2 && vla == 1)
the gs is used to check the previous bar range, if bar1 moved from top to bottom over 4 pips then its set to 1, the 2nd bar is set to 2, vla is from the for loop if previous 3 bars close below open set to 1, i also try to manaual type in all the iopen, iclose to compare but it just dont work

 
I ment your variable gs couldn't be equal 1 and 2 simultaneously
 

roger, thank you for the help, now everything seems runing fine, i didnt know that i cant set gs stimultaneously, i used use functions then return gs, i hope this will work.

 

DD

Did you mean either.. or..

if ((gs==1 || gs==2) && vla==1)
-BB-