TOP комментариев

0
март завершился, подгонял в ручную настройки. Раньше торговал в ручную только евро и фунт оказалось, что эта стратегия подходит для многих инструментов.
avatar

MihaMM

  • 1 апреля 2026, 18:57
0
//+------------------------------------------------------------------+
//| message |
//+------------------------------------------------------------------+
string SignalMessage(int signalType, datetime barTime)
{
string side = «BUY»;
if(signalType < 0) side = «SELL»;

return(«ADX/Stoch » + side +
" | " + Symbol() +
" | TF=" + IntegerToString(Period()) +
" | bar=" + TimeToStr(barTime, TIME_DATE|TIME_MINUTES));
}

//+------------------------------------------------------------------+
//| evaluate main signal on closed bar |
//| returns: 1=buy, -1=sell, 0=none |
//+------------------------------------------------------------------+
int EvaluateMainSignal(int barIndex)
{
if(barIndex < 1) return(0);
if(barIndex + 1 >= Bars) return(0);
if(!al) return(0);

double a = iStochastic(NULL, 0, Kperiod, Dperiod, slowing, method, price_field, MODE_MAIN, barIndex);
double b = iStochastic(NULL, 0, Kperiod, Dperiod, slowing, method, price_field, MODE_MAIN, barIndex + 1);

double po = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_PLUSDI, barIndex);
double p1 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_PLUSDI, barIndex + 1);
double mo = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MINUSDI, barIndex);
double m1 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MINUSDI, barIndex + 1);

bool buySignal = false;
bool sellSignal = false;

if(iBuy)
{
if(a > b && a < 80 && po > p1 && po > mo)
buySignal = true;
}

if(iSell)
{
if(a < b && a > 20 && mo > m1 && po < mo)
sellSignal = true;
}

if(buySignal && !sellSignal) return(1);
if(sellSignal && !buySignal) return(-1);

return(0);
}

//+------------------------------------------------------------------+
//| draw history arrows |
//+------------------------------------------------------------------+
void BuildHistoryArrows()
{
if(!DrawHistoricalArrows) return;
if(Bars < 10) return;

int maxBar = Bars — 2; // because barIndex+1 is used
if(HistoryBarsToDraw > 0 && HistoryBarsToDraw < maxBar)
maxBar = HistoryBarsToDraw;

for(int bar = maxBar; bar >= 1; bar--)
{
int sig = EvaluateMainSignal(bar);
if(sig != 0)
CreatePriceArrow(sig, bar);
}

WindowRedraw();
}

//+------------------------------------------------------------------+
//| start |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;

int limit = Bars — counted_bars;
if(counted_bars == 0) limit -= 2;
if(limit < 0) limit = 0;

//---- fill stochastic plot buffers
for(int q = limit; q >= 0; q--)
{
Stoch[q] = iStochastic(NULL, 0, Kperiod, Dperiod, slowing, method, price_field, MODE_MAIN, q);
Signal[q] = iStochastic(NULL, 0, Kperiod, Dperiod, slowing, method, price_field, MODE_SIGNAL, q);
}

//---- manual ADX calculation for subwindow buffers
int starti = limit;
int i = starti;

while(i >= 0)
{
double price_low = Low[i];
double price_high = High[i];

double pdm = price_high — High[i + 1];
double mdm = Low[i + 1] — price_low;

if(pdm < 0) pdm = 0;
if(mdm < 0) mdm = 0;

if(pdm == mdm)
{
pdm = 0;
mdm = 0;
}
else if(pdm < mdm) pdm = 0;
else if(mdm < pdm) mdm = 0;

double num1 = MathAbs(price_high — price_low);
double num2 = MathAbs(price_high — Close[i + 1]);
double num3 = MathAbs(price_low — Close[i + 1]);

double tr = MathMax(num1, num2);
tr = MathMax(tr, num3);

if(tr == 0.0)
{
PlusSdiBuffer[i] = 0.0;
MinusSdiBuffer[i] = 0.0;
}
else
{
PlusSdiBuffer[i] = 100.0 * pdm / tr;
MinusSdiBuffer[i] = 100.0 * mdm / tr;
}

i--;
}

for(i = 0; i <= limit; i++)
PlusDiBuffer[i] = iMAOnArray(PlusSdiBuffer, Bars, ADXPeriod, 0, MODE_EMA, i);

for(i = 0; i <= limit; i++)
MinusDiBuffer[i] = iMAOnArray(MinusSdiBuffer, Bars, ADXPeriod, 0, MODE_EMA, i);

i = starti;
while(i >= 0)
{
double div = MathAbs(PlusDiBuffer[i] + MinusDiBuffer[i]);
if(div == 0.0) TempBuffer[i] = 0.0;
else TempBuffer[i] = 100.0 * (MathAbs(PlusDiBuffer[i] — MinusDiBuffer[i]) / div);
i--;
}

for(i = 0; i < limit; i++)
ADXBuffer[i] = iMAOnArray(TempBuffer, Bars, ADXPeriod, 0, MODE_EMA, i);

//---- one-time rebuild of history on load / TF change
if(!g_historyBuilt)
{
BuildHistoryArrows();
g_historyBuilt = true;
}

//---- live signal only on new bar (closed candle signal = bar 1)
if(!IsNewBar())
return(0);

int sig = EvaluateMainSignal(1);

if(sig != 0)
{
datetime signalBarTime = Time[1];

if(!(g_lastAlertBarTime == signalBarTime && g_lastAlertType == sig))
{
CreatePriceArrow(sig, 1);
SendAllNotifications(SignalMessage(sig, signalBarTime));

g_lastAlertBarTime = signalBarTime;
g_lastAlertType = sig;
}
}

return(0);
}
//+------------------------------------------------------------------+
avatar

Kadosh123456789

  • 31 марта 2026, 14:11
0
//+------------------------------------------------------------------+
//| Delete all arrows created by this indicator on this chart |
//| We intentionally remove all periods for this symbol, so when |
//| timeframe changes, old arrows disappear and new TF arrows build. |
//+------------------------------------------------------------------+
void DeleteMyArrows()
{
string prefix = ArrowPrefix + "_" + Symbol() + "_";

for(int i = ObjectsTotal() — 1; i >= 0; i--)
{
string objName = ObjectName(i);
if(StringFind(objName, prefix, 0) == 0)
ObjectDelete(objName);
}
}

//+------------------------------------------------------------------+
//| init |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(8);

SetIndexBuffer(0, ADXBuffer);
SetIndexBuffer(1, PlusDiBuffer);
SetIndexBuffer(2, MinusDiBuffer);
SetIndexBuffer(5, PlusSdiBuffer);
SetIndexBuffer(6, MinusSdiBuffer);
SetIndexBuffer(7, TempBuffer);

IndicatorShortName(«sA(» + IntegerToString(ADXPeriod) + ")");
SetIndexLabel(0, «ADX»);
SetIndexLabel(1, "+DI");
SetIndexLabel(2, "-DI");

SetIndexDrawBegin(0, ADXPeriod);
SetIndexDrawBegin(1, ADXPeriod);
SetIndexDrawBegin(2, ADXPeriod);

SetIndexStyle(3, DRAW_LINE);
SetIndexDrawBegin(3, 0);
SetIndexBuffer(3, Stoch);

SetIndexStyle(4, DRAW_LINE, STYLE_DOT);
SetIndexDrawBegin(4, 0);
SetIndexBuffer(4, Signal);

if(ClearStaleArrowsOnInit)
DeleteMyArrows();

return(0);
}

//+------------------------------------------------------------------+
//| deinit |
//+------------------------------------------------------------------+
int deinit()
{
if(DeleteArrowsOnDeinit)
DeleteMyArrows();

return(0);
}

//+------------------------------------------------------------------+
//| pip helper |
//+------------------------------------------------------------------+
double PipValue()
{
if(Digits == 3 || Digits == 5) return(Point * 10.0);
return(Point);
}

//+------------------------------------------------------------------+
//| new bar |
//+------------------------------------------------------------------+
bool IsNewBar()
{
if(g_lastBarTime == 0)
{
g_lastBarTime = Time[0];
return(false);
}

if(Time[0] != g_lastBarTime)
{
g_lastBarTime = Time[0];
return(true);
}

return(false);
}

//+------------------------------------------------------------------+
//| notify |
//+------------------------------------------------------------------+
void SendAllNotifications(string message)
{
if(PopupAlert) Alert(message);
if(PushNotification) SendNotification(message);
if(EmailNotification) SendMail(«MT4 Signal » + Symbol(), message);
if(SoundNotification) PlaySound(SoundFileName);
}

//+------------------------------------------------------------------+
//| arrow object name |
//+------------------------------------------------------------------+
string ArrowObjectName(int signalType, datetime t)
{
string side = «BUY»;
if(signalType < 0) side = «SELL»;

return(
ArrowPrefix + "_" +
Symbol() + "_" +
IntegerToString(Period()) + "_" +
side + "_" +
IntegerToString((int)t)
);
}

//+------------------------------------------------------------------+
//| create arrow on main chart |
//+------------------------------------------------------------------+
void CreatePriceArrow(int signalType, int barIndex)
{
if(!DrawSignalArrows) return;
if(barIndex < 0 || barIndex >= Bars) return;

datetime t = Time[barIndex];
string name = ArrowObjectName(signalType, t);

if(ObjectFind(name) != -1) return;

double shift = ArrowOffsetPips * PipValue();
double price;
color clr;
int arrowCode;

if(signalType > 0)
{
price = Low[barIndex] — shift;
clr = BuyArrowColor;
arrowCode = BuyArrowCode;
}
else
{
price = High[barIndex] + shift;
clr = SellArrowColor;
arrowCode = SellArrowCode;
}

if(ObjectCreate(name, OBJ_ARROW, 0, t, price))
{
ObjectSet(name, OBJPROP_ARROWCODE, arrowCode);
ObjectSet(name, OBJPROP_COLOR, clr);
ObjectSet(name, OBJPROP_WIDTH, 1);
ObjectSet(name, OBJPROP_BACK, false);
}
}
avatar

Kadosh123456789

  • 31 марта 2026, 14:11
0
Не дал мне целым кодом добавить. Частями леплю))
Прикрутил еще стрелки. Картинка жуть, аж в глазах рябит.
//+------------------------------------------------------------------+
//| ADX_z_Stochastic_alerts_history_arrows_tfclean.mq4 |
//| History arrows + live bar-close arrows, clean on TF change |
//+------------------------------------------------------------------+
#property strict
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 DodgerBlue
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_color5 Magenta
#property indicator_maximum 100
#property indicator_minimum 0

//---- original ADX inputs
extern bool al = true;
extern bool iBuy = true;
extern bool iSell = true;
extern bool pDi_Uv = false;
extern bool pDi_Um = false;
extern bool mDi_Uv = false;
extern bool mDi_Um = false;
extern bool mcb = false;
extern double mb = 20;
extern bool mcm = false;
extern double mm = 20;
extern bool pDI_c_b = false;
extern bool pDI_c_m = false;
extern double pDI = 20;
extern bool crs_up = false;
extern bool crs_dwn = false;
extern bool adx = false;
extern bool adxUm = false;
extern bool adxBol = false;
extern double ADX_u = 20;
extern int ADXPeriod = 14;

//---- original stochastic alert inputs (kept for compatibility)
extern bool lrt = false;
extern bool drebezg = false;
extern bool LevelMainMore = false;
extern double levelTop = 0;
extern bool LevelMainLess = false;
extern double levelLower = 0;
extern bool crossA = false;
extern bool crossB = false;
extern double level_high_A = 70;
extern double level_low_B = 30;

//---- stochastic settings
extern int Kperiod = 5;
extern int Dperiod = 3;
extern int slowing = 3;
extern int method = 0; // 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
extern int price_field = 0; // 0=High/Low, 1=Close/Close

//---- arrows / history
extern bool DrawSignalArrows = true;
extern bool DrawHistoricalArrows = true;
extern int HistoryBarsToDraw = 1500;
extern double ArrowOffsetPips = 3.0;
extern color BuyArrowColor = Lime;
extern color SellArrowColor = Red;
extern int BuyArrowCode = 233; // Wingdings up
extern int SellArrowCode = 234; // Wingdings down
extern string ArrowPrefix = «ADXStoHist»;

//---- notifications
extern bool PopupAlert = true;
extern bool PushNotification = false;
extern bool EmailNotification = false;
extern bool SoundNotification = false;
extern string SoundFileName = «alert.wav»;

//---- cleanup behavior
extern bool DeleteArrowsOnDeinit = true; // important: old TF arrows will be removed
extern bool ClearStaleArrowsOnInit = true; // remove leftovers before building new TF history

//---- buffers
double ADXBuffer[];
double PlusDiBuffer[];
double MinusDiBuffer[];
double PlusSdiBuffer[];
double MinusSdiBuffer[];
double TempBuffer[];

double Stoch[];
double Signal[];

//---- state
datetime g_lastBarTime = 0;
datetime g_lastAlertBarTime = 0;
int g_lastAlertType = 0; // 1=buy, -1=sell, 0=none
bool g_historyBuilt = false;
avatar

Kadosh123456789

  • 31 марта 2026, 14:10
0
Спасибо! Как будет время, займусь тестированием.
avatar

Oks

  • 27 марта 2026, 09:04
0
бот смотрит не на Н4

Бот смотрит именно на Н4, и это легко проверить если запустить советник в тестере на Н4.Советник на этом таймфрейме не откроет ни одной сделки, а на меньших тайфреймах открывает.
avatar

alex30774

  • 26 марта 2026, 16:43