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

 
artem artem #:

What additions I wanted to make:

1. To make the opening of a deal and check for the correspondence of all indicator conditions(crossing a fast (5) of two slow (75) (85) and opening of a MACD bar in the same direction with a fast (5)) was made only at the opening price of a new candle (the first tick of each 30 minute candle);
  1. Create conditions for "zeroing" the indicators. For example, for a fast moving bar (5): If it is higher than the slow ones - then it is a signal to buy. If after that, it goes down and either touches one of them, or is between the slow moving (75) and (85)- then the signal from the fast moving indicator" zeros out" as it were, and will remain in such a" zero" position as long as it touches or remains between the slow ones. If after that the fast one crosses both slow ones to one side(including if it goes back to the side it came from before touching the slow ones)- then it will be a signal of this indicator. With MACD the situation is similar- Only MACD=0 will be considered as "zeroing"(if on the first candle the MACD, for example, opened with 0.0043, and on the second candle with -0.0010, it means that the MACD on the second candle has" zeroed" and has given a new signal). However, there is a time when the fast (5) and the MACD should be kind of "on equal footing" - if (5) doesn't change its position relative to the slow, and the MACD has opened on the previous candle in the wrong zone (no entry), and on the next one - in the same zone as the fast, then all conditions have converged and an entry to the order should occur. Note that all this should be only on the opening prices of the candles - only on this one tick;
  1. And the last, to make the Expert Advisor wait for 4 consecutive candle openings:

    1. 1st open price - (5) above (75) and (85) + MACD bar opened above 0- 1 out of 4 confirmations;
    2.The opening price of the 2nd candle - (5) over (75) and (85) + MACD bar opened above 0- 2 out of 4 confirmations is;
    3. The opening price of the 3rd candle - (5) over (75) and (85) + MACD bar opened above 0- 3 out of 4 confirmations is;
    4.Opening price of the 4th candle - (5) over (75) and (85) + MACD bar opened above 0- 4 out of 4 confirmations yes- Open buy trade on the same candle (4th).
The same situation with orders to sell, only in the other direction indicators should open. And there is an important point- if at, say, any stage of the 1 st candle to the 4th, the indicators change their position(for example, on the 3rd opening candle, the MACD bar opens either below 0, or = 0)- then everything resets, because the signals were not tested on the opening of 4-th candle in a row.

I'm with these settings - tried to make an indicator (RED AND BLUE)

compared to other indicators - they all have the same theme

EURUSDH1

 
MakarFX #:

Then find the opening prices min/mac, add them and divide by 2. If you buy, add points*Points to the result,

and if selling, subtract.

Makar if you can explain to me in more detail: Opening price of what????

 
EVGENII SHELIPOV #:

Makar if you can explain to me in more detail: Opening price of what????

Opening price of maximum and minimum order

 
MakarFX #:

Opening price of maximum and minimum order

I wonder if the step between orders "Dynamic" changes depending on volatility?

 
EVGENII SHELIPOV #:

I wonder if the pitch between orders "Dynamic" changes depending on volatility?

I do not understand the question
 
EVGENII SHELIPOV #:

I wonder if the pitch between orders "Dynamic" changes depending on volatility???

Or does that have nothing to do with it???

 
MakarFX #:
I don't understand the question.

It is the same as counting the average price but including the lot

 
EVGENII SHELIPOV #:

Or does that have nothing to do with it?

You have gone off the original topic!

You wanted a certain "figure" in points from the breakeven point to close the orders with the maximum and minimum ticket.

So, you find the open prices of these orders, add them and divide by two - this will be the price to which you should add or subtract points

 
MakarFX #:

You have strayed from the original topic!

You wanted a certain "figure" in points from the breakeven point to close the orders with the maximum and minimum ticket.

So, you find the open prices of these orders, add them and divide by two and this will be the price you have to add or subtract points from.

Makar, I got it. You should only use the weight coefficients of min and max lot sizes i.e. you have to make parallel calculation according to the calculation principle and the principle described below. I think it is not reasonable.

double   AwerageBuyPrice = 0, AwerageSelPrice = 0;
      if(b >= 2)
         AwerageBuyPrice = NormalizeDouble((BuyPriceMax * BuyPriceMaxLot + BuyPriceMin * BuyPriceMinLot) / (BuyPriceMaxLot + BuyPriceMinLot) + iMinimalProfit * Point(), Digits());
      if(s >= 2)
         AwerageSelPrice = NormalizeDouble((SelPriceMax * SelPriceMaxLot + SelPriceMin * SelPriceMinLot) / (SelPriceMaxLot + SelPriceMinLot) - iMinimalProfit * Point(), Digits());

My question was simple: how to specify min/max orders to be closed after the breakeven point instead of profit in currency, after a certain amount of pips
.

 
EVGENII SHELIPOV #:

Yes Makar, I have already understood. Only it should be counted taking into account the weight coefficients of min and max lot size, i.e. it should be counted in parallel according to the principle of calculation and according to the principle mentioned below. I think it is not reasonable.

My question was simple: instead of profit in currency you can specify that the min/max orders will close after the breakeven point after a certain amount of points
.

You have an average price function "GetAveragePrice()"

Do the same, but only for "max_ticket" and "min_ticket".