Привет. Посмотри в коде советника 1.62. Он там интегрирован. Только реальной пользы от него я еще не обнаружил.
Кажется, этот советник не любит «рано» закрывать ордера. Пока самое субъективное — Не включать.
//************************************************************************************************/
bool InTime() //------- Узнаем, подходит ли текущее время для торговли ----------
{
if(StartTradeHour==0 && StartTradeMinute==0 && EndTradeHour==0 && EndTradeMinute==0)
return(true);
int Start = StartTradeHour*60+StartTradeMinute;
int Stop = EndTradeHour*60+EndTradeMinute;
if ( Start > Stop)
return (false);
datetime CurrentTime = TimeCurrent(); // текущее время
datetime StartTime = StrToTime(TimeToStr(TimeCurrent(),TIME_DATE)+" "+(string)StartTradeHour+":"+(string)StartTradeMinute);// время старта торгов
datetime StopTime = StrToTime(TimeToStr(TimeCurrent(),TIME_DATE)+" "+(string)EndTradeHour+":"+(string)EndTradeMinute); // время закрытия торгов
if(StartTime<StopTime && StartTime<=CurrentTime && CurrentTime<=StopTime)
return (true);
if(StartTime>StopTime && (CurrentTime>=StartTime || CurrentTime<=StopTime))
return (true);
return (false);
}
//************************************************************************************************/
<code> //+------------+-----------------------------------------------------+ //| v.12.01.25 | Up and Down.mq4 | //| Copyright © 2025, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2025, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_separate_window #property indicator_buffers 3 #property indicator_style1 STYLE_SOLID #property indicator_width1 2 #property indicator_style2 STYLE_SOLID #property indicator_color2 clrRed #property indicator_width2 2 #property indicator_style3 STYLE_SOLID #property indicator_color3 clrBlue #property indicator_width3 3 #property indicator_level1 0 #property indicator_minimum -3 #property indicator_maximum 3 #define PREFIX "xxx" extern int period = 14; extern double Rol = 1.15; // от 0 до 3 extern bool Arrow = true; extern int ArrowSize = 0; extern int SIGNAL_BAR = 1; extern color clArrowBuy = Blue; extern color clArrowSell = Red; double ExtBuffer0[]; double ExtBufferUp[]; double ExtBufferDn[]; // ------------------------------------------------------------------------------------------------------------- int init() { SetIndexBuffer(0,ExtBuffer0); SetIndexStyle(0,DRAW_NONE); SetIndexBuffer(1,ExtBufferUp); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,clrRed); SetIndexBuffer(2,ExtBufferDn); SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2,clrBlue); IndicatorShortName("Up and Down Histo"); return(0); } // ------------------------------------------------------------------------------------------------------------- int deinit() { for (int i = ObjectsTotal()-1; i >= 0; i--) if (StringSubstr(ObjectName(i), 0, StringLen(PREFIX)) == PREFIX) ObjectDelete(ObjectName(i)); return(0); } // ------------------------------------------------------------------------------------------------------------- int start() { int limit, counted_bars; double Value = 0, // prev Value1 = 0, // current Value2 = 0, // old Fish = 0, // prev Fish1 = 0, // current Fish2 = 0, // old MinL = 0, MaxH = 0, price; counted_bars = IndicatorCounted(); if (counted_bars > 0) counted_bars--; limit = Bars - counted_bars; for(int i=0; i<limit; i++) { MaxH = High[iHighest(NULL,0,MODE_CLOSE,period,i)]; MinL = Low[iLowest(NULL,0,MODE_CLOSE,period,i)]; price = (Open[i]+ Close[i])/2; if(MaxH-MinL == 0) Value = 0.33*2*(0-0.5) + 0.67*Value1; else Value = 0.33*2*((price-MaxH)/(MinL-MaxH)-0.5) + 0.67*Value1; Value=MathMin(MathMax(Value,-0.999),0.999); if(1-Value == 0) ExtBuffer0[i] = 0.5+0.5*Fish1; else ExtBuffer0[i] = 0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1; if(ExtBuffer0[i]>=0) { ExtBufferUp[i] = ExtBuffer0[i]; ExtBufferDn[i] = EMPTY_VALUE; } else { ExtBufferDn[i] = ExtBuffer0[i]; ExtBufferUp[i] = EMPTY_VALUE; } Value1=Value; Fish1=ExtBuffer0[i]; } //--- int counted_bars2 = IndicatorCounted(); if (counted_bars2 > 0) counted_bars2--; int limit2 = Bars - counted_bars2; for(int j = limit2;j >= 0;j--) { if (Arrow) { if (ExtBuffer0[j+SIGNAL_BAR+1] > Rol && ExtBuffer0[j+SIGNAL_BAR] < Rol) manageArr(j+1, clArrowBuy, 108, false); if (ExtBuffer0[j+SIGNAL_BAR+1] < -Rol && ExtBuffer0[j+SIGNAL_BAR] > -Rol) manageArr(j+1, clArrowSell, 108, true ); //--- if (ExtBuffer0[j+SIGNAL_BAR+1] > -Rol && ExtBuffer0[j+SIGNAL_BAR+1] < Rol) { if (ExtBuffer0[j+SIGNAL_BAR+3] > ExtBuffer0[j+SIGNAL_BAR+2] && ExtBuffer0[j+SIGNAL_BAR+2] > ExtBuffer0[j+SIGNAL_BAR+1] && ExtBuffer0[j+SIGNAL_BAR+1] < ExtBuffer0[j+SIGNAL_BAR]) manageArr(j+1, clArrowSell, 108, true ); if (ExtBuffer0[j+SIGNAL_BAR+3] < ExtBuffer0[j+SIGNAL_BAR+2] && ExtBuffer0[j+SIGNAL_BAR+2] < ExtBuffer0[j+SIGNAL_BAR+1] && ExtBuffer0[j+SIGNAL_BAR+1] > ExtBuffer0[j+SIGNAL_BAR]) manageArr(j+1, clArrowBuy, 108, false); } } } return(0); } // ------------------------------------------------------------------------------------------------------------- void manageArr(int j, color clr, int theCode, bool up) { string objName = PREFIX + Time[j]; double gap = 2*iATR(NULL,0,9,j)/4.0; ObjectCreate(objName, OBJ_ARROW,0,Time[j],0); ObjectSet (objName, OBJPROP_COLOR, clr); ObjectSet (objName, OBJPROP_ARROWCODE,theCode); ObjectSet (objName, OBJPROP_WIDTH,ArrowSize); if ( up ) { ObjectSet(objName,OBJPROP_PRICE1,Open[j]+gap); // Alert("Open OP_SELL"); } else { ObjectSet(objName,OBJPROP_PRICE1,Close[j] -gap); // Alert("Open OP_BUY"); } } // ------------------------------------------------------------------------------------------------------------- </code>
kvashnin007