por Bellagio » 27 Jun 2012, 10:35  
			
			En principio me sale un erro de final de programa no se porque lo {} esta bien contados, la idea es que no me compre si el precio esta por encima del precio=0 y no me venda si el precio esta por debajo del precio=0, precio=0 la suma de precio de la operativas / numero de operativas. - Código: Seleccionar todo
 #define SIGNAL_NONE 0 #define SIGNAL_BUY   1 #define SIGNAL_SELL  2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4
  extern int MagicNumber = 2; extern double Lots = 0.1; extern int Slippage = 3; extern bool UseTrailingStop = False; extern int TrailingStop = 50; extern int Compra = -30; extern int Venda = 45;
  double PriceSell; double PriceBuy; int BarCount, Current, countbuy, countsell, openbuy, opensell, pricebuy, pricesell, pips2dbl, pips2point, pipValue; bool TickCheck = False; bool IsTradedOnThisBar; //only 1 trade for bar
 
  int init() {        if (Digits == 5 || Digits == 3)    // Adjust for five (5) digit brokers.    {                   pips2dbl = Point*10; pips2point = 10;pipValue = (MarketInfo(Symbol(),MODE_TICKVALUE))*10;    }     else     {           pips2dbl = Point;   pips2point = 1;pipValue = (MarketInfo(Symbol(),MODE_TICKVALUE))*1;    }    
     return(0); }
  int deinit() {    return(0); }
  int start()  {    int Order = SIGNAL_NONE;    int Total;     int Ticket;    double StopLossLevel = 0, TakeProfitLevel = 0;
     Total = OrdersTotal();    Order = SIGNAL_NONE;        openbuy = OpenedBuy();    opensell =  OpenedSell();    pricebuy = PriceBuy();    pricesell = PriceSell();    DoubleToStr(pricebuy,5);    DoubleToStr(pricesell,5);
 
      double Buy2_1 = iCustom(Symbol(), PERIOD_M1, "JVC", 20,9,0.5,-0.5,100, 0, Current + 0);     double Buy2_2 = Compra;
      double Sell2_1 = iCustom(Symbol(), PERIOD_M1, "JVC", 20,9,0.5,-0.5,100, 0, Current + 0);     double Sell2_2 = Venda;
     if (Buy2_1 < Buy2_2) Order = SIGNAL_BUY;
     if (Sell2_1 > Sell2_2) Order = SIGNAL_SELL;
     if (Order == SIGNAL_BUY && ((pricebuy/openbuy)>Ask) && IsTradedOnThisBar!=Bars)     {          {          Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);          IsTradedOnThisBar = Bars;}          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);       }
     if (Order == SIGNAL_SELL && ((pricesell/opensell<Bid) && IsTradedOnThisBar!=Bars)     {          {          Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);          IsTradedOnThisBar = Bars;          }          if(Ticket > 0)           {             if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES))             {             Print("SELL order opened : ", OrderOpenPrice());                              }              else              {             Print("Error opening SELL order : ", GetLastError());             }          }
        return(0);           }     }     double PriceBuy()    {        int total  = OrdersTotal();        double pricebuy = 0;          for (int cnt = total-1 ; cnt >=0 ; cnt--)          {                                               OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);                          if(OrderSymbol()==Symbol() && (OrderType()==OP_BUY))                               pricebuy+=OrderOpenPrice();                                     }          return (pricebuy); } double PriceSell() {       int total  = OrdersTotal();       double pricesell = 0;         for (int cnt = total-1 ; cnt >=0 ; cnt--)          {                                              OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
              if(OrderSymbol()==Symbol() && (OrderType()==OP_SELL))                             pricesell+=OrderOpenPrice();                                 }          return (pricesell); }   int OpenedBuy() {      int total  = OrdersTotal();      int countbuy = 0;          for (int cnt = total-1 ; cnt >=0 ; cnt--)          {             OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);                 if(OrderSymbol()==Symbol()&& OrderType()==OP_BUY)                                countbuy++;                     }          return (countbuy); } int OpenedSell() {        int total  = OrdersTotal();        int countsell = 0;          for (int cnt = total-1 ; cnt >=0 ; cnt--)          {            OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);                       if(OrderSymbol()==Symbol() && (OrderType()==OP_SELL))                               countsell++;                                              }          return (countsell);
  }
 
  
			
		 
		
			
			- 
				Bellagio
			
 
			
		-  
 
		- Mensajes: 2
 - Registrado: 01 Jun 2012, 11:43
 
				- Karma: 0
 
			
		 
	
		
		 
	 
	 
	
		
		
			
				
			
			
			 por elolima » 27 Jun 2012, 16:20  
			
			Hola Creo que el problema esta aquí .... Saludos
   if (Order == SIGNAL_BUY && ((pricebuy/openbuy)>Ask) && IsTradedOnThisBar!=Bars)     {-----------------------------------?????????????????????????????????????           { -----------------------------------?????????????????????????????????????          Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);          IsTradedOnThisBar = Bars;} -----------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ERROR! .....
  if (Order == SIGNAL_SELL && ((pricesell/opensell<Bid) && IsTradedOnThisBar!=Bars)  -----------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Falta Paréntesis ")"  
			
		 
		
			
			- 
				elolima
			
 
			
		-  
 
		- Mensajes: 47
 - Registrado: 13 May 2012, 10:10
 
				- Karma: 0
 
			
		 
	
		
		 
	 
	 
	
	 
 | 
	
 |