Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 803

 
pycha:

Thank you, but there's still a lot I don't understand. Just tell me if this code will read correctly or not.

   double profit =0.5;
   double takeprofit2= profit * point * value * lot1 + bid;



You can't go wrong if you think it's wrong! Start with the ABCs, learn, everything is there for everyone, what you need, you will find! Good luck!
 
Got it, thanks.
 

As you know, in MQL there is no possibility to change the size of 2 and 3 dimensions of a multidimensional array. I wonder what this limitation has to do with it.

But never mind. But what if we want to determine the number of columns of an array using an external variable? Again it is impossible. Or there is a way out?

 
People, please advise, I want to display a cross rate line on a chart. For this I need to multiply Close[0] by the Close of the instrument I need. How to mark it?
 
kon12:
Folks, please advise, I want to display a cross rate line on a chart. For this I need to multiply Close[0] by the Close of the instrument I need. How do I define it?
Look for iClose in the reference book.
 

I have almost found this formula by gut feeling, which works when the quote currency is equal to the deposit currency.

takeprofit = (profit+ (MarketInfo(symbol,MODE_LOTSIZE)*lot*ask))/lot1*MarketInfo(symbol,MODE_LOTSIZE)*0.0000000001;

Please advise which variables should correctly replace this - 0.0000000001. It works, but it's not the solution, it's better to make it look nice

 

Good afternoon.

I would like to know the maximum and minimum that the bars have reached since the beginning of the day on M15. I suggest discussing the best algorithm (not a code, but an algorithm).

1. 3 hours x 4 (there are 4 15-minute bars in one hour). 3x4=12.

2. The Expert Advisor can be started at any time, so we should build a check to see if 3 hours have passed?

3. The total amount of bars in the history from the beginning of the day until the launch of the Expert Advisor - the current time in hours *4 + integer part of the minutes/4. Suppose we have X bars in total.

4. We should loop from X bar to (X-12)-bar including, gradually calculating the maximum and minimum but should we check if this bar is related to the beginning of the day?

(here https://book.mql4.com/ru/functions/datetime there is figure 143, which explains that the number of bars can be smaller).


What can be improved or optimised here. Is there anything I haven't considered?


Ozero.



 
Ozero:

Good afternoon.

I would like to know the maximum and minimum that the bars have reached since the beginning of the day on M15. I suggest discussing the optimal algorithm (not the code, but the algorithm).

1. 3 hours x 4 (there are 4 15-minute bars in one hour). 3x4=12.

2. The Expert Advisor can be run at any time, it means that we should build a check if 3 hours have passed?

3. The total number of bars in the history from the beginning of the day until the Expert Advisor starts - current time in hours *4 + integer part of minutes/4. Let's assume that there are X bars in total.

4. We should run a cycle from X bar to (X-12)-bar inclusive, gradually calculating maximum and minimum, but should we check if the bar refers to the beginning of the day?

(here https://book.mql4.com/ru/functions/datetime there is figure 143, which explains that the number of bars can be less).


What can I improve or optimize? Maybe I have not considered something?


Ozero.



Highest() andLowest() are used to determine max and min bars.See Doc!
 
pycha:

I have almost found this formula by gut feeling and it works when quote currency is equal to deposit currency.

takeprofit = (profit+ (MarketInfo(symbol,MODE_LOTSIZE)*lot*ask))/lot1*MarketInfo(symbol,MODE_LOTSIZE)*0.0000000001;

Please advise which variables should correctly replace this - 0.0000000001. It works, but it's not the solution, it's better to make it look nice

The rule of thumb may be good for mobile devices, while here, you have to study, understand, build your own logic, your own system. If you need to multiply by one ten-billionth, it's enough to divide by Point() 2 times. Decide which is better, having knowledge or always being on the lookout for clues!
 
borilunad:
To determine max and min bars use Highest() andLowest(). See Doc!

Thanks for the reply.

According to https://docs.mql4.com/ru/obsolete Highest() andLowest() are obsolete functions. They have been replaced by

iHighest() andiLowest().


The examples are https://docs.mql4.com/ru/series/ihighest and https://docs.mql4.com/ru/series/ilowest.

In thefirst sample, the bar's belonging to a new day is not taken into account while in the second sample, there is an error in the code (it is written: int val_index=iLowest(NULL,0,MODE_LOW,10,10);

perhaps int val_index=iLowest(NULL,0,MODE_LOW,19,10);).

So, the algorithm comes down to sifting out yesterday's bars from the interval [X, X-12] and then searching for them via iHighest() and iLowest()?


Ozero.

Reason: