Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 975

 
Alexandr Sokolov:

I had an idea, I need a lot of cycles, so I decided to check the speed this way

... As a result MT5 stops working, glitches and I have to close it via task manager


Is this a problem in the power of my pc or something else?


*PS - I want to try to write a neural network, and there will be billions of cycles, and here I'm going by a million.

But I caught it twice without any glitches, but if I repeat it again it glitches (script in attached files)

Files:
zsbh.mq5  7 kb
 
Alexandr Sokolov:

I had an idea, I need a lot of cycles, so I decided to check the speed this way

... As a result MT5 stops working, glitches and I have to close it via task manager


Is this a problem in the power of my pc or something else?


*PS - I want to try to write a neural network, and it will be billions of cycles, and here I'm going to lie down by a million.

don't try it :-)

or rather, write something simpler first

Because the problem is in the lack of understanding of what you're writing and how it works in general.

 
Maxim Kuznetsov:

don't try it :-)

or rather, write something simple first

because the problem is in the lack of understanding of what you're writing and how it works in general.

This script is not a neural network)) I made it to see how fast a million cycles go by


But why is the terminal glitchy? The script starts working (digits are running), but I don't get to the end (at least for me)

 
Good afternoon, gentlemen programmers. Please advise. I am trying to write an arrow indicator based on reversal patterns and others. It seems to be OK. However, it only considers the first 2 candlesticks instead of 4. When compiling, the editor swears about possible loss of accuracy when assigning different data types. And only on iVolume. Thanks in advance.
 
35vas35:
Good afternoon, gentlemen programmers. Please advise. I am trying to write an arrow indicator based on reversal patterns and others. It seems to be OK. However, it only considers the first 2 candlesticks instead of 4. When compiling, the editor swears about possible loss of accuracy when assigning different data types. And only on iVolume. Thanks in advance.

Here.

 
Artyom Trishkin:

Here.

Here is the code for the indicator.
//+------------------------------------------------------------------+
//|                                                       Figaro.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2     
#property indicator_color1 Blue   
#property indicator_color2 Red    
double Buy[];                   
double Sell[];                  
#define  BUY 0
#define  SELL 1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{

SetIndexBuffer (0, Buy);
SetIndexBuffer (1, Sell);  

SetIndexEmptyValue (0, 0);
SetIndexEmptyValue (1, 0);

SetIndexStyle (0, DRAW_ARROW);
SetIndexStyle (1, DRAW_ARROW); 
SetIndexArrow(0, 233);  // Стрелка "вверх" для покупок
SetIndexArrow(1, 234);  // Стрелка "вниз" для продаж

IndicatorDigits (Digits);

IndicatorShortName ("FIGARO");

SetIndexLabel(0, "Покупаем");
SetIndexLabel(1, "Продаём");

return(INIT_SUCCEEDED);

}
//+------------------------------------------------------------------+
//| 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[])
{

int counted_bars = IndicatorCounted();
int limit, signal;

if (counted_bars>0) 
counted_bars-- ;

limit=Bars-counted_bars;

for(int i = 2; i < limit; i++) 
{
signal = Signal(i-1);
if (signal == BUY)
{ 
Buy[i-1] = low[i-1];
}
else
if (signal == SELL)
{
Sell[i-1] = high[i-1];
}
}
return(rates_total); } 
//+------------------------------------------------------------------+
int Signal(int i)
{
     double O_1 = iOpen(Symbol(), 0, 1);
     double O_2 = iOpen(Symbol(), 0, 2);
     double O_3 = iOpen(Symbol(), 0, 3);
     double O_4 = iOpen(Symbol(), 0, 4);
     double C_1 = iClose(Symbol(), 0, 1);
     double C_2 = iClose(Symbol(), 0, 2);
     double C_3 = iClose(Symbol(), 0, 3);
     double C_4 = iClose(Symbol(), 0, 4);
     double H_1 = iHigh(Symbol(), 0, 1);
     double H_2 = iHigh(Symbol(), 0, 2);
     double L_1 = iLow(Symbol(), 0, 1);
     double L_2 = iLow(Symbol(), 0, 2);
     double S_1 = iVolume(NULL, 0, 1);
     double S_2 = iVolume(NULL, 0, 2);
     double S_3 = iVolume(NULL, 0, 3);
if ((O_1<C_1 && S_1>=8 && S_2==0 && O_3>C_3 && O_4>C_4 && (H_2-O_2)>=6 && (C_2-L_2)>=6) || (O_1<C_1 && S_1>=10 && O_2>C_2 && S_2>=8 && O_3>C_3 &&
O_4>C_4 && S_3>=8 && O_1<=C_2 && O_1<C_3 && O_2<C_1 && O_3<C_1) || (O_1<C_1 && O_2>C_2 && O_3>C_3 && O_4>C_4 && S_1<=1 && (O_1-L_1)>=5 && (H_1-C_1)<=2) || (O_1<C_1 && S_1>=10 &&
O_2>C_2 && O_3>C_3 && S_2>=10 && S_1>=S_2*0.6 && O_1<C_2 && (H_1-C_1)<=2 && (O_1-L_1)<=2 && (H_2-O_2)<=2 && (C_2-L_2)<=2) || (O_1<C_1 && S_1>=10 && O_2>C_2 &&
S_2>=8 && C_1<=C_2 && (H_1-C_1)<=2 && (O_1-L_1)<=2 && (H_2-O_2)<=2 && (C_2-L_2)<=2))
     
     return (BUY);
     
if ((O_1>C_1 && S_1>=8 && S_2==0 && O_3<C_3 && O_4<C_4 && (H_2-O_2)>=6 && (C_2-L_2)>=6) || (O_1>C_1 && S_1>=10 && O_2<C_2 && O_3<C_3 && O_4<C_4 &&
S_2>=8 && S_3>=8 && O_1>=C_2 && O_1>C_3 && O_2>C_1 && O_3>C_1) || (O_1>C_1 && O_2<C_2 && O_3<C_3 && O_4<C_4 && S_1<=1 && (C_1-L_1)>=5 && (H_1-O_1)<=2) || (O_1>C_1 && S_1>=10 && 
O_2<C_2 && O_3<C_3 && O_4<C_4 && S_2>=10 && S_1>=S_2*0.6 && O_1>C_2 && (H_1-O_1)<=2 && (C_1-L_1)<=2 && (H_2-C_2)<=2 && (O_2-L_2)<=2) || (O_1>C_1 && S_1>=10 && O_2<C_2 &&
O_3<C_3 && O_4<C_4 && S_2>=8 && C_1>=C_2 && (H_1-O_1)<=2 && (C_1-L_1)<=2 && (H_2-C_2)<=2 && (O_2-L_2)<=2))

     return (SELL);
     
     return(-1);
     
}
 

35vas35:
Вот код индикатора.

The problem is that as you can see on the chart, the volume of 3 candles from the buy signal is 3 points. But in the code the volume is prescribed from 8 and above.

 
35vas35:

The problem is that as you can see on the chart, the volume of 3 candles from the buy signal is 3 points. But in the code the volume is prescribed from 8 and above.

In the future, I want to attach a mailing or sms. I tried to write an EA with MACD, MA, and RSI indicators using this principle. There are few false signals. But I would like to control the process myself.
 
35vas35:
In the future, I want to link the newsletter to email or sms. I tried to write an EA with MACD, MA, and RSI indicators using this principle. There are few false signals. But I would like to control the process myself.
I used harami, two candle absorption, hammer, gap and veil, counterattack patterns as the basis.
Reason: