//+------------------------------------------------------------------+ //| GBPUSDADR14.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" int barant = 999999999; int Lote = 1; int ticket = 0; int media14 = 0; double soma14 = 0; int aberturaVenda; int aberturaCompra; bool isComprou; bool isVendeu; int sl100 = 15; int tp100 = 30; int sl175 = 20; int tp175 = 40; int sl200 = 25; int tp200 = 50; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(barant != Bars){ for(int i = 1; i<=14; i++){ soma14 += High[i] - Low[i]; } media14 = (soma14/14)/Point; Print("Media dos 14 dias é: "+media14); } soma14 = 0; barant = Bars; if(Hour() == 17 && Minute() == 0){ for(int j=0; j= 100 && media14 < 175){ aberturaVenda = (Low[1]/Point) - (Bid/Point); aberturaCompra = (High[1]/Point) - (Ask/Point); if(aberturaCompra == 0 && !isComprou){ ticket=OrderSend(Symbol(),OP_BUY, Lote,Ask, 3,Ask - sl100*Point,Ask + tp100*Point,"Comprando GBP",0,0,Red); if(ticket<0) Print("OrderSend failed with error #",GetLastError()); isComprou = true; return(0); } if(aberturaVenda == 0 && !isVendeu){ ticket=OrderSend(Symbol(),OP_SELL, Lote,Bid, 3,Bid + sl100*Point,Bid - tp100*Point,"Vendendo GBP",0,0,Red); if(ticket<0) Print("OrderSend failed with error #",GetLastError()); isVendeu = true; return(0); } } if(media14 >= 175 && media14 <= 199){ aberturaVenda = (Low[1]/Point) - (Bid/Point); aberturaCompra = (High[1]/Point) - (Ask/Point); if(aberturaCompra == 0 && !isComprou){ ticket=OrderSend(Symbol(),OP_BUY, Lote,Ask, 3,Ask - sl175*Point,Ask + tp175*Point,"Comprando GBP",0,0,Red); if(ticket<0) Print("OrderSend failed with error #",GetLastError()); isComprou = true; return(0); } if(aberturaVenda == 0 && !isVendeu){ ticket=OrderSend(Symbol(),OP_SELL, Lote,Bid, 3,Bid + sl175*Point,Bid - tp175*Point,"Vendendo GBP",0,0,Red); if(ticket<0) Print("OrderSend failed with error #",GetLastError()); isVendeu = true; return(0); } } if(media14 >= 200){ aberturaVenda = (Low[1]/Point) - (Bid/Point); aberturaCompra = (High[1]/Point) - (Ask/Point); if(aberturaCompra == 0 && !isComprou){ ticket=OrderSend(Symbol(),OP_BUY, Lote,Ask, 3,Ask - sl200*Point,Ask + tp200*Point,"Comprando GBP",0,0,Red); if(ticket<0) Print("OrderSend failed with error #",GetLastError()); isComprou = true; return(0); } if(aberturaVenda == 0 && !isVendeu){ ticket=OrderSend(Symbol(),OP_SELL, Lote,Bid, 3,Bid + sl200*Point,Bid - tp200*Point,"Vendendo GBP",0,0,Red); if(ticket<0) Print("OrderSend failed with error #",GetLastError()); isVendeu = true; return(0); } } return(0); } //+------------------------------------------------------------------+