Date when file was compiled without time (hours, minutes and seconds are 0)
__DATETIME__
Date and time when the file was compiled
__LINE__
Line number in the source code where the macro is located
__FILE__
Name of the file being compiled
__PATH__
Absolute path to the current compiled file
__FUNCTION__
Name of the function in the body of which the macro is located
__FUNCSIG__
Function signature in the body of which the macro is located. The function description with types of parameters can be useful in identification ofoverloaded functions
Could you please tell me where in the code there is an error that prevents opening BUY position on the same bar with SELL that has closed the previous position?
The rules are simple (to learn): 1 Entry - slow indicator crossing 0 + fast also in the zone (buy/sell)
2 Exit - crossing by fast indicator 0
//+------------------------------------------------------------------+//| TestDPO.mq5 |//| Copyright 2020, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2020, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#include <Trade\Trade.mqh>
CTrade trade;
inputint dpo_fast_period = 9; // DPO Fast Periodinputint dpo_slow_period = 40; // DPO Fast Periodinputint magic = 1000; // Magic советникаinputulong slippage = 10; // Проскальзывание ценыinputdouble volume = 0.1; // размер позицииint DPO_fast; // Хэндл для быстрого DPOint DPO_slow; // Хэндл для медленного DPOdouble fDPOVal[]; //Динамический массив для хранения значений fast DPOdouble sDPOVal[]; //Динамический массив для хранения значений slow DPO//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---------------Задаем цены покупки и продажи------------------------double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
int signal=0; // сигнал на покупку, продажу//--------------Проверка на новый барif(!isNewBar())
return;
//--------------------------------------------------------------------
DPO_fast=iCustom(NULL,0,"Examples\\DPO",dpo_fast_period); // получаем хэндлы для быстрого
DPO_slow=iCustom(NULL,0,"Examples\\DPO",dpo_slow_period); // получаем хэндлы для медленногоArraySetAsSeries(fDPOVal,true); //задаем направление индексов массиваArraySetAsSeries(sDPOVal,true);
if(CopyBuffer(DPO_fast,0,0,10,fDPOVal)<0) // наполняем массив значений DPO fast
{
Alert("Ошибка копирования буфера индикатора fast DPO. Ошибка ", GetLastError());
}
if(CopyBuffer(DPO_slow,0,0,10,sDPOVal)<0) // наполняем массив значений DPO slow
{
Alert("Ошибка копирования буфера индикатора slow DPO. Ошибка ", GetLastError());
}
double DPO_fast_c_value=NormalizeDouble(fDPOVal[1],6); // запоминаем значение индикатора DPO fast на предыдущем бареdouble DPO_slow_c_value=NormalizeDouble(sDPOVal[1],6); // запоминаем значение индикатора DPO slow на предыдущем бареdouble DPO_fast_p_value=NormalizeDouble(fDPOVal[2],6); // запоминаем значение индикатора DPO fast на пред-предыдущем бареdouble DPO_slow_p_value=NormalizeDouble(sDPOVal[2],6); // запоминаем значение индикатора DPO slow на пред-предыдущем бареif(DPO_slow_c_value>0 && DPO_slow_p_value<0 && DPO_fast_c_value>0) // если медленный индикатор пересекает 0 снизу вверх и быстрый находится выше 0
signal=1; // сигнал на открытие покупкиif(DPO_slow_c_value<0 && DPO_slow_p_value>0 && DPO_fast_c_value<0) // если медленный индикатор пересекает 0 сверху вниз и быстрый находится ниже 0
signal=-1; // сигнал на открытие продажиif(DPO_fast_c_value>0 && DPO_fast_p_value<0) // если быстрый индикатор пересекает 0 снизу вверх
signal=-2; // сигнал на закрытие продажиif(DPO_fast_c_value<0 && DPO_fast_p_value>0) // если быстрый индикатор пересекает 0 сверху вниз
signal=2; // сигнал на закрытие покупкиswitch (signal)
{
case -1:
trade.Sell(volume,NULL,Bid,0,0,NULL);
break;
case1:
trade.Buy(volume,NULL,Ask,0,0,NULL);
break;
case -2:
trade.PositionClose(_Symbol,slippage);
break;
case2:
trade.PositionClose(_Symbol,slippage);
break;
}
}
Задавайте вопросы по техническому анализу, обсуждайте торговые системы и улучшайте свои навыки программирования торговых стратегий на языке MQL5. Общайтесь и обменивайтесь опытом на форуме с трейдерами всего мира и помогайте ответами новичкам — наше сообщество развивается вместе с вами. Как я собираю себе советника методом тыка Из этих...
Could you please tell me where in the code there is an error that prevents to open BUY position on the same bar with SELL that closed a previous position?
The rules are simple (to learn): 1 Entry - slow indicator crossing 0 + fast also in the zone (buy/sell)
2 Exit - fast indicator crossing 0 line
All works correctly: opening conditions crossing of slow indicator 0 line, only fast indicator crossed 0 line in the specified place.
A condition must be added to open a position at the specified location, slow in the same area and fast crosses the 0 line
Could you please advise where in the code there is an error that prevents BUY position from opening on the same bar with SELL, which has closed a previous position?
The rules are simple (to learn): 1 Entry - slow indicator crossing 0 + fast also in the zone (buy/sell)
2 Exit - crossing by fast indicator 0
You are making a gross error: You ARE creating TWO INLIKERS FOR EACH TICK!
//--------------------------------------------------------------------
DPO_fast=iCustom(NULL,0,"Examples\\DPO",dpo_fast_period); // получаем хэндлы для быстрого
DPO_slow=iCustom(NULL,0,"Examples\\DPO",dpo_slow_period); // получаем хэндлы для медленного
Идея автоматической торговли привлекательна тем, что торговый робот может без устали работать 24 часа в сутки и семь дней в неделю. Робот не знает усталости, сомнений и страха, ему не ведомы психологические проблемы. Достаточно четко формализовать торговые правила и реализовать их в виде алгоритмов, и робот готов неустанно трудиться. Но прежде...
OK, I'll look for a mon with 4K.
Where is this picture from?
Forum on Trading, Automated Trading Systems and Strategy Tests
FAQ from Beginners MQL5 MT5 MetaTrader 5
Vitaly Muzichenko, 2020.05.13 08:32
Here is 4K and1920x1080
Where is this picture from?
Sent from 4K
Sent with 4K
Well, can you check again I suppose? Or not?
Well, can you check again I suppose? Or not?
Not desirable)
How to get the value of MQL5 program version defined by property# version?
It turns out that you can't, because inPredefined macro substitutions
Constant
Description
__DATE__
Date when file was compiled without time (hours, minutes and seconds are 0)
__DATETIME__
Date and time when the file was compiled
__LINE__
Line number in the source code where the macro is located
__FILE__
Name of the file being compiled
__PATH__
Absolute path to the current compiled file
__FUNCTION__
Name of the function in the body of which the macro is located
__FUNCSIG__
Function signature in the body of which the macro is located. The function description with types of parameters can be useful in identification ofoverloaded functions
__MQLBUILD__, __MQL5BUILD__
Number of the compiler build
no such variable
How to get the value of MQL5 program version defined by property# version?
I use this, I couldn't find any other option. You need to specify the version twice, but it's not that difficult
Good day, dear experts.
Could you please tell me where in the code there is an error that prevents opening BUY position on the same bar with SELL that has closed the previous position?
The rules are simple (to learn):
1 Entry - slow indicator crossing 0 + fast also in the zone (buy/sell)
2 Exit - crossing by fast indicator 0
Good afternoon, esteemed experts.
Could you please tell me where in the code there is an error that prevents to open BUY position on the same bar with SELL that closed a previous position?
The rules are simple (to learn):
1 Entry - slow indicator crossing 0 + fast also in the zone (buy/sell)
2 Exit - fast indicator crossing 0 line
All works correctly: opening conditions crossing of slow indicator 0 line, only fast indicator crossed 0 line in the specified place.
A condition must be added to open a position at the specified location, slow in the same area and fast crosses the 0 line
Good day, dear experts.
Could you please advise where in the code there is an error that prevents BUY position from opening on the same bar with SELL, which has closed a previous position?
The rules are simple (to learn):
1 Entry - slow indicator crossing 0 + fast also in the zone (buy/sell)
2 Exit - crossing by fast indicator 0
You are making a gross error: You ARE creating TWO INLIKERS FOR EACH TICK!
Indicator handle MUST be created once at OnInit.
Please read theiCustom help.