[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 335

 
snowman647 >> :

This is far from Random. I want an Expert Advisor using random variables as randomly as possible)) if I don't find it, I will post it.

As far as I know there is no random number in MCL. there is a pseudo-random number. so it's pretty much the same as the scheme I suggested.

Actually, about pseudo-random numbers read here https://www.mql4.com/ru/search/?keyword=%D1%81%D0%BB%D1%83%D1%87%D0%B0%D0%B9%D0%BD%D0%BE%D0%B5+%D1%87%D0%D0%B8%D1%81%D0%BB%D0%BE

 
vik-777 >> :
>> Hello, could you tell me how to search for a bar by time and display the open,close price?

Again, really need

 
Stepan241 >> :

First of all, the entry is not quite correct

MA_1 = iMA(NULL,0,Period_MA_1,Sdvig_1,MODE_SMA,PRICE_CLOSE,0); // Call function indicator
MA_2 = iMA(NULL,0,Period_MA_2,Sdvig_2,MODE_SMA,PRICE_CLOSE,0);

The zeros should be replaced with 1

In order to determine the moment of crossing, not only the current value (above or below, but also the previous value) should be considered

Therefore we should add

MA_1_Prev = iMA(NULL,0,Period_MA_1,Sdvig_1,MODE_SMA,PRICE_CLOSE,2); // Call indicator function
MA_2_Prev= iMA(NULL,0,Period_MA_2,Sdvig_2,MODE_SMA,PRICE_CLOSE,2);

note number 2

In other words, this block will now look like

MA_1 = iMA(NULL,0,Period_MA_1,Sdvig_1,MODE_SMA,PRICE_CLOSE,1); // Call function indicator
MA_2 = iMA(NULL,0,Period_MA_2,Sdvig_2,MODE_SMA,PRICE_CLOSE,1);

MA_1_Prev = iMA(NULL,0,Period_MA_1,Sdvig_1,MODE_SMA,PRICE_CLOSE,2); // Call indicator function
MA_2_Prev= iMA(NULL,0,Period_MA_2,Sdvig_2,MODE_SMA,PRICE_CLOSE,2);

The line

if (MA_2 < MA_1 && Fact_Up == true)

replace with if (MA_2 < MA_1 && MA_2_Prev>MA_1_Prev && Fact_Up == true)


Make the same replacement for the second condition and exit condition. The new condition is marked in blue. We will now enter a long position when the First Moving Average is greater than the Second, while the previous value of the First Moving Average is less than the previous value of the Second.

Thank you.

 
vik-777 писал(а) >>

>> again, I really need

 
DDFedor >> :

>> that's it, it finds how many seconds to that bar.

datetime some_time=D'2004.03.21 12:00';

int shift=iBarShift("EUROUSD",PERIOD_M1,some_time);

 
vik-777 >> :

>> that's it, it finds how many seconds to that bar.

but how to know the open and close price of this bar

 
vik-777 писал(а) >>

and how to find out the open and close price of this bar

https://docs.mql4.com/ru/series

then the number of the bar found is used in the timeseries functions...

double MyOpenPrice =  iOpen(Symbol(),Period(),iBarShift(Symbol(),Period(), some_time));
 

I don't understand how to do it, I've already looked for an example on the internet (2 days) and couldn't find it.

 
DDFedor >> :

https://docs.mql4.com/ru/series

Then the number of the bar found is used in the timeseries functions...

thank you very much

 
vik-777 >> :
>> Hello, could you tell me how to search for a bar by time and display the open,close price?


datetime some_time=D'2009.12.07 01:15';
int shift=iBarShift("EURUSD",PERIOD_M1,some_time);

Alert("бар: ",shift," * время: ",TimeToStr(some_time)," * цена откр.: ",
iOpen("EURUSD",PERIOD_M1,shift)," * цена закр.: ",iClose("EURUSD",PERIOD_M1,shift));

Reason: