[ARCHIVO] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen de largo. En ninguna parte sin ti - 3. - página 420

 

Hola.

He creado el siguiente bucle:

for(j=0;j<ArraySize(fiboOrd);j++)
 {
  if(fiboOrd[j]==d && TP==0) TP=NormalizeDouble(Asia*fibo[j],Digits);
  if(fiboOrd[j]==d && TP>0)  Price=NormalizeDouble(Asia*fibo[j],Digits);
 }

El problema es el siguiente: el valor de la variable TP por alguna razón sólo se encuentra para el primer valor de j , mientras que el valor de la variable Precio se encuentra para todos los valores de j .

¿Cómo puedo obtener todos los valores de TP para todos los valores de j? ¿Cuál es mi error?

Gracias de antemano.

 
nemo811:

¿Cómo puedo encontrar todos los valores de TP para todos los valores de j? ¿Cuál es mi error?

No tengo que responder a la pregunta, lo he averiguado por mi cuenta.

 
frixer:
Hola, podrías decirme por favor cómo encontrar el mínimo y el máximo de la última vela por ejemplo


¿Es el último el que aún no se ha formado del todo?

Low_0=Low[0];                                // Low_0 присвоена мин. цена 0-го бара
High_0=High[0];                              // High_0 присвоена макс. цена 0-го бара
 

Por favor, dígame por qué el Asesor Experto no puede abrir operaciones en el comercio real, aunque en el Probador de Estrategias abre todo normalmente? Y no hay errores en el registro. El servidor de demostración de Alpari.

 
sss2019:

Por favor, dígame por qué el Asesor Experto no puede abrir operaciones en el comercio real, aunque en el Probador de Estrategias abre todo normalmente? Y no hay errores en el registro. El servidor de demostración de Alpari.


es difícil de decir - hay muchas variantes.... ¿algún otro detalle que pueda darme?
 
elmucon:

es difícil de decir - hay muchas opciones.... me gustaría saber más detalles.


No sé, todo parece estar bien, todo funciona como un reloj en el tester, pero en la cuenta demo ya ha llegado la hora, pero no se ha abierto ninguna operación y durante la siguiente hora también. Tal vez deberías mirar el código.

//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| extern variables                                                 |
//+------------------------------------------------------------------+

extern int GMT = 2;
extern int InTime = 23;
extern int OrderDuration = 2;
extern double Lot = 0.1;
extern string MyComment = "Return";
extern int Slippage = 3;
extern int StopLoss = 150;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  int CurrentHour = TimeHour(TimeCurrent());
  int CurrentMinute = TimeMinute(TimeCurrent());
  datetime OrderExpiriation = TimeCurrent() + 3600 * OrderDuration;
  
  double MyPoint = Point;
  if(Digits == 3 || Digits == 5)
    {
    MyPoint = Point * 10;
    }
//----
   if(TimeHour(TimeCurrent()) + GMT == InTime && TimeMinute(TimeCurrent()) == 0 && OrdersTotal() == 0)
     {
//---- Sending first order - Buy
     if(OrderSend(Symbol(),OP_BUYLIMIT,Lot,Open[0] - 10 * MyPoint,Slippage,Open[0] - StopLoss * MyPoint,Open[0],MyComment,16523,OrderExpiriation,Green) > 0)
       {
       Alert("Первый ордер запущен");
       }else
       {
       Alert("Первый ордер не запущен");
       }
//---- Sending second order Buy
     if(OrderSend(Symbol(),OP_BUYLIMIT,Lot,Open[0] - 15 * MyPoint,Slippage,Open[0] - StopLoss * MyPoint,Open[0],MyComment,16523,OrderExpiriation,Green) > 0)
       {
       Alert("Второй ордер запущен");
       }else
       {
       Alert("Второй ордер не летит");
       }
//---- Sending third order - Sell
     if(OrderSend(Symbol(),OP_SELLLIMIT,Lot,Open[0] + 10 * MyPoint,Slippage,Open[0] + StopLoss * MyPoint,Open[0],MyComment,16523,OrderExpiriation,Red) > 0)
       {
       Alert("Третий ордер отжахан");
       }else
       {
       Alert("Третий ордер не отжахан");
       }
//---- Sending fourth order - Sell
     if(OrderSend(Symbol(),OP_SELLLIMIT,Lot,Open[0] + 15 * MyPoint,Slippage,Open[0] + StopLoss * MyPoint,Open[0],MyComment,16523,OrderExpiriation,Red) > 0)
       {
       Alert("Четвертый ордер запущен");
       }else
       {
       Alert("Четвертый ордер не запущен");
       }

     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Ni en el registro ni en ningún otro sitio hay ningún error. Si no hay errores en el código (bueno, tal vez haya algún fallo en el terminal), entonces es más probable que me haya equivocado con la sincronización.
 
El periodo de rsi nunca se ha cambiado.
 
kolyango:


¿El último es el que aún no se ha formado del todo?

Gracias, eso es útil, pero aún me queda una duda, pero intentaré resolverla por mi cuenta.
 

¡Si no tiene ningún problema, no puedo encontrar un buen programador, he escrito un EA con TS simple, pero no funciona correctamente!

Por lo tanto, mira la imagen, la orden de apertura en la intersección de 2 MAs, rápido cruza una MA lento de abajo hacia arriba - comprar y viceversa, el asesor no tiene idea de cómo abrir órdenes, un ejemplo revelador en la imagen:

1 - comprar el 03.11.2011, sin cruzar cerca;

3 - vender el 04.11.2011, lo mismo;

5 - comprar el 07.11.2011; no está claro por qué se abre esta orden.

También he visto el propio código:

extern int period_EMA = 85,
period_WMA = 5,
period_RSI = 14,
stoploss = 0,
takeprofit = 500,
risk = 10,
Magic = 777;
extern bool CloseCounter = false;
extern double Lot = 0.1;
extern int TrailingStop = 70; //если= 0, то трейлинг по фракталам или свечам
extern int Tip.Fr.or.Candl = 1; //если= 0, то трейлинг по фракталам 
//если= 1, то трейлинг по свечам
//--------------------------------------------------------------------
double SL,TP,LOT;
int TimeBar;
//--------------------------------------------------------------------
int start()
{
if (TimeBar==Time[0]) return(0);
double EMA0 = iMA(NULL,0,period_EMA,0,MODE_EMA, PRICE_OPEN,0);
double WMA0 = iMA(NULL,0,period_WMA,0,MODE_LWMA,PRICE_OPEN,0);
double EMA1 = iMA(NULL,0,period_EMA,0,MODE_EMA, PRICE_OPEN,1);
double WMA1 = iMA(NULL,0,period_WMA,0,MODE_LWMA,PRICE_OPEN,1);
double RSI = iRSI(NULL,0,period_RSI,PRICE_OPEN,0);
if (EMA0 < WMA0 && EMA1 > WMA1 && RSI > 50)
{
TimeBar=Time[0]; 
if (takeprofit!=0) TP = Ask + takeprofit*Point;
if (stoploss!=0) SL = Ask - stoploss* Point; 
LOT = LOT(risk,1);
if (CloseCounter) CLOSEORDER("Sell");
OPENORDER ("Buy");
}
if (EMA0 > WMA0 && EMA1 < WMA1 && RSI < 50)
{
TimeBar=Time[0]; 
if (takeprofit!=0) TP = Bid - takeprofit*Point;
if (stoploss!=0) SL = Bid + stoploss* Point; 
LOT = LOT(risk,1);
if (CloseCounter) CLOSEORDER("Buy");
OPENORDER ("Sell");
}
TrailingStop();
return(0);
}
//--------------------------------------------------------------------
void CLOSEORDER(string ord)
{
for (int i=0; i<OrdersTotal(); i++)
{ 
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol()!=Symbol()||Magic!=OrderMagicNumber()) continue;
if (OrderType()==OP_BUY && ord=="Buy")
OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
if (OrderType()==OP_SELL && ord=="Sell")
OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
} 
}
}
//--------------------------------------------------------------------
void OPENORDER(string ord)
{
int error;
if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, LOT,Ask,2,SL,TP,"EMA WMA RSI",Magic,3);
if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,LOT,Bid,2,SL,TP,"EMA WMA RSI",Magic,3);
if (error==-1) ShowERROR(error,0,0);
return;
} 
//--------------------------------------------------------------------
void ShowERROR(int Ticket,double SL,double TP)
{
int err=GetLastError();
switch ( err )
{ 
case 1: return;
case 2: Alert("Нет связи с торговым сервером " ,Ticket," ",Symbol());return;
case 130: Alert("Error близкие стопы Ticket ", Ticket," ",Symbol());return;
case 134: Alert("Недостаточно денег ", Ticket," ",Symbol());return;
case 146: Alert("Error Подсистема торговли занята ", Ticket," ",Symbol());return;
case 129: Alert("Error Неправильная цена ", Ticket," ",Symbol());return;
case 131: Alert("Error Неправильный объем ", Ticket," ",Symbol());return;
default: Alert("Error ",err," Ticket ", Ticket," ",Symbol());return;
}
}
//--------------------------------------------------------------------
double LOT(int risk,int ord)
{
if (Lot!=0) return(Lot);
double MINLOT = MarketInfo(Symbol(),MODE_MINLOT);
LOT = AccountFreeMargin()*risk/100/MarketInfo(Symbol(),MODE_MARGINREQUIRED)/ord;
if (LOT>MarketInfo(Symbol(),MODE_MAXLOT)) LOT = MarketInfo(Symbol(),MODE_MAXLOT);
if (LOT<MINLOT) LOT = MINLOT;
if (MINLOT<0.1) LOT = NormalizeDouble(LOT,2); else LOT = NormalizeDouble(LOT,1);
return(LOT);
}
//--------------------------------------------------------------------
void TrailingStop()
{
int tip,Ticket;
bool error;
double StLo,OSL,OOP;
for (int i=0; i<OrdersTotal(); i++) 
{ if (OrderSelect(i, SELECT_BY_POS)==true)
{ tip = OrderType();
if (tip<2 && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
OSL = OrderStopLoss();
OOP = OrderOpenPrice();
Ticket = OrderTicket();
if (tip==OP_BUY) 
{
StLo = SlLastBar(1,Bid,Tip.Fr.or.Candl,TrailingStop); 
if (StLo <= OOP) continue;
if (StLo > OSL)
{ error=OrderModify(Ticket,OOP,NormalizeDouble(StLo,Digits),
OrderTakeProfit(),0,White);
Comment("TrailingStop ",Ticket," ",TimeToStr(TimeCurrent(),TIME_MINUTES));
Sleep(500);
if (!error) Comment("Error order ",Ticket," TrailingStop ",
GetLastError()," ",Symbol()," SL ",StLo);
}
} 
if (tip==OP_SELL) 
{
StLo = SlLastBar(-1,Ask,Tip.Fr.or.Candl,TrailingStop); 
if (StLo==0) continue; 
if (StLo >= OOP) continue;
if (StLo < OSL || OSL==0 )
{ error=OrderModify(Ticket,OOP,NormalizeDouble(StLo,Digits),
OrderTakeProfit(),0,White);
Comment("TrailingStop "+Ticket," ",TimeToStr(TimeCurrent(),TIME_MINUTES));
Sleep(500);
if (!error) Comment("Error order ",Ticket," TrailingStop ",
GetLastError()," ",Symbol()," SL ",StLo);
}
} 
}
}
}
}
//--------------------------------------------------------------------
double SlLastBar(int tip,double price, int tipFr, int tral)
{
double fr;
int jj,ii,delta=5;
if (tral!=0)
{
if (tip==1) fr = Bid - tral*Point; 
else fr = Ask + tral*Point; 
}
else
{
if (tipFr==0)
{
if (tip== 1)
for (ii=1; ii<100; ii++) 
{
fr = iFractals(NULL,0,MODE_LOWER,ii);
if (fr!=0) if (price-delta*Point > fr) break;
else fr=0;
}
if (tip==-1)
for (jj=1; jj<100; jj++) 
{
fr = iFractals(NULL,0,MODE_UPPER,jj);
if (fr!=0) if (price+delta*Point < fr) break;
else fr=0;
}
}
else
{
if (tip== 1)
for (ii=1; ii<100; ii++) 
{
fr = iLow(NULL,0,ii);
if (fr!=0) if (price-delta*Point > fr) break;
else fr=0;
}
if (tip==-1)
for (jj=1; jj<100; jj++) 
{
fr = iHigh(NULL,0,jj);
if (price+delta*Point < fr) break;
else fr=0;
}
}
}
/* if (tip== 1)
{
ObjectDelete("SL Buy");
ObjectDelete("SL-");
ObjectCreate("SL Buy",OBJ_ARROW,0,TIME,fr,0,0,0,0); 
ObjectSet ("SL Buy",OBJPROP_ARROWCODE,6);
ObjectSet ("SL Buy",OBJPROP_COLOR, Blue);
ObjectCreate("SL-",OBJ_ARROW,0,TIME,price-delta*POINT,0,0,0,0); 
ObjectSet ("SL-",OBJPROP_ARROWCODE,4);
ObjectSet ("SL-",OBJPROP_COLOR, Blue);
}
if (tip==-1)
{
ObjectDelete("SL Sell");
ObjectDelete("SL+");
ObjectCreate("SL Sell",OBJ_ARROW,0,TIME,fr,0,0,0,0);
ObjectSet ("SL Sell",OBJPROP_ARROWCODE,6);
ObjectSet ("SL Sell", OBJPROP_COLOR, Green);
ObjectCreate("SL+",OBJ_ARROW,0,TIME,price+delta*POINT,0,0,0,0); 
ObjectSet ("SL+",OBJPROP_ARROWCODE,4);
ObjectSet ("SL+",OBJPROP_COLOR, Green);
}*/
return(fr);
}
//--------------------------------------------------------------------



Muchas gracias de antemano.

 

Buenas tardes, por favor, indíqueme qué significa el error "2011.12.10 12:46:26 TestGenerator: unmatched data error (volume limit 2225 at 2011.11.29 11:00 is exceeded)" y cómo se puede corregir....