Опубликовал пост Пример математически правильной Торговой Системы Ниже математически правильная ТС с проверкой, что это так. Логика ТС следующая: переворачивается вовнутрь, когда цена с запасом пересекает EMA-шку от цены. // Пример математически правильной ТС с возможностью ее проверки в MT5-Тестере. // https://www.mql5... Добавил тему...
No soy un gran fanático de compartir mi propio trabajo, por lo que algunas optimizaciones en tiempo de ejecución para las matrices de Pod han sido recortadas. En su lugar, una funcionalidad ligeramente ampliada: - compila para MT4 (build 1262, ME 2380) y MT5 (build 2380, ME 2380); - Admite estructuras Pod y NonPod; - trabaja con matrices de estructuras estáticas y dinámicas;
#property strict#define PRINT(x) ; Print(#x, ":", string(x))
#define CONSTRAINT(ex) if(false){string test = typename(ex);}
//+------------------------------------------------------------------+//| Test Inviroment |//+------------------------------------------------------------------+struct Pod{
int value;
};
struct NonPod : public Pod{
uchar data[];
};
template<typename T>
void ArrayInit(T &arr[]){
int size = ArraySize(arr);
for(int i = 0; i < size; ++i){
arr[i].value = size - i;
}
}
template<typename T>
string ArrayPrintValue(T &arr[]){
string result = "";
for(int i = 0; i < ArraySize(arr); ++i){
result += string(arr[i].value) + " ";
}
return result;
}
//+------------------------------------------------------------------+//| Fixed code |//+------------------------------------------------------------------+template <typename T>
void ArrayReindex( T &Array[], constdouble &TmpSort[][2] )
{
T TmpArray[];
for (int x = ::ArrayResize(TmpArray, ::ArrayRange(TmpSort, 0)) - 1; x >= 0; x--){
TmpArray[x] = Array[(int)(TmpSort[x][1] + 0.1)];
}
#ifdef __MQL5__if(!::ArraySwap(Array, TmpArray)){
ArrayFunctions::ArrayCopy(Array, TmpArray);
}
#endif
#ifdef __MQL4__
ArrayFunctions::ArrayCopy(Array, TmpArray);
#endif
return;
}
// Сортировка массива структур и указателей на объекты по (под-) полю/методу. #define ArraySortStruct(ARRAY, FIELD) \
{ \
double TmpSort[][2]; \
int size = ::ArraySize(ARRAY); \
::ArrayResize(TmpSort, ::ArraySize(ARRAY)); \
for (int x = size - 1; x >= 0; x--) \
{ \
TmpSort[x][0] = (double)ARRAY[x].FIELD; \
TmpSort[x][1] = x; \
} \
\
::ArraySort(TmpSort); \
::ArrayReindex(ARRAY, TmpSort); \
}
//+------------------------------------------------------------------+//| Test |//+------------------------------------------------------------------+voidOnStart(){
Pod arr_pod[9];
NonPod arr_nonpod[];
ArrayResize(arr_nonpod, 9);
ArrayInit(arr_pod);
ArrayInit(arr_nonpod);
PRINT(ArrayPrintValue(arr_pod)); // 9 8 7 6 5 4 3 2 1
PRINT(ArrayPrintValue(arr_nonpod)); // 9 8 7 6 5 4 3 2 1
ArraySortStruct(arr_pod, value);
ArraySortStruct(arr_nonpod, value);
PRINT(ArrayPrintValue(arr_pod)); // 1 2 3 4 5 6 7 8 9
PRINT(ArrayPrintValue(arr_nonpod)); // 1 2 3 4 5 6 7 8 9
}
//+------------------------------------------------------------------+//| Optimization Standat Array Functions |//+------------------------------------------------------------------+class ArrayFunctions{
public:
//+------------------------------------------------------------------+//| Copies an array into another one |//+------------------------------------------------------------------+template<typename T_dst, typename T_src>
staticintArrayCopy(T_dst &dst_array[], const T_src &src_array[], int dst_start = 0, int src_start = 0, int count = WHOLE_ARRAY){
CONSTRAINT(dst_array[0] = src_array[0]);
if(dst_start < 0 || src_start < 0){
return -1;
}
if(ArraySize(src_array) - src_start <= 0){
return -1;
}
int max_count = MathMin(ArraySize(dst_array) - dst_start, ArraySize(src_array) - src_start);
count = count > 0 ? count : max_count;
count = count < max_count ? count : max_count;
int result = ArrayCopy_AnyType(dst_array, src_array, dst_start, src_start, count);
return result;
}
//+------------------------------------------------------------------+private:
template<typename T_dst, typename T_src>
staticint ArrayCopy_AnyType(T_dst &dst_array[], const T_src &src_array[], int dst_start, int src_start, int count){
int dst_size = dst_start + count;
if(dst_size > ArraySize(dst_array)){
ArrayResize(dst_array, dst_size);
}
if(dst_size >= src_start && dst_start < src_start){
for(int i = 0; i < count; ++i){
dst_array[dst_start + i] = src_array[src_start + i];
}
}
else{
for(int i = count - 1; i >= 0; --i){
dst_array[dst_start + i] = src_array[src_start + i];
}
}
return count;
}
};
Para iniciar sesión y usar el sitio web MQL5.com es necesario permitir el uso de Сookies.
Por favor, active este ajuste en su navegador, de lo contrario, no podrá iniciar sesión.
Ha iniciado sesión. La autenticación de dos factores se ha desactivado. Vuelva a configurarla y escanee un nuevo código QR, o continúe con la autenticación de dos factores desactivada.
La respuesta no era para todas las ocasiones. La mayoría están cerrando.
¡Muchas graciasfxsaber por tu ayuda! Dónde transferir 10 dólares
¡Muchas graciasfxsaber por tu ayuda! Dónde transferir 10 dólares
De nada.
De nada.
Tu método no funciona si hay datos de cadena en la estructura ordenada...
Tu método no funciona si hay datos de cadena en la estructura ordenada...
Usa esto.
directamente irrealizable en mql.
Pero por cierto, sí :-( un (pseudo)puntero a una función no puede ser un comodín
Pero uno podría pensar, ¿cuál es el problema?
Después de C/C++ tal comportamiento repugna a los intentos de "crear una ortiga" en MQL. Sólo soluciones individuales específicas
Usa este.
Este tampoco funciona ((((
Las declaraciones de plantillas no están permitidas en las clases locales
Pero por cierto, sí :-( un (pseudo)puntero a una función no puede ser un comodín
Pero uno podría pensar, ¿cuál es el problema?
Después de C/C++ tal comportamiento me disgusta de mis intentos de "crear netliness" en MQL. Sólo soluciones individuales específicas
¿Cuál es el problema?
Puedes seguir utilizando el código sugerido si lo deseas:
Este tampoco funciona ((((
Las declaraciones de plantillas no están permitidas en las clases locales
Comprobado, funciona.
En su lugar, una funcionalidad ligeramente ampliada:
- compila para MT4 (build 1262, ME 2380) y MT5 (build 2380, ME 2380);
- Admite estructuras Pod y NonPod;
- trabaja con matrices de estructuras estáticas y dinámicas;