View Single Post
  #2 (permalink)  
Old 12-22-2005, 09:38 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow

Quote:
Originally Posted by trevman2005
this bit of code doesnt seem to buy, any ideas why?
Code:
   if(Close[2]<ma && Close[1]>ma)
   {
    OrderSend(Symbol(),OP_BUY,lots,Ask,3,stop,Ask+profit,"",2005,0,Green);
   }
it should buy when a new candle closes above the moving average and the previous closed below it.
I think it should be:

PHP Code:
 if(Close[1]<ma && Close[0]>ma)
  {
   
ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,3,stop*Point,Ask+profit*Point,"",2005,0,Green);
   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);

__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Reply With Quote