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

 
Nerd Trader #:
If you do it through an array, then check only the tickets of modified orders written into it against all the other ones.

If there is no error check when modifying, how can we be sure that the order has changed?

And if there is an error check, what is the point of the array?

 
EVGENII SHELIPOV #:

Makar has inserted code into the EA so far only to compare profit in currency and profit in pips as far as I understand it can be understood when these functions have zero values


Send me the file in your inbox
 

Can you tell me how to write a condition?

If a monthly/weekly/4-hourly candle has closed...

When the current chart is different.

 
Ivan Butko #:

Can you tell me how to write a condition?

If a monthly/weekly/4-hourly candle has closed...

When the current chart is different.

It's not clear what's needed...
 
artem artem #:

MakarFX, on that screenshot, which I attached, tested on EUR / USD - M 30 - all ticks - 01.08.21 to 03.09.21 - 26 orders were ( but I changed the constant from 4 to 8, I decided to look at a larger number of candles)

If we return the constant to 4 candlesticks then for the same period - then 35 orders, but the first order also comes in 2 orders earlier

Artem, I checked on the indicator readings and the opening is correct, but visually it shows differently...very strange

2021.10.10 19:13:35.904 2021.08.02 12:00:00  artem EURUSD,M30: BUY OK
2021.10.10 19:13:35.904 2021.08.02 12:00:00  artem EURUSD,M30: open #1  buy 0.01 EURUSD at 1.18854 sl: 1.18444 tp: 1.18954 ok
2021.10.10 19:13:35.904 2021.08.02 12:00:00  artem EURUSD,M30: 1.18829 / 1.18769 / 1.18780 / 1.18773 / 1.18746 / true / 0
2021.10.10 19:12:38.068 2021.08.02 11:30:00  artem EURUSD,M30: 1.18826 / 1.18769 / 1.18780 / 1.18764 / 1.18739 / true / 0
2021.10.10 19:11:38.087 2021.08.02 11:00:00  artem EURUSD,M30: 1.18794 / 1.18769 / 1.18780 / 1.18745 / 1.18726 / true / 0
2021.10.10 19:10:34.589 2021.08.02 10:30:00  artem EURUSD,M30: 1.18793 / 1.18771 / 1.18780 / 1.18738 / 1.18720 / true / 0
2021.10.10 19:09:03.560 2021.08.02 10:00:00  artem EURUSD,M30: 1.18775 / 1.18771 / 1.18780 / 1.18725 / 1.18712 / true / -1
2021.10.10 19:07:38.218 2021.08.02 09:30:00  artem EURUSD,M30: 1.18722 / 1.18771 / 1.18779 / 1.18700 / 1.18696 / true / -1
2021.10.10 19:06:21.547 2021.08.02 09:00:00  artem EURUSD,M30: 1.18711 / 1.18772 / 1.18779 / 1.18693 / 1.18692 / true / -1
2021.10.10 19:05:45.473 2021.08.02 08:30:00  artem EURUSD,M30: 1.18708 / 1.18774 / 1.18779 / 1.18690 / 1.18690 / false / -1
2021.10.10 19:05:07.243 2021.08.02 08:00:00  artem EURUSD,M30: 1.18702 / 1.18775 / 1.18779 / 1.18685 / 1.18688 / false / 1
2021.10.10 19:04:45.039 2021.08.02 07:30:00  artem EURUSD,M30: 1.18709 / 1.18777 / 1.18780 / 1.18685 / 1.18688 / false / 1
2021.10.10 19:04:22.852 2021.08.02 07:00:00  artem EURUSD,M30: 1.18700 / 1.18779 / 1.18780 / 1.18679 / 1.18685 / false / 1
2021.10.10 19:03:55.033 2021.08.02 06:30:00  artem EURUSD,M30: 1.18696 / 1.18781 / 1.18781 / 1.18675 / 1.18683 / false / 1
2021.10.10 19:03:37.209 2021.08.02 06:00:00  artem EURUSD,M30: 1.18685 / 1.18783 / 1.18781 / 1.18669 / 1.18680 / false / 1
2021.10.10 19:03:37.145 2021.08.02 05:30:00  artem EURUSD,M30: 1.18656 / 1.18784 / 1.18781 / 1.18656 / 1.18674 / false / 1
2021.10.10 19:03:37.023 2021.08.02 05:00:00  artem EURUSD,M30: 1.18646 / 1.18785 / 1.18781 / 1.18653 / 1.18673 / false / 1
2021.10.10 19:03:36.917 2021.08.02 04:30:00  artem EURUSD,M30: 1.18665 / 1.18789 / 1.18782 / 1.18660 / 1.18679 / false / 1
2021.10.10 19:03:36.819 2021.08.02 04:00:00  artem EURUSD,M30: 1.18677 / 1.18790 / 1.18783 / 1.18664 / 1.18682 / false / 1
2021.10.10 19:03:36.755 2021.08.02 03:30:00  artem EURUSD,M30: 1.18670 / 1.18790 / 1.18781 / 1.18660 / 1.18682 / false / 1
2021.10.10 19:03:36.688 2021.08.02 03:00:00  artem EURUSD,M30: 1.18654 / 1.18791 / 1.18779 / 1.18653 / 1.18679 / false / 1
2021.10.10 19:03:36.669 2021.08.02 02:30:00  artem EURUSD,M30: 1.18641 / 1.18792 / 1.18778 / 1.18649 / 1.18679 / false / 1
2021.10.10 19:03:36.640 2021.08.02 02:00:00  artem EURUSD,M30: 1.18662 / 1.18794 / 1.18777 / 1.18657 / 1.18686 / false / 1
2021.10.10 19:03:36.615 2021.08.02 01:30:00  artem EURUSD,M30: 1.18645 / 1.18794 / 1.18776 / 1.18651 / 1.18685 / false / 1
2021.10.10 19:03:27.183 2021.08.02 01:00:00  artem EURUSD,M30: 1.18638 / 1.18796 / 1.18774 / 1.18649 / 1.18687 / false / 1
2021.10.10 19:03:22.324 2021.08.02 00:30:00  artem EURUSD,M30: 1.18643 / 1.18797 / 1.18773 / 1.18652 / 1.18692 / false / 1
2021.10.10 19:03:18.053 2021.08.02 00:05:00  artem EURUSD,M30: 1.18644 / 1.18798 / 1.18772 / 1.18655 / 1.18696 / false / 1

Try other days start and compare readings.

 
MakarFX #:
It's not clear what you need...

For example, a working M5 chart.

How to write "if H1 candle closed above/below the bar..." in the trade opening condition?
That is, while in indicators you can specify the TF in function parameters, the bar / candlestick parameters do not seem to have any indication of the TF. It is only index of the serial number of the candle (Close[0]). I need something like Close(NULL,60...) if it exists)))

Here, for example, how to write:

"If the swing1 on M15 is higher than the swing2 on M15 and the stochastic on M15 is below 20 and the hourly candle closed below the previous hourly candle..."
 
EVGENII SHELIPOV #:

Makar has inserted code into the Expert Advisor so far only to compare profit in currency and profit in pips as far as I understand it can be understood when these functions have zero values


That's right, just correct it in the comments

 "Профит в пунктах: " + IntegerToString(GetProfitOpenPosInPoint())+ "\n" +

and it's not clear what it's for...

 if(p==0)
    if(StringFind(OrderSymbol(), "")<0)
       p=0.0001;
    else
       p=0.01;
 
Ivan Butko #:

For example, a working M5 chart.

How to write "If H1 candle closed above/below the bar..." in the trade opening condition?
That is, while in indicators you can specify the TF in function parameters, the bar / candlestick parameters do not seem to have any indication of the TF. They only have the index of the serial number of the candle (Close[0]). I need something like Close(NULL,60...) if it exists)))

double barclose=iClose(_Symbol,PERIOD_H1,1);
   if(barclose>машки)
      {выполняем условие}
 
Ivan Butko #:
Here's how to prescribe:

"If M15 wristband1 is higher than M15 wristband2 and the stochastic on M15 is below 20 and the hourly candle has closed below the previous hourly candle...".
if(iMA_1_M15>iMA_2_M15&&iStoch_M15<20&&iClose(_Symbol,PERIOD_H1,1)<iClose(_Symbol,PERIOD_H1,2))
 
MakarFX #:

Thank you very much!

I must have missed this feature in the handbook

Reason: