Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen de largo. En ninguna parte sin ti - 6. - página 554

 
Vinin:


¡Muchas gracias!
 

splxgf: - ¡Muchas gracias! Todo funciona como un reloj.

Aquí está el código de equilibrio de Igor Kim, convertido "splxgf:" en lugar de puntos a porcentajes:

//+----------------------------------------------------------------------------+
//| Autor : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Versión : 23.04.2009 |
//| Descripción : Mover el nivel de parada a sin pérdidas |
//+----------------------------------------------------------------------------+
//| Parámetros: |
//| sy - nombre del instrumento ( "" - cualquier símbolo, |
//| NULL - símbolo actual) |
//| op - operación ( -1 - cualquier posición) |
//| mn - MagicNumber ( -1 - cualquier mago) |
//+----------------------------------------------------------------------------+
void MovingInWL(string sy=NULL, int op=-1, int mn=-1) {

double po, pp, PercentStep,MoveStoplossLevel,StoplossLevel;
int i, k=OrdersTotal();

if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
si ((OrderSymbol()==sy || sy==") && (op<0 || OrderType()==op)) {
if (mn<0 || OrderMagicNumber()==mn) {

po=MarketInfo(OrderSymbol(), MODE_POINT);

if (OrderType()==OP_BUY) {
PercentStep=(OrderTakeProfit()-OrderOpenPrice())/po/(138-23);
MoveStoplossLevel = OrderOpenPrice() + PercentStep*(76-23);
StoplossLevel = OrderOpenPrice() + PercentStep*(51-23);
if (OrderStopLoss()-OrderOpenPrice()<StoplossLevel*po) {
pp=MarketInfo(OrderSymbol(), MODE_BID);
if (pp-OrderOpenPrice()>MoveStoplossLevel*po) {
ModifyOrder(-1, OrderOpenPrice()+StoplossLevel*po, -1);
}
}

}


if (OrderType()==OP_SELL) {
PercentStep=(OrderTakeProfit()-OrderOpenPrice())/po/(138-23);
MoveStoplossLevel = OrderOpenPrice() - PercentStep*(76-23);
StoplossLevel = OrderOpenPrice() - PercentStep*(51-23)
if (OrderStopLoss()==0 || OrderOpenPrice()-OrderStopLoss()<StoplossLevel*po) {
pp=MarketInfo(OrderSymbol(), MODE_ASK);
if (OrderOpenPrice()-pp>MoveStoplossLevel*po) {
ModifyOrder(-1, OrderOpenPrice()-StoplossLevel*po, -1);

}
}
}
}
}
}
}
}

//+----------------------------------------------------------------------------+

Cifras:

138 es la ganancia en % de Fibonacci.

23 es el precio de apertura de la orden en % de Fibonacci

76 es el % de la cuadrícula de Fibonacci, si el precio alcanza este valor, el stop loss se moverá al 51% de la cuadrícula de Fibonacci.

Función de e-MovingInWL2 Expert Advisor.

 
int start()
{

Trailing();


double Line11=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 1);
double Line12=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 2);
double Line21=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 5, 1);

if (timeprev == Time[0]) return(0);
timeprev = Time[0];

ma0=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,1);
ma1=iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,1);
ma2=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,1);
ma3=iMA(NULL,0,800,0,MODE_SMA,PRICE_CLOSE,1);

if (CountBuy()>5 && Volume[0]==1 && Ask > ma0 && Ask > ma1 && Ask > ma3)
{
if (Line11>Level1&&Line12<Level1&&Line11>Line12)
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask-sl*Point, Ask+tp*Point, comment, Magic, 0, Blue);
}

if (CountSell()>5 && Volume[0]==1 && Bid < ma0 && Bid < ma1 && Ask < ma3)
{
if (Line11>Level2&&Line12>Level1&&Line11>Line12)
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Ask+sl*Point,Ask-tp*Point, comment, Magic, 0, Red);
}

return(0);
}


Por favor, ayude a encontrar un error en el código con la señal de abrir órdenes por el indicador TDI Red Green.

El probador no abre tratos, o sólo abre uno. No informa de ningún error.

He indicado correctamente los topes del indicador.

Estoy aprendiendo mql4 desde hace unos días, soy un principiante))

¡Agradezco de antemano la ayuda!
 
Me encuentro con este dilema: digamos que hay un bucle para:

int Array_1[][];
int Array_2[][];
int Array_3[][];
int Array_4[][];
 . . . 


start() {

   for(int k=1; k<=N; k++) {

      if(k==1) {
         Используем массив ARRAY_1
      }
      if(k==2) {
         Используем массив ARRAY_2
      }
      if(k==3) {
         Используем массив ARRAY_3
      }
      . . . 
   } // for(int k=1; k<=N; k++) {

} // start() {

El parámetro N en él es variable, lo que significa que cada vez que se cambia, el código tiene que ser reelaborado mediante la adición (o eliminación) de las condiciones "si" (bajo la matriz correspondiente).

Pregunta - ¿es posible usar sólo un "if", pero usar la variable "to" en los nombres de las matrices (o algo más)? Es decir, algo como ARRAY_{k}. Sé que podemos sustituir las matrices por variables terminales, pero es un caso extremo. ¿Existe esta solución para las matrices?
 
chief2000:
Me enfrenté a este dilema - digamos que hay un bucle-para:


El parámetro N en él es variable, lo que significa que cada vez que se cambia, hay que modificar el código añadiendo (o eliminando) condiciones "if" (bajo la matriz correspondiente).

Pregunta - ¿es posible usar sólo un "if", pero usar la variable "to" en los nombres de las matrices (o algo más)? Es decir, algo como ARRAY_{k}. Sé que podemos sustituir las matrices por variables terminales, pero es un caso extremo. ¿Existe esta solución para las matrices?

Puedes si es de alguna manera similar:

// Константы
#define   Version     "TT-Pod 1.2.6"
#define   MyError     4999
#define   Infinity    100000000.0
#define   Zero                0.00000001
#define   TypesTotal  24
// Глобальные переменные и массивы
int      LastBar,
         Visibility,
         Groups[2],
         MainGroup[2],
         OldMG[2],
         StumbleNumber[2];
double   QualityMax[2];
datetime DeadLine,
         OldStopLine,
         StartTime[2],
         NewTime;
color    ЦветЛиний[2],
         Цвет123[2],
         ЦветХорды[2];
string   NameTangent[2]     ={"RaisingTangent"     ,"ReducingTangent"     },
         NameTrend[2]       ={"RaisingTrend"       ,"ReducingTrend"       },
         NameBorder[2]      ={"RaisingBorder"      ,"ReducingBorder"      },
         NameLevel1[2]      ={"RaisingLevel_1_"    ,"ReducingLevel_1_"    },
         NameLevel12[2]     ={"RaisingLevel_2_"    ,"ReducingLevel_2_"    },
         NameLevel2[2]      ={"RaisingLevel_3_"    ,"ReducingLevel_3_"    },
         NameLevel22[2]     ={"RaisingLevel_4_"    ,"ReducingLevel_4_"    },
         NameMainLevel1[2]  ={"MainRaisingLevel_1" ,"MainReducingLevel_1" },
         NameMainLevel12[2] ={"MainRaisingLevel_3" ,"MainReducingLevel_3" },
         NameMainLevel2[2]  ={"MainRaisingLevel_2" ,"MainReducingLevel_2" },
         NameMainLevel22[2] ={"MainRaisingLevel_4" ,"MainReducingLevel_4" },
         NameTrace[2]       ={"RaisingTrace"       ,"ReducingTrace"       },
         NameAttention[2]   ={"RaisingAttention"   ,"ReducingAttention"   },
         NameSpiral[2]      ={"RaisingSpiral"      ,"ReducingSpiral"      },
         NameSpan[2]        ={"RaisingSpan"        ,"ReducingSpan"        },
         NameMainLevel0[2]  ={"MainRaisingLevel_0" ,"MainReducingLevel_0" },
         NameMainLevel5[2]  ={"MainRaisingLevel_5" ,"MainReducingLevel_5" },
         NameMainLevel6[2]  ={"MainRaisingLevel_6" ,"MainReducingLevel_6" },
         NameBaseLevel[2]   ={"RaisingBaseLevel"   ,"ReducingBaseLevel"   },
         Name123[2]         ={"RaisingTrendBreak"  ,"ReducingTrendBreak"  },
         NameSpiralBorder[2]={"RaisingSpiralBorder","ReducingSpiralBorder"},
         NameDirector[2]    ={"RaisingDirector"    ,"ReducingDirector"    },
         NameHorizont[2]    ={"RaisingHorizont"    ,"ReducingHorizont"    },
         NameStumble[2]     ={"RaisingStumble"     ,"ReducingStumble"     },
         РежимРаботы        =" ",
         TextTangent[2]     ={""                                  ,""},
         TextTrend[2]       ={""                                  ,""},
         TextTrace[2]       ={""                                  ,""},
         TextBorder[2]      ={""                                  ,""},
         TextLevel1[2]      ={""                                  ,""},
         TextLevel12[2]     ={""                                  ,""},
         TextLevel2[2]      ={""                                  ,""},
         TextLevel22[2]     ={""                                  ,""},
         TextSpan[2]        ={""                                  ,""},
         TextDirector[2]    ={"                                              Директорная ВТ"
                             ,"                                              Директорная НТ"},
         TextHorizont[2]    ={"                                              Горизонт ВТ"
                             ,"                                              Горизонт НТ"},
         Text123[2]         ={"Пробой ВТ"                         ,"Пробой НТ"},
         TextAttention[2]   ={"В! "                               ,"Н! "},
         TextSpiral[2]      ={"          ВТ"                      ,"          НТ"},
         TextSpiralBorder[2]={"               ВГр"                ,"               НГр"},
         TextMainLevel0[2]  ={"ВУр0"                              ,"НУр0"},
         TextMainLevel1[2]  ={"     ВУр1"                         ,"     НУр1"},
         TextMainLevel2[2]  ={"          ВУр2"                    ,"          НУр2"},
         TextMainLevel12[2] ={"",""},
         TextMainLevel22[2] ={"                    ВУр4"          ,"                    НУр4"},
         TextMainLevel5[2]  ={"                         ВУр5"     ,"                         НУр5"},
         TextMainLevel6[2]  ={"                              ВУр6","                              НУр6"},
         TextBaseLevel[2]   ={"                ВБУ"               ,"                НБУ"},
         TextStumble[2]     ={""                                  ,""};
// Внешние переменные
extern double  МинНаклонТренда         =0.0,       // Фильтры "ложных" трендовых
               МаксНаклонТренда        =Infinity;
extern string  Варианты="1=Hb, 2=Hb/H, 3=H, 4=V, 5=N";
extern int     КритерийВыбора          =5,
               МинБазовыйПериод        =1,
               МаксБазовыйПериод       =Infinity,
               БарНачала               =Infinity,  // Параметры отображения
               БарОкончания            =1,
               ПериодИмитацииТиков     =2000,
               СдвигИндикатораТиков    =10,
               ЗнакИндикатораТиков     =159,
               РазмерИндикатораТиков   =5,
               ТолщинаТрендовой        =3;
extern color   ЦветПоддержки           =Green,
               ЦветВосходящейХорды     =LimeGreen,
               Цвет123 ВТ               =LightYellow,
               ЦветСопротивления       =Red,
               ЦветНисходящейХорды     =HotPink,
               Цвет123 НТ               =LightYellow,
               ЦветВертикалей          =DimGray,
               ЦветИндикатораТиков     =DarkOrange;
extern bool    ОчиститьЭкран           =true,
               ПоказыватьВсе           =false,
               РежимОтладки            =true,      // Режим работы программы
               СтатическийРежим        =false,
               МоделироватьДинамику    =false,
               ПечататьПредупреждения  =false;
//-----------------------------------------------------------------------------
// Удаление созданных графических объектов
void ClearScreen(){
   int Dimension=2*TypesTotal;
   string Name, Pref[];
   Comment("                                                       "+
           "                                                       "+
           "                                                       ");
   ArrayResize(Pref,Dimension);
   Pref[ 0]=NameTangent[0];
   Pref[ 1]=NameTangent[1];
   Pref[ 2]=NameTrend[0];
   Pref[ 3]=NameTrend[1];
   Pref[ 4]=NameBaseLevel[0];
   Pref[ 5]=NameBaseLevel[1];
   Pref[ 6]=NameTrace[0];
   Pref[ 7]=NameTrace[1];
   Pref[ 8]=NameLevel12[0];
   Pref[ 9]=NameLevel12[1];
   Pref[10]=NameLevel22[0];
   Pref[11]=NameLevel22[1];
   Pref[12]=NameBorder[0];
   Pref[13]=NameBorder[1];
   Pref[14]=NameLevel2[0];
   Pref[15]=NameLevel2[1];
   Pref[16]=NameMainLevel12[0];
   Pref[17]=NameMainLevel12[1];
   Pref[18]=NameMainLevel22[0];
   Pref[19]=NameMainLevel22[1];
   Pref[20]=NameSpiralBorder[0];
   Pref[21]=NameSpiralBorder[1];
   Pref[22]=NameMainLevel2[0];
   Pref[23]=NameMainLevel2[1];
   Pref[24]=NameAttention[0];
   Pref[25]=NameAttention[1];
   Pref[26]=NameLevel1[0];
   Pref[27]=NameLevel1[1];
   Pref[28]=NameMainLevel1[0];
   Pref[29]=NameMainLevel1[1];
   Pref[30]=NameSpiral[0];
   Pref[31]=NameSpiral[1];
   Pref[32]=NameSpan[0];
   Pref[33]=NameSpan[1];
   Pref[34]=NameMainLevel0[0];
   Pref[35]=NameMainLevel0[1];
   Pref[36]=NameMainLevel5[0];
   Pref[37]=NameMainLevel5[1];
   Pref[38]=NameMainLevel6[0];
   Pref[39]=NameMainLevel6[1];
   Pref[40]=Name123[0];
   Pref[41]=Name123[1];
   Pref[42]=NameDirector[0];
   Pref[43]=NameDirector[1];
   Pref[44]=NameStumble[0];
   Pref[45]=NameStumble[1];
   Pref[46]=NameHorizont[0];
   Pref[47]=NameHorizont[1];
   int i, k=ObjectsTotal()-1;
   while( k>=0 ){
      Name=ObjectName(k);
      i=Dimension-1;
      while( i>=0 ){
         if( StringSubstr(Name,0,StringLen(Pref[i]))==Pref[i] ){
            if( !ObjectDelete(Name) ) {
               if( !РежимОтладки ) PlaySound("alert.wav");
               Print("***** "+Name+": ошибка удаления "+GetLastError()+" при очистке экрана");
         }  }
         i--;
      }
      k--;
   }
   return;
}
 
tara:

Puedes si es de alguna manera similar:


¿Puede describir con palabras lo que quería decir?
 
chief2000:

¿Puede describir con palabras lo que quería decir?


Lo siento, me distraje.

El índice del array forma parte del identificador.

 

He aquí un código sencillo.

Quiero que el programa dibuje una línea vertical en CADA 50ª vela.

el programa dibujará una línea vertical.

EL PROBLEMA ES .

El programa muestra una línea vertical SÓLO EN LA PRIMERA CORONA (múltiplo de 50).

Gracias.

double p;

int start()
{

p=Bars%50;
if(p<1)
ObjectCreate(0, OBJ_VLINE, 0, Time[1],0  );

                     
return(0);
}
 
tara:


El índice del array forma parte del identificador.


Por lo que entiendo tu solución no funcionará en mi caso, pero me ha dado una idea que merece la pena comprobar. Gracias.
 
solnce600:

He aquí un código sencillo.

Lo quiero en CADA vela quincuagésima.

el programa exponía una línea vertical.

PROBLEMA

El programa establece una línea vertical SÓLO en la PRIMERA LÍNEA (múltiplo de 50).

Quiero que sea el mismo nombre para cada quincuagésima vela.

Estás intentando crear varios objetos con el mismo nombre y esto no es posible. El nombre tiene que ser único, como el tiempo:

ObjectCreate(Time[i], OBJ_VLINE, 0, Time[i],0 );

Eso es lo primero. En segundo lugar, ¿dónde está el bucle? ¿Cómo contará el guión las velas?