Questions from Beginners MQL5 MT5 MetaTrader 5 - page 581

 
barudkinarseniy:
Hello gentlemen of the forum!!! I have a problem. I tested the Expert Advisor on weekdays for one result, but on weekends it gives me a totally different result! Can you please tell me why?
i think it's because the spread widens on weekends
 
Sergey Gritsay:
because at the weekend they widen the spread
and the margin level decreases, i.e. when the market closes or earlier or does it depend on the broker?
 
Karputov Vladimir:

Here is the dialog panel with the CEdit control (for clarity, the example is made as a single file) - the panel checks the characters entered. Only numbers are allowed:

Thanks for the code. But here is another question. I have compiled the code in MT5. It turns out that you can still enter letters in the unit, but if you enter letters, it says "Only digits are allowed" at the end of the code in the unit. But how to make it impossible to enter letters into the unit?
 
Andrey Zuev:
Thanks for the code. But another question is this. I compiled the code in mt5. It turns out that you can still enter letters in edit, but if you enter letters, when you finish entering it, it says "Only numbers are allowed" in edit. But how to make it impossible to enter letters into udite?
You can't. The control based on CEdit class handles only ON_END_EDIT- (6) // end of editing event - i.e. input completion event.
 

Colleagues, trying to take a signal from this line:

if((MathAbs(d_f)>(K_F*Point)) && (d_f>0.0)) // Signal to buy

But the compiler complains that "Point - undeclared identifier".

This is MT5.

Isn't it a predefined variable?

 
Andrey Koldorkin:

Colleagues, trying to take a signal from this line:

if((MathAbs(d_f)>(K_F*Point)) && (d_f>0.0)) // Signal to buy

But the compiler complains that "Point - undeclared identifier".

This is MT5.

Isn't it a predefined variable?

No. Use _Point.
 
Andrey Koldorkin:

Colleagues, trying to take a signal from this line:

if((MathAbs(d_f)>(K_F*Point)) && (d_f>0.0)) // Signal to buy

But the compiler complains that "Point - undeclared identifier".

This is MT5.

Isn't it a predefined variable?

You need to usePoint().

 

Thank you.

Another question. I want to take the value of the curve on the current and last closed candle, as well as on the last closed and penultimate closed candle.

Do I need to use an array here?

I have a mashka that has 3 input parameters. I'm trying to build an address to it:

//----------------------

double P0, P1, P2; // indicator value at the current candle, last closed candle

P0 = iCustom(NULL, 0, "VIDYA", InpPeriodCMO, InpPeriodEMA, InpShift); //The indicator price on the current candle

P1 = iCustom(NULL, 0, "VIDYA", InpPeriodCMO, InpPeriodEMA, InpShift); //The indicator price on the latest closed candle

P2 = iCustom(NULL, 0, "VIDYA", InpPeriodCMO, InpPeriodEMA, InpShift); //The indicator price on the penultimate closed candle

//----------------------

The bottom three lines are the same, I wrote it this way, because I don't understand how to read the value at the previous candlestick. It takes the current one correctly, and outputs it correctly using Alert.

Maybe we should somehow define a loop, where the current value will be written and with each new candlestick is shifted back, becoming first the last closed, and then the penultimate closed candlestick.

How to do this in an intelligent way? ))

 
Andrey Koldorkin:

Colleagues, trying to take a signal from this line:

if((MathAbs(d_f)>(K_F*Point)) && (d_f>0.0)) // Signal to buy

But the compiler complains that "Point - undeclared identifier".

This is MT5.

Isn't it a predefined variable?

And then you write this:

Andrey Koldorkin:

Thank you.

Another question. I want to take the value of the curve on the current and last closed candle, as well as on the last closed and penultimate closed candle.

Do I need to use an array here?

I have a mashka that has 3 input parameters. I'm trying to build an address to it:

//----------------------

double P0, P1, P2; // indicator value at the current candle, last closed candle

P0 = iCustom(NULL, 0, "VIDYA", InpPeriodCMO, InpPeriodEMA, InpShift); //The indicator price on the current candle

P1 = iCustom(NULL, 0, "VIDYA", InpPeriodCMO, InpPeriodEMA, InpShift); //The indicator price on the latest closed candle

P2 = iCustom(NULL, 0, "VIDYA", InpPeriodCMO, InpPeriodEMA, InpShift); //The indicator price on the penultimate closed candle

//----------------------

The bottom three lines are the same, I wrote it this way, because I don't understand how to read the value at the previous candlestick. It takes the current one correctly, and outputs it correctly using Alert.

Maybe we should somehow define a loop, where the current value is written and with each new candlestick is shifted back, becoming first the last closed, and then the penultimate closed candlestick.

How to do this in an intelligent way? ))

So, still: do you write in MT5 or in MT4?

Added:Insert code correctly in the forum

 
Karputov Vladimir:

and then you write this:

So, still: are you writing in MT5 or MT4?

Added:Inserting the code correctly in the forum

MT5. Don't judge harshly, I'm just starting out.

The compiler doesn't seem to swear.

Reason: