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

 
Hi, I have a situation like this and I want to fix it without using crutches. The Expert Advisor opens a position and has a Stop and Take. There is a situation when during testing on one candle (that is when the condition of opening the position is fulfilled), right after the first order is closed, the second, third, etc. orders are opened. This is due to the fact that conditions for opening a position are fulfilled on that very candle and a stop or take order triggers some time later (the conditions for opening are still fulfilled, the candle is not closed).

Please advise how to make an entry (the condition for opening a position) and if the same candle will trigger a take or stop so as not to open a new position (the condition for opening is satisfied). Thank you!

 
Profitpamm:
Hi, I have a situation like this and I want to fix it without using crutches. The Expert Advisor opens a position and has a Stop and Take. There is a situation when during testing on one candle (that is when the condition of opening the position is fulfilled), right after the first order is closed, the second, third, etc. orders are opened. This is due to the fact that it is on this candle that the condition to open the position is met and after some time, a stop or take order is triggered (the opening condition is still satisfied, the candle is not closed).
Please advise how to make an entry (the condition for opening a position) and if the same candle will trigger a take or stop so as not to open a new position (the condition for opening is satisfied). Thank you!

Check by date if there is an open position and if the position was opened and closed on this candlestick...
 
Profitpamm:
Hi, I have a situation like this and I want to fix it without using crutches. The Expert Advisor opens a position and has a Stop and Take. There is a situation when during testing on one candle (that is when the condition of opening the position is fulfilled), right after the first order is closed, the second, third, etc. orders are opened. This is due to the fact that conditions for opening a position are fulfilled on that very candle and a stop or take order triggers some time later (the conditions for opening are still fulfilled, the candle is not closed).

Please advise how to make an entry (condition for opening a position) and if the same candle will trigger a take or stop so as not to open a new position (the condition for opening is met). Thank you!


Here's an example of how you can use it...

datetime zap_tim;

//=======================
void start()
{
if(zap_tim!=Time[0])
 {
  OrderSend(............);
  zap_tim=Time[0];
 }
}
 
-Aleks-:

Check by date if there is an open position and if the position was opened and closed on that candle...
Thanks Aleks!
 
Valerius:


Here's an example of how it can be used...

Valerius, thank you very much for the clarification!
 

The standard code from the reference does not work

https://docs.mql4.com/ru/basis/types/casting

Bringing data of the simple structure type

333

how to treat?

Used to convert values of different basic types. For example, there is an array uchar arr[].We need to write the value of double to a certain position.

void GetBytes(double x,uchar &arr[],int pos)

Or vice versa.

double GetDouble(uchar &arr[],int pos)

Perhaps someone may suggest a simpler solution.

Приведение типов - Типы данных - Основы языка - Справочник MQL4
Приведение типов - Типы данных - Основы языка - Справочник MQL4
  • docs.mql4.com
Приведение типов - Типы данных - Основы языка - Справочник MQL4
 

doubleiMA(
stringsymbol,// symbol name
inttimeframe,// timeframe
intma_period,// period
intma_shift,// shift average
intma_method,// averaging method
intapplied_price,//price type
intshift// shift
);

How is a pair put in place ofsymbol ?
 
Rustam Bikbulatov:

doubleiMA(
stringsymbol,// symbol name
inttimeframe,// timeframe
intma_period,//period
intma_shift,// shift of average
intma_method,// averaging method
intapplied_price,//price type
int shift//shift
);

How is a pair put in place ofsymbol ?

"EURUSD"
 
Alekseu Fedotov:

"EURUSD"

It's in inverted commas. Thank you!
 
Rustam Bikbulatov:

doubleiMA(
stringsymbol,// symbol name
inttimeframe,// timeframe
intma_period,//period
intma_shift,// shift of average
intma_method,// averaging method
intapplied_price,//price type
int shift//shift
);

How is any pair put in place ofsymbol ?
double  iMA("EURCAD", Period(), ...);
Reason: