//+------------------------------------------------------------------+ //| Ind - The xCustom | //| Copyright 2008-2018, Expforex | //| https://www.expforex.com | //+------------------------------------------------------------------+ //################################################################################################################################################################### // Для простоты программирования // // Нажмите сочетание клавиш Ctrl+F и вы увидите строку поиска; // Введите название Step MT4 или Step MT5 - По этому слову, в нашем исходном коде, // Вы сможете ориентироваться и быстро написать свою стратегию. // // Каждый шаг комментирован и содержит пример //################################################################################################################################################################### // for ease of programming // // Press the key combination Ctrl + F and you will see the search bar; // Enter the name Step MT4 or Step MT5 - For this word, in our source code, // You can navigate and quickly write your strategy. // // Each step is commented and contains an example. //################################################################################################################################################################### //################################################################################################################################################################### // НЕ ИЗМЕНЯТЬ!!!! // DO NOT CHANGE!!! // Этот Порядок и параметры изменять нельзя! Это стандартные параметры для работы советника! // This type and parameters cannot be changed! These are standard parameters for the work of an adviser! //################################################################################################################################################################### //+------------------------------------------------------------------+ //| Тип расчета // Type of calculate //+------------------------------------------------------------------+ enum TypeCalculate { TypeCalculateAll=0,//All TypeCalculateSignal=1,//Signal TypeCalculateFilter=2,//Filter TypeCalculateClose=3,//Close TypeCalculateSLTP=4,//SLTP }; input string StrategySymbol=""; input ENUM_TIMEFRAMES StrategyTimeFrame=PERIOD_CURRENT; input int StrategyNumber=1; input TypeCalculate StrategyType=0; input int StrategyShift=1; input string StrategyInputs; input int BarsToShow=500; //################################################################################################################################################################### // Step MT4 0 #################################################################### // Step MT5 0 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Вы можете объявить здесь свои внешние переменные, которые будут использоваться в советнике! // Внимание! Порядок и тип переменных задается в строгом соответствии с вызовом в советнике в параметрах // SIGNALStrategyInputs CloseStrategyInputs SLTPStrategyInputs FILTERStrategyInputs // // You can declare your external variables here that will be used in the advisor! // Attention! The order and type of variables is set in strict accordance with the call in the expert in the parameters // SIGNALStrategyInputs CloseStrategyInputs SLTPStrategyInputs FILTERStrategyInputs // #################################################################### // for example: // input int InpCCIPeriod=1; // input double InpCCIPeriod2=2.0; // input color InpCCIPeriod3=clrGreen; // input string InpCCIPeriod6="text"; // input datetime InpCCIPeriod4=2018.11.08; // input bool InpCCIPeriod5=false; // ========================================================================= // В советнике эти параметры должны быть записаны как: // In the expert advisor, these parameters should be written as: // SIGNALStrategyInputs=1,2.0,C'0/128/0',"text ",D'2018.11.08',false // CloseStrategyInputs=1,2.0,C'0/128/0',"text ",D'2018.11.08',false // SLTPStrategyInputs=1,2.0,C'0/128/0',"text ",D'2018.11.08',false // FILTERStrategyInputs=1,2.0,C'0/128/0',"text ",D'2018.11.08',false // ########################################################################### //+------------------------------------------------------------------+ //| Объявим переменные для хранения настроек индикаторов //| Настройки, которыми не нужно управлять из советника можно скрыть, //| Те настройки, которыми нужно управлять из советника, нужно вывести в в нешние переменные добавлением input //| //| Let's declare variables for storing indicator settings //| Settings that you do not need to manage from the advisor can be hidden, //| Those settings that need to be managed from the advisor should be brought into external variables by adding input //+------------------------------------------------------------------+ // Step MT4 1 #################################################################### // Step MT5 1 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Для того,чтобы при компиляции, индикатор был встроен в советник, Вам необходимо загрузить его в ресурсы советника // In order for the indicator to be built into the Expert Advisor during compilation, you need to load it into the resources of the Expert Advisor // #################################################################### // for example: //* #resource "\Indicators\Market\Examples.ex5" // ########################################################################### //################################################################################################################################################################### //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ //| Описание : Объявим переменные для хранения хэндлов индикаторов //| Description : Declare the variables for storing indicator handles //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+//+------------------------------------------------------------------+ // Step MT5 2 #################################################################### // Только для МТ5 // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // обьявите переменную массива хендлов // Declare the variable of the handle array // #################################################################### // for example: //* int h_custom_for_Open; // ########################################################################### int h_custom_for_Open; int h_custom_for_Close; int h_custom_for_Filter; int h_custom_for_SLTP; //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ //| Описание : Объявим нужные массивы для хранения данных индикаторов //| Description : Declare the necessary arrays for storing indicator data //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+//+------------------------------------------------------------------+ // Step MT4 3 #################################################################### // Step MT5 3 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // обьявите переменную массива значений индикатора // Declare the variable of the handle array // #################################################################### // for example: //* double custom_buffer_for_Open_BUY[]; //* double custom_buffer_for_Open_SELL[]; // ########################################################################### double custom_buffer_for_Open_BUY[]; double custom_buffer_for_Open_SELL[]; double custom_buffer_for_Close_BUY[]; double custom_buffer_for_Close_SELL[]; double custom_buffer_for_Filter_BUY[]; double custom_buffer_for_Filter_SELL[]; double custom_buffer_for_SL_BUY[]; double custom_buffer_for_SL_SELL[]; double custom_buffer_for_TP_BUY[]; double custom_buffer_for_TP_SELL[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void IndicatorInit() { #ifdef __MQL5__ // Инициализируем индикаторы, Initializing Indicators switch(StrategyNumber) { // Step MT5 4 #################################################################### // Только для МТ5 // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Вам необходимо создать запись в массиве для того, чтобы советник присвоил хендл индикатора при инициализации // Если необходимо указать внешние переменные индикаторы, то это можно сделать после IndicatorName через запятую, // например: // h_custom_for_Open=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,InpCCIPeriod,InpCCIPeriod2,InpCCIPeriod3,InpCCIPeriod6,InpCCIPeriod4,InpCCIPeriod5); // // You need to create an entry in the array in order for the Expert Advisor to assign an indicator handle when initializing // If you need to specify external variable indicators, this can be done after IndicatorName, separated by commas // eg: // h_custom_for_Open = iCustom (StrategySymbolString, StrategyTimeFrame, IndicatorName, InpCCIPeriod, InpCCIPeriod2, InpCCIPeriod3, InpCCIPeriod6, InpCCIPeriod4, InpCCIPeriod5); // #################################################################### // for example: //* case 1: //* h_custom_for_Open=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName); //* if(h_custom_for_Open==INVALID_HANDLE){Print(" Failed to get indicator handle | Не удалось получить хендл индикатора");return;} //* break; // ########################################################################### case 1: // Если нужно указать индикатор для открытия позиций if(h_custom_for_Open<=0) h_custom_for_Open=iCustom(StrategySymbolString,StrategyTimeFrame,"Examples\\MACD_DL_2colors"); if(h_custom_for_Open==INVALID_HANDLE){Print(" Failed to get indicator handle | Не удалось получить хендл индикатора");return;} // Если нужно указать индикатор для закрытия позиций if(h_custom_for_Close<=0) h_custom_for_Close=iCustom(StrategySymbolString,StrategyTimeFrame,"Examples\\MACD_DL_2colors"); if(h_custom_for_Close==INVALID_HANDLE){Print(" Failed to get indicator handle | Не удалось получить хендл индикатора");return;} // Если нужно указать индикатор для фильтрации позиций if(h_custom_for_Filter<=0) h_custom_for_Filter=iCustom(StrategySymbolString,StrategyTimeFrame,"Examples\\MACD_DL_2colors"); if(h_custom_for_Filter==INVALID_HANDLE){Print(" Failed to get indicator handle | Не удалось получить хендл индикатора");return;} // Если нужно указать индикатор для стоплосса и тейкпрофита if(h_custom_for_SLTP<=0) h_custom_for_SLTP=iCustom(StrategySymbolString,StrategyTimeFrame,""); if(h_custom_for_SLTP==INVALID_HANDLE){Print(" Failed to get indicator handle | Не удалось получить хендл индикатора");return;} break; // ########################################################################### // ########################################################################### } #endif } //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ //| Описание : Функция определения сигнала для открытия по номеру индикатора //| Description : The signal detection function for opening by the indicator number //+---------------------------------------------------------------------------------------------+ //| Параметры : //| sigInd - Номер индиктора, Indicator number //| symToWork3 - Символ, Symbol //| TF - ТаймФрейм, TimeFrame //+---------------------------------------------------------------------------------------------+ //| Возврат : Сигнал для открытия позиций, Signal for opening positions //| 0 - нет сигнала, No Signal //| 1 - BUY //| -1 - SELL //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ int IndicatorSignal(int sigInd=0,string symToWork3="",int TF=0,int ShiftIndicator=1,int i=0) { // **************************************************************************************************** // ==================================================================================================== // Эту часть кода Не изменять! // Do not change this part of the code! // START int sig=0; if(symToWork3=="") symToWork3=Symbol(); int StartCopyI=i; InfoAboutSignal=""; if(sigInd==0) { return(-9); } // END // Эту часть кода Не изменять! // Do not change this part of the code! // ==================================================================================================== // **************************************************************************************************** if(sigInd==1) { // Внимание! Это примеры настроек, здесь я создал переменные, чтобы быстро заполнить их в следующих шагах! // Attention! These are examples of settings, here I created variables to quickly fill them in the following steps! string IndicatorName="Examples\\MACD_DL_2colors"; int SignalBuferforBUY=0; //SignalBuferforBUY --> Buffer number for BUY signal int SignalBuferforSELL=1; //SignalBuferforSELL --> Buffer number for SELL signal // // Step MT5 5 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для открытия позиций. Заполняем буферы данных // Here we create our signal for opening positions. Fill in the data buffer // ########################################################################### #ifdef __MQL5__ if(xCustomCopyBufferMT5(h_custom_for_Open,0,StartCopyI,3+ShiftIndicator,custom_buffer_for_Open_0)<3+ShiftIndicator)return(0); if(xCustomCopyBufferMT5(h_custom_for_Open,1,StartCopyI,3+ShiftIndicator,custom_buffer_for_Open_1)<3+ShiftIndicator)return(0); #endif // Step MT4 5 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для открытия позиций. Заполняем буферы данных // Here we create our signal for opening positions. Fill in the data buffer // ########################################################################### #ifdef __MQL4__ ArrayResize(custom_buffer_for_Open_BUY,3+ShiftIndicator); ArrayResize(custom_buffer_for_Open_SELL,3+ShiftIndicator); for(int inum=0;inum<3+ShiftIndicator; inum++) { custom_buffer_for_Open_BUY[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/SignalBuferforBUY,StartCopyI+inum); custom_buffer_for_Open_SELL[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/SignalBuferforSELL,StartCopyI+inum); } #endif // Step MT4 6 #################################################################### // Step MT5 6 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для открытия позиций. Здесь пишем нашу стратегию, // Here we create our signal for opening positions. Here we write our strategy, // ########################################################################### if(custom_buffer_for_Open_1[ShiftIndicator]custom_buffer_for_Open_0[ShiftIndicator+1]) sig=-1; else if(custom_buffer_for_Open_1[ShiftIndicator]>custom_buffer_for_Open_0[ShiftIndicator] && custom_buffer_for_Open_1[ShiftIndicator+1] Buffer number for BUY filter int FilterBuferforSELL=3; //FilterBuferforSELL --> Buffer number for SELL filter // // Step MT5 7 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш фильтр для фильтрации сигналов. Заполняем буферы данных // Here we create our filter for signal filtering. Fill in the data buffers // ########################################################################### #ifdef __MQL5__ if(xCustomCopyBufferMT5(h_custom_for_Filter,0,StartCopyI,3+ShiftIndicator,custom_buffer_for_Filter_0)<3+ShiftIndicator)return(0); if(xCustomCopyBufferMT5(h_custom_for_Filter,1,StartCopyI,3+ShiftIndicator,custom_buffer_for_Filter_1)<3+ShiftIndicator)return(0); #endif // Step MT4 7 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш фильтр для фильтрации сигналов. Заполняем буферы данных // Here we create our filter for signal filtering. Fill in the data buffers // ########################################################################### #ifdef __MQL4__ ArrayResize(custom_buffer_for_Filter_BUY,3+ShiftIndicator); ArrayResize(custom_buffer_for_Filter_SELL,3+ShiftIndicator); for(int inum=0;inum<3+ShiftIndicator; inum++) { custom_buffer_for_Filter_BUY[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/FilterBuferforBUY,StartCopyI+inum); custom_buffer_for_Filter_SELL[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/FilterBuferforSELL,StartCopyI+inum); } #endif // Step MT4 8 #################################################################### // Step MT5 8 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш фильтр для фильтрации сигналов. Здесь пишем нашу стратегию, // Here we create our filter for signal filtering. Here we write our strategy, // ########################################################################### if(custom_buffer_for_Filter_1[ShiftIndicator]0) sig=-1; else if(custom_buffer_for_Filter_1[ShiftIndicator]>custom_buffer_for_Filter_0[ShiftIndicator]>0) sig=1; else sig=0; // Конец шага ########################################################################### // //--- возвращаем торговый сигнал return(sig); } return(-100); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ //| Описание : Проверка отдельных сигналов на закрытие //| Description : Checking individual closure signals //+---------------------------------------------------------------------------------------------+ //| Параметры : //| sigINDICATORN - Номер сигнала //| Number of Signal //| TF - Таймфрейм //| timeframe //| Number - Порядковый номер //| Sequence number //+---------------------------------------------------------------------------------------------+ //| Возврат : Сигнал для закрытия //| Signal for close //| 0 - нет сигнала, No signal //| 1 - Сигнал, для закрытия BUY, Signal for close BUY //| -1 - Сигнал, для закрытия SELL, Signal for close SELL //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ int CLOSEIndicatorSignal(int sigInd=0,string symToWork3="",int TF=0,int ShiftIndicator=1,int i=0) { // **************************************************************************************************** // ==================================================================================================== // Эту часть кода Не изменять! // Do not change this part of the code! // START int sig=0; if(symToWork3=="")symToWork3=Symbol(); int shift=ShiftIndicator; int StartCopyI=i; // END // Эту часть кода Не изменять! // Do not change this part of the code! // ==================================================================================================== // **************************************************************************************************** if(sigInd==1) { // Внимание! Это примеры настроек, здесь я создал переменные, чтобы быстро заполнить их в следующих шагах! // Attention! These are examples of settings, here I created variables to quickly fill them in the following steps! string IndicatorName=""; int CloseBuferforBUY=4; //CloseBuferforBUY --> Buffer number for close BUY int CloseBuferforSELL=5; //CloseBuferforSELL --> Buffer number for close SELL // // Step MT5 9 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для закрытия позиций. Заполняем буферы данных // Here we create our signal for positions closing. Fill in the data buffers // ########################################################################### #ifdef __MQL5__ if(xCustomCopyBufferMT5(h_custom_for_Close,CloseBuferforBUY,StartCopyI,3+ShiftIndicator,custom_buffer_for_Close_BUY)<3+ShiftIndicator)return(0); if(xCustomCopyBufferMT5(h_custom_for_Close,CloseBuferforSELL,StartCopyI,3+ShiftIndicator,custom_buffer_for_Close_SELL)<3+ShiftIndicator)return(0); #endif // Step MT4 9 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для закрытия позиций. Заполняем буферы данных // Here we create our signal for positions closing. Fill in the data buffers // ########################################################################### #ifdef __MQL4__ // MetaTrader 4 #################################################################### // MetaTrader 4 MetaTrader 4 MetaTrader 4 MetaTrader 4 MetaTrader 4 MetaTrader 4 MetaTrader 4 MetaTrader 4 MetaTrader 4 ArrayResize(custom_buffer_for_Close_BUY,3+ShiftIndicator); ArrayResize(custom_buffer_for_Close_SELL,3+ShiftIndicator); for(int inum=0;inum<3+ShiftIndicator; inum++) { custom_buffer_for_Close_BUY[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/CloseBuferforBUY,StartCopyI+inum); custom_buffer_for_Close_SELL[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/CloseBuferforSELL,StartCopyI+inum); } #endif // Step MT4 10 #################################################################### // Step MT5 10 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для закрытия позиций. Здесь пишем нашу стратегию, // Here we create our signal for positions closing. Here we write our strategy, // ########################################################################### if(custom_buffer_for_Close_BUY[ShiftIndicator]!=EMPTY_VALUE && custom_buffer_for_Close_BUY[ShiftIndicator]>0) sig=-1; else if(custom_buffer_for_Close_SELL[ShiftIndicator]!=EMPTY_VALUE && custom_buffer_for_Close_SELL[ShiftIndicator]>0) sig=1; else sig=0; // Конец шага ########################################################################### // //--- возвращаем торговый сигнал return(sig); } return(-100); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ //| Описание : Проверка линий СЛ и ТП от индикаторов, программирование собственных стоплосс и тейкпрофит //| Description : Check lines SL and TP from indicators, programming your own stop loss and take profit //+---------------------------------------------------------------------------------------------+ //| Параметры : //| TF - Таймфрейм //| timeframe //+---------------------------------------------------------------------------------------------+ //| Возврат : Стоплосс, тейкпрофит //+---------------------------------------------------------------------------------------------+ //|#############################################################################################+ //+---------------------------------------------------------------------------------------------+ double SLTPIndicatorSignal(int sigInd=0,string symToWork3="",int TF=0,int ShiftIndicator=1,int i=0,int type=-1) { // **************************************************************************************************** // ==================================================================================================== // Эту часть кода Не изменять! // Do not change this part of the code! // START int sig=0; if(symToWork3=="")symToWork3=Symbol(); int shift=ShiftIndicator; int StartCopyI=i; // END // Эту часть кода Не изменять! // Do not change this part of the code! // ==================================================================================================== // **************************************************************************************************** if(sigInd==1) { // Внимание! Это примеры настроек, здесь я создал переменные, чтобы быстро заполнить их в следующих шагах! // Attention! These are examples of settings, here I created variables to quickly fill them in the following steps! string IndicatorName=""; int SLTPBuferforBUY_StopLoss=-1; //SLTPBuferforBUY_StopLoss --> Buffer number of SL for BUY int SLTPBuferforSELL_StopLoss=-1; //SLTPBuferforSELL_StopLoss --> Buffer number of SL for SELL int SLTPBuferforBUY_TakeProfit=-1; //SLTPBuferforBUY_TakeProfit --> Buffer number of TP for BUY int SLTPBuferforSELL_TakeProfit=-1; //SLTPBuferforSELL_TakeProfit --> Buffer number of TP for SELL. // // Step MT5 11 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для получения стоплоссов и тейкпрофитов. Заполняем буферы данных // Here we create our signal for positions closing. Fill in the data buffers // ########################################################################### #ifdef __MQL5__ if(SLTPBuferforBUY_StopLoss!=-1) if(xCustomCopyBufferMT5(h_custom_for_SLTP,SLTPBuferforBUY_StopLoss,StartCopyI,3+ShiftIndicator,custom_buffer_for_SL_BUY)<3+ShiftIndicator)return(0); if(SLTPBuferforSELL_StopLoss!=-1) if(xCustomCopyBufferMT5(h_custom_for_SLTP,SLTPBuferforSELL_StopLoss,StartCopyI,3+ShiftIndicator,custom_buffer_for_SL_SELL)<3+ShiftIndicator)return(0); if(SLTPBuferforBUY_TakeProfit!=-1) if(xCustomCopyBufferMT5(h_custom_for_SLTP,SLTPBuferforBUY_TakeProfit,StartCopyI,3+ShiftIndicator,custom_buffer_for_TP_BUY)<3+ShiftIndicator)return(0); if(SLTPBuferforSELL_TakeProfit!=-1) if(xCustomCopyBufferMT5(h_custom_for_SLTP,SLTPBuferforSELL_TakeProfit,StartCopyI,3+ShiftIndicator,custom_buffer_for_TP_SELL)<3+ShiftIndicator)return(0); #endif // Step MT4 11 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для получения стоплоссов и тейкпрофитов. Заполняем буферы данных // Here we create our signal for positions closing. Fill in the data buffers // ########################################################################### #ifdef __MQL4__ int inum=0; if(IndicatorName!="") { if(SLTPBuferforBUY_StopLoss!=-1) { ArrayResize(custom_buffer_for_SL_BUY,3+ShiftIndicator); for(inum=0;inum<3+ShiftIndicator; inum++) custom_buffer_for_SL_BUY[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/SLTPBuferforBUY_StopLoss,StartCopyI+inum); } if(SLTPBuferforSELL_StopLoss!=-1) { ArrayResize(custom_buffer_for_SL_SELL,3+ShiftIndicator); for(inum=0;inum<3+ShiftIndicator; inum++) custom_buffer_for_SL_SELL[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/SLTPBuferforSELL_StopLoss,StartCopyI+inum); } if(SLTPBuferforBUY_TakeProfit!=-1) { ArrayResize(custom_buffer_for_TP_BUY,3+ShiftIndicator); for(inum=0;inum<3+ShiftIndicator; inum++) custom_buffer_for_TP_BUY[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/SLTPBuferforBUY_TakeProfit,StartCopyI+inum); } if(SLTPBuferforSELL_TakeProfit!=-1) { ArrayResize(custom_buffer_for_TP_SELL,3+ShiftIndicator); for(inum=0;inum<3+ShiftIndicator; inum++) custom_buffer_for_TP_SELL[inum]=iCustom(StrategySymbolString,StrategyTimeFrame,IndicatorName,/* Здесь можно вставить настройки индикатора, через запятую*/SLTPBuferforSELL_TakeProfit,StartCopyI+inum); } } #endif // Step MT4 12 #################################################################### // Step MT5 12 #################################################################### // Эта часть кода для программирования своей стратегии в открытом коде // This part of the code for programming your strategy in open source // // Здесь создаем наш сигнал для получения стоплоссов и тейкпрофитов. Здесь пишем нашу стратегию, // Here we create our signal for positions closing. Here we write our strategy, // ########################################################################### if(type==1 && SLTPBuferforBUY_StopLoss!=-1) if(custom_buffer_for_SL_BUY[ShiftIndicator]!=EMPTY_VALUE && custom_buffer_for_SL_BUY[ShiftIndicator]>0) return(custom_buffer_for_SL_BUY[ShiftIndicator]); if(type==2 && SLTPBuferforBUY_TakeProfit!=-1) if(custom_buffer_for_TP_BUY[ShiftIndicator]!=EMPTY_VALUE && custom_buffer_for_TP_BUY[ShiftIndicator]>0) return(custom_buffer_for_TP_BUY[ShiftIndicator]); if(type==3 && SLTPBuferforSELL_StopLoss!=-1) if(custom_buffer_for_SL_SELL[ShiftIndicator]!=EMPTY_VALUE && custom_buffer_for_SL_SELL[ShiftIndicator]>0) return(custom_buffer_for_SL_SELL[ShiftIndicator]); if(type==4 && SLTPBuferforSELL_TakeProfit!=-1) if(custom_buffer_for_TP_SELL[ShiftIndicator]!=EMPTY_VALUE && custom_buffer_for_TP_SELL[ShiftIndicator]>0) return(custom_buffer_for_TP_SELL[ShiftIndicator]); // Конец шага ########################################################################### } return(0); } // Step MT4 13 #################################################################### // Step MT5 13 #################################################################### // Это все, что нужно было сделать для программирования своей стратегии // This is all you need to do to program your strategy. // // Сохраните этот файл в папке Индикаторов вашего терминала (ex5 для MT5 и ex4 для MT4) // Save this file in the Indicators folder of your terminal (ex5 for MT5 and ex4 for MT4) // // Укажите имя этого файла индикатора в параметрах SignalNameIndicator, CloseNameIndicator, FilterNameIndicator, SLTPNameIndicator // Specify the name of this indicator file in the SignalNameIndicator, CloseNameIndicator, FilterNameIndicator, SLTPNameIndicator parameters // // Укажите номера буферов и остальные параметры, подробнее в нашей инструкции https://www.expforex.com/publ/4-1-0-204 // Specify the buffer numbers and other parameters, more details in our instructions https://www.expforex.com/publ/11-1-0-207 // ########################################################################### // Это конец файла, который Вы можете изменить. Изменять все, что ниже этой строчки ЗАПРЕЩЕНО! // This is the end of the file you can change. Changing everything below this line is NOT ALLOWED! //+------------------------------------------------------------------+ // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // **************************************************************************************************** // ==================================================================================================== // Эту часть кода Не изменять! // Do not change this part of the code! // START // Версия советника // Version of EA #define versionea "18.988" // Принадлежность к терминалу. Не изменять! // Belonging to the terminal. Do not change! #ifdef __MQL5__ #define MT "MT5" #endif #ifdef __MQL4__ #define MT "MT4" #endif #define defEANAME "Ind-The xCustomEA" // Ссылка на полную инструкцию // Link to the full instruction #define linkTOfull "www.expforex.com/publ/4-1-0-204" #property copyright "2008-2018, www.expforex.com" // Описание советника! // description! #property description defEANAME+" for "+MT+". \nMore information on www.expforex.com \nThank`s\nall my products there: https://www.mql5.com/ru/users/vladon/seller#products\n\nPlease add your review of this product in the section REVIEW on the product page." // Остальные свойства программы. Не изменять! // Other properties of the program. Do not change! #property version versionea #property link "http://"+linkTOfull #property indicator_chart_window #property indicator_buffers 10 #property indicator_plots 10 //--- plot SignalBuy #property indicator_label1 "SignalBuy(0)" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 3 //--- plot SignalSell #property indicator_label2 "SignalSell(1)" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 3 //--- plot FilterBuy #property indicator_label3 "FilterBuy(2)" #property indicator_type3 DRAW_LINE #property indicator_color3 clrAquamarine #property indicator_style3 STYLE_SOLID #property indicator_width3 2 //--- plot FilterSell #property indicator_label4 "FilterSell(3)" #property indicator_type4 DRAW_LINE #property indicator_color4 clrSalmon #property indicator_style4 STYLE_SOLID #property indicator_width4 2 //--- plot CloseBuy #property indicator_label5 "CloseBuy(4)" #property indicator_type5 DRAW_ARROW #property indicator_color5 clrYellow #property indicator_style5 STYLE_SOLID #property indicator_width5 3 //--- plot CloseSell #property indicator_label6 "CloseSell(5)" #property indicator_type6 DRAW_ARROW #property indicator_color6 clrYellow #property indicator_style6 STYLE_SOLID #property indicator_width6 3 //--- plot TPBuy #property indicator_label7 "TPBuy(6)" #property indicator_type7 DRAW_LINE #property indicator_color7 clrLightGreen #property indicator_style7 STYLE_DASHDOT #property indicator_width7 1 //--- plot SLBuy #property indicator_label8 "SLBuy(7)" #property indicator_type8 DRAW_LINE #property indicator_color8 clrLightPink #property indicator_style8 STYLE_DASHDOT #property indicator_width8 1 //--- plot TPSell #property indicator_label9 "TPSell(8)" #property indicator_type9 DRAW_LINE #property indicator_color9 clrLightGreen #property indicator_style9 STYLE_DASHDOT #property indicator_width9 1 //--- plot SLSell #property indicator_label10 "SLSell(9)" #property indicator_type10 DRAW_LINE #property indicator_color10 clrLightPink #property indicator_style10 STYLE_DASHDOT #property indicator_width10 1 //--- indicator buffers double SignalBuyBuffer[]; double SignalSellBuffer[]; double FilterBuyBuffer[]; double FilterSellBuffer[]; double CloseBuyBuffer[]; double CloseSellBuffer[]; double SLBuyBuffer[]; double SLSellBuffer[]; double TPBuyBuffer[]; double TPSellBuffer[]; // --- var string StrategySymbolString=""; string InfoAboutSignal=""; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // END // Эту часть кода Не изменять! // Do not change this part of the code! // ==================================================================================================== // **************************************************************************************************** // **************************************************************************************************** // ==================================================================================================== // Эту часть кода Не изменять! // Do not change this part of the code! // START //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { if(StrategySymbol!="")StrategySymbolString=StrategySymbol; else StrategySymbolString=Symbol(); //--- indicator buffers mapping SetIndexBuffer(0,SignalBuyBuffer,INDICATOR_DATA); SetIndexBuffer(1,SignalSellBuffer,INDICATOR_DATA); SetIndexBuffer(2,FilterBuyBuffer,INDICATOR_DATA); SetIndexBuffer(3,FilterSellBuffer,INDICATOR_DATA); SetIndexBuffer(4,CloseBuyBuffer,INDICATOR_DATA); SetIndexBuffer(5,CloseSellBuffer,INDICATOR_DATA); SetIndexBuffer(6,TPBuyBuffer,INDICATOR_DATA); SetIndexBuffer(7,SLBuyBuffer,INDICATOR_DATA); SetIndexBuffer(8,TPSellBuffer,INDICATOR_DATA); SetIndexBuffer(9,SLSellBuffer,INDICATOR_DATA); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW #ifdef __MQL4__ SetIndexArrow(0,221); SetIndexArrow(1,222); SetIndexArrow(4,222); SetIndexArrow(5,221); SetIndexEmptyValue(0,0); SetIndexEmptyValue(1,0); SetIndexEmptyValue(2,0); SetIndexEmptyValue(3,0); SetIndexEmptyValue(4,0); SetIndexEmptyValue(5,0); SetIndexEmptyValue(6,0); SetIndexEmptyValue(7,0); SetIndexEmptyValue(8,0); SetIndexEmptyValue(9,0); #endif //--- setting a code from the Wingdings charset as the property of PLOT_ARROW PlotIndexSetInteger(0,PLOT_ARROW,221); PlotIndexSetInteger(1,PLOT_ARROW,222); PlotIndexSetInteger(4,PLOT_ARROW,222); PlotIndexSetInteger(5,PLOT_ARROW,221); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(7,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(8,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(9,PLOT_EMPTY_VALUE,0); //--- number of digits of indicator value IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- //--- setting buffer arrays as timeseries ArraySetAsSeries(SignalBuyBuffer,true); ArraySetAsSeries(SignalSellBuffer,true); ArraySetAsSeries(FilterBuyBuffer,true); ArraySetAsSeries(FilterSellBuffer,true); ArraySetAsSeries(CloseBuyBuffer,true); ArraySetAsSeries(CloseSellBuffer,true); ArraySetAsSeries(SLBuyBuffer,true); ArraySetAsSeries(SLSellBuffer,true); ArraySetAsSeries(TPBuyBuffer,true); ArraySetAsSeries(TPSellBuffer,true); IndicatorInit(); return(INIT_SUCCEEDED); } // END // Эту часть кода Не изменять! // Do not change this part of the code! // ==================================================================================================== // **************************************************************************************************** // **************************************************************************************************** // ==================================================================================================== // Эту часть кода Не изменять! // Do not change this part of the code! // START int BarToCalculate; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- variables //--- check for bars count if(rates_total1) BarToCalculate=prev_calculated-1; else BarToCalculate=0; BarToCalculate=rates_total-prev_calculated-1; if(BarToCalculate<=0)BarToCalculate=1+StrategyShift; if(BarToCalculate>BarsToShow)BarToCalculate=BarsToShow; if(Bars(StrategySymbolString,StrategyTimeFrame)==0)return(0); // Comment("prev_calculated="+prev_calculated+" rates_total="+rates_total+" BarToCalculate="+BarToCalculate); //--- main cycle for(int i=BarToCalculate-StrategyShift; i>=0 && !IsStopped(); i--) { // Comment("i="+i+" prev_calculated="+prev_calculated+" rates_total="+rates_total+" BarToCalculate="+BarToCalculate); #ifdef __MQL5__ double High[]; int count=1; // сколько копируем ArraySetAsSeries(High,true); CopyHigh(_Symbol,_Period,0,Bars(StrategySymbolString,StrategyTimeFrame),High); double Low[]; ArraySetAsSeries(Low,true); CopyLow(_Symbol,_Period,0,Bars(StrategySymbolString,StrategyTimeFrame),Low); #endif int Signal=0; SignalSellBuffer[i+StrategyShift]=0;SignalBuyBuffer[i+StrategyShift]=0; FilterSellBuffer[i+StrategyShift]=0;FilterBuyBuffer[i+StrategyShift]=0; CloseBuyBuffer[i+StrategyShift]=0;CloseSellBuffer[i+StrategyShift]=0; SLBuyBuffer[i+StrategyShift]=0;SLSellBuffer[i+StrategyShift]=0; TPBuyBuffer[i+StrategyShift]=0;TPSellBuffer[i+StrategyShift]=0; // Проверяем сигналы if(StrategyType==1 || StrategyType==0) { Signal=IndicatorSignal(StrategyNumber,StrategySymbolString,StrategyTimeFrame,StrategyShift,i); if(Signal==1) {SignalBuyBuffer[i+StrategyShift]=Low[i+StrategyShift]-(High[i+StrategyShift]-Low[i+StrategyShift]);SignalSellBuffer[i+StrategyShift]=0;} if(Signal==-1) {SignalSellBuffer[i+StrategyShift]=High[i+StrategyShift]+(High[i+StrategyShift]-Low[i+StrategyShift]);SignalBuyBuffer[i+StrategyShift]=0;} if(Signal==0) {SignalSellBuffer[i+StrategyShift]=0;SignalBuyBuffer[i+StrategyShift]=0;} if(Signal==-9) {SignalSellBuffer[i+StrategyShift]=High[i+StrategyShift]+(High[i+StrategyShift]-Low[i+StrategyShift]);SignalBuyBuffer[i+StrategyShift]=Low[i+StrategyShift]-(High[i+StrategyShift]-Low[i+StrategyShift]);} if(Signal==-100) {SignalSellBuffer[i+StrategyShift]=-100;SignalBuyBuffer[i+StrategyShift]=-100;} } // Проверяем фильтры if(StrategyType==2 || StrategyType==0) { Signal=FILTERIndicatorSignal(StrategyNumber,StrategySymbolString,StrategyTimeFrame,StrategyShift,i); if(Signal==1) { FilterBuyBuffer[i+StrategyShift]=Low[i+StrategyShift];FilterSellBuffer[i+StrategyShift]=0;} if(Signal==-1) { FilterSellBuffer[i+StrategyShift]=High[i+StrategyShift];FilterBuyBuffer[i+StrategyShift]=0;} if(Signal==0) {FilterSellBuffer[i+StrategyShift]=0;FilterBuyBuffer[i+StrategyShift]=0;} if(Signal==-100) {FilterSellBuffer[i+StrategyShift]=-100;FilterBuyBuffer[i+StrategyShift]=-100;} } // Проверяем сигналы на закрытие if(StrategyType==3 || StrategyType==0) { Signal=CLOSEIndicatorSignal(StrategyNumber,StrategySymbolString,StrategyTimeFrame,StrategyShift,i); if(Signal==1) {CloseBuyBuffer[i+StrategyShift]=Low[i+StrategyShift]-(High[i+StrategyShift]-Low[i+StrategyShift]);CloseSellBuffer[i+StrategyShift]=0;} if(Signal==-1) {CloseSellBuffer[i+StrategyShift]=High[i+StrategyShift]+(High[i+StrategyShift]-Low[i+StrategyShift]);CloseBuyBuffer[i+StrategyShift]=0;} if(Signal==0) {CloseSellBuffer[i+StrategyShift]=0;CloseBuyBuffer[i+StrategyShift]=0;} if(Signal==-9) {CloseSellBuffer[i+StrategyShift]=High[i+StrategyShift]+(High[i+StrategyShift]-Low[i+StrategyShift]);CloseBuyBuffer[i+StrategyShift]=Low[i+StrategyShift]-(High[i+StrategyShift]-Low[i+StrategyShift]);} if(Signal==-100) {CloseSellBuffer[i+StrategyShift]=-100;CloseBuyBuffer[i+StrategyShift]=-100;} } // Проверяем SL TP if(StrategyType==4 || StrategyType==0) { SLBuyBuffer[i+StrategyShift]=SLTPIndicatorSignal(StrategyNumber,StrategySymbolString,StrategyTimeFrame,StrategyShift,i,1); TPBuyBuffer[i+StrategyShift]=SLTPIndicatorSignal(StrategyNumber,StrategySymbolString,StrategyTimeFrame,StrategyShift,i,2); SLSellBuffer[i+StrategyShift]=SLTPIndicatorSignal(StrategyNumber,StrategySymbolString,StrategyTimeFrame,StrategyShift,i,3); TPSellBuffer[i+StrategyShift]=SLTPIndicatorSignal(StrategyNumber,StrategySymbolString,StrategyTimeFrame,StrategyShift,i,4); } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // END // Эту часть кода Не изменять! // Do not change this part of the code! // ==================================================================================================== // **************************************************************************************************** //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int xCustomCopyBufferMT5( int indicator_handle, // indicator handle int buffer_num, // indicator buffer number int start_pos, // start position int count, // amount to copy double &buffer[]// target array to copy ) { int AmountElements=-1; #ifdef __MQL5__ AmountElements=CopyBuffer(indicator_handle,buffer_num,start_pos,count,buffer); if(AmountElements