[¡Archivo!] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no lo dejéis pasar. No podría ir a ningún sitio sin ti - 2. - página 366

 
abolk:

tienes

pero tienes que (comparación)


Tome el código de cualquier indicador OEM y vea cómo está formateado el código

No veo ninguna diferencia. por ejemplo, es una disciplina estándar. es sólo la complejidad que lo hace. sin embargo, además del propio paréntesis puede ser una cuestión de ";" por ejemplo...

//+------------------------------------------------------------------+
//|                                                       Discipline |
//|                 Copyright © 1999-2008, MetaQuotes Software Corp. |
//|                                                         FX_FISH  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Kiko Segui"
#property link      "webtecnic@terra.es"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//----
double buffer1[];
double buffer2[];
//----
extern int period=10;
extern int price=0; // 0 or other = (H+L)/2
                    // 1 = Open
                    // 2 = Close
                    // 3 = High
                    // 4 = Low
                    // 5 = (H+L+C)/3
                    // 6 = (O+C+H+L)/4
                    // 7 = (O+C)/2
extern bool Mode_Fast=false;
extern bool Signals  =true;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Lime);
   SetIndexBuffer(0,buffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Red);
   SetIndexBuffer(1,buffer2);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   int i;
   double tmp;
//----
   for(i=0;i<Bars;i++)
     {
      ObjectDelete("Sel"+DoubleToStr(i,0));
      ObjectDelete("Buy"+DoubleToStr(i,0));
      ObjectDelete("Exit"+DoubleToStr(i,0));
     }
   return(0);
  }
double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;
int buy=0,sell=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i;
   int barras;
   double _price;
   double tmp;
   double MinL=0;
   double MaxH=0;
   double Threshold=1.2;
//----
   barras=Bars;
   if(Mode_Fast) barras=100;
   i=barras-period-1;
   while(i>=0)
     {
      MaxH=High[Highest(NULL,0,MODE_HIGH,period,i)];
      MinL= Low[ Lowest(NULL,0,MODE_LOW, period,i)];
      switch(price)
        {
         case 0:  _price=(High[i]+Low[i])/2;                   break;
         case 1:  _price= Open[i];                             break;
         case 2:  _price= Close[i];                            break;
         case 3:  _price= High[i];                             break;
         case 4:  _price= Low[i];                              break;
         case 5:  _price=(High[i]+Low[i]+Close[i])/3;          break;
         case 6:  _price=(Open[i]+High[i]+Low[i]+Close[i])/4;  break;
         case 7:  _price=(Open[i]+Close[i])/2;                 break;
         default: _price=(High[i]+Low[i])/2;                   break;
        }
      Value=0.33*2*((_price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;
      Value=MathMin(MathMax(Value,-0.999),0.999);
      Fish =0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
      buffer1[i]=0;
      buffer2[i]=0;
//----
      if((Fish<0) && (Fish1>0))
        {
         if(Signals)
           {
            ObjectCreate("Exit"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],_price);
            ObjectSet("Exit"+DoubleToStr(i,0),OBJPROP_ARROWCODE,251);
            ObjectSet("Exit"+DoubleToStr(i,0),OBJPROP_COLOR,Red);
           }
         buy=0;
        }
      if((Fish>0) && (Fish1<0))
        {
         if(Signals)
           {
            ObjectCreate("Exit"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],_price);
            ObjectSet("Exit"+DoubleToStr(i,0),OBJPROP_ARROWCODE,251);
            ObjectSet("Exit"+DoubleToStr(i,0),OBJPROP_COLOR,Red);
           }
         sell=0;
        }
      if(Fish>=0)
      { buffer1[i]=Fish; }
      else
      { buffer2[i]=Fish; }
      tmp=i;
      if((Fish<-Threshold) && (Fish>Fish1) && (Fish1<=Fish2))
        {
         if (Signals)
           {
            ObjectCreate("Sel"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],High[i]+5*Point);
            ObjectSet("Sel"+DoubleToStr(i,0),OBJPROP_ARROWCODE,226);
            ObjectSet("Sel"+DoubleToStr(i,0),OBJPROP_COLOR,Red);
           }
         sell=1;
        }
      if((Fish>Threshold) && (Fish<Fish1) && (Fish1>=Fish2))
        {
         if (Signals)
           {
            ObjectCreate("Buy"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],Low[i]-5*Point);
            ObjectSet("Buy"+DoubleToStr(i,0),OBJPROP_ARROWCODE,225);
            ObjectSet("Buy"+DoubleToStr(i,0),OBJPROP_COLOR,Aqua);
           }
         buy=1;
        }
      Value1=Value;
      Fish2=Fish1;
      Fish1=Fish;
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+
 
KONDOR:
preste más atención a los paréntesis ))))
Símbolo()

¿Se refiere a esto, por ejemplo?

if(OrderSymbol()==Symbol())

Lo arreglé. El error se mantuvo.

 

¿también es si? ¿o qué?

Lo volveré a hacer entonces...

debería ser así: if(OrderSymbol()==Symbol() ??

todos los símbolos están definidos.

eliminado el paréntesis - nada ha cambiado.

 
KONDOR:
el penúltimo paréntesis es innecesario
todo lo mismo =(
 
frxmax:

¿dónde está el error a, en términos de paréntesis todo parece ser recto?


//+------------------------------------------------------------------+
//|                                                        Beta2.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
extern int       StopLoss=100;
extern int       TakeProfit=20;
extern double    Lot=0.01;
extern int       cnt, ticket, total;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
      double LoCurent=iCustom(NULL, 0, "LO",0,0);
      double LoPrevious=iCustom(NULL, 0, "LO",1,1);
      double FtCurent=iCustom(NULL, 0, "FT",0,0);
      double FtPrevious=iCustom(NULL, 0, "FT",1,1);
//----
   if (total==0)
      {
         if (LoCurent>LoPrevious && FtCurent>FtPrevious)
            {
               ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid-StopLoss*Point,Bid+TakeProfit*Point,"Buy",1111,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); 
            }else 
            if(LoCurent<LoPrevious && FtCurent<FtPrevious)
               {
                  ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Ask+StopLoss*Point,Ask-TakeProfit*Point,"Sell",2222,0,Red);
                  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); 
               }    
             return(0);
      }
      else 
      if(LoCurent<LoPrevious || FtCurent<FtPrevious || LoCurent<-30 || LoPrevious<-30)
         {
            if(OrderSelect(ticket,SELECT_BY_POS,MODE_TRADES)==false) //break;
               {
                  if(OrderSymbol()==Symbol())
                   {
                      if(OrderType()==OP_SELL)
                         {
                         OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                         }
                     return(0);
                   }
               }
         }
         else
            if (LoCurent>LoPrevious || FtCurent>FtPrevious || LoCurent>30 || LoPrevious>30)
               {
                  if(OrderSelect(ticket,SELECT_BY_POS,MODE_TRADES)==false) //break;
                     {
                        if(OrderSymbol()==Symbol())
                           {
                              if(OrderType()==OP_SELL)
                                 {
                                    OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
                                 }
                               return(0);
                           }
                     }
               }
           //}
return(0);
      }
//+------------------------------------------------------------------+
 
frxmax:
sin errores.
 else 
      if(LoCurent<LoPrevious || FtCurent<FtPrevious || LoCurent<-30 || LoPrevious<-30)
         {
            if(OrderSelect(ticket,SELECT_BY_POS,MODE_TRADES)) //break ругается

               {
                  if(OrderSymbol()==Symbol())
                   {
                      if(OrderType()==OP_SELL)
                         {
                         OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                         }
                     return(0);
                   }
               }
         }
         else
            if (LoCurent>LoPrevious || FtCurent>FtPrevious || LoCurent>30 || LoPrevious>30)
               {
                  if(OrderSelect(ticket,SELECT_BY_POS,MODE_TRADES)) //break ругается
                     {
                        if(OrderSymbol()==Symbol())
                           {
                              if(OrderType()==OP_SELL)
                                 {
                                    OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
                                 }
                               return(0);
                           }
                     }
               }
      
return(0);
      }
 
Muchas gracias por su ayuda. KONDOR
 

El único problema es que los resultados no son tan buenos.

Ayúdame a entender cómo hacer que se abra sólo una orden en la dirección de la señal recibida previamente. cerrarla cuando uno de los indicadores mostrará una señal inversa. y todo teniendo en cuenta el par de divisas

 
comprueba la función NumberOfBarOpenLastPos(), comprueba el número de barra en la que la orden está abierta
 

Prefiero tenerlo así: (por ejemplo, en el gráfico del eurodólar, hay una señal de compra)

si el total>1

si el par de divisas = eurodólar

si la orden es de Venta

cerrar el pedido

abrir una orden de compra


La vista general debería ser así

si (señal de compra)

si total==0

comprar

en caso contrario (total >1)

comprobar en qué par de divisas se abren las operaciones

si nuestro

si está en venta

cerrarlo y volver a comprar

o bien (total = 0, abrir una compra) ....

Razón de la queja: