Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 92
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
So check the number of open positions on the M15 zero candle. If you already have a position and it is open on an M15 null candle, then don't open any more.
for (i=OrdersTotal()-1;i>=0;i--)
{
RefreshRates();
if(OrderSelect (i, SELECT_BY_POS, MODE_TRADES) == true) a = 0;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) b++;
}
I am not very good at programming, but this module does it
}
Try to make a control for a new bar on H1
for (i=OrdersTotal()-1;i>=0;i--)
{
RefreshRates();
if(OrderSelect (i, SELECT_BY_POS, MODE_TRADES) == true) a = 0;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) b++;
}
if( stM1 <= 20 && stM0 > 20 && stH0 > 70 && b==0 && opp != iTime(_Symbol,PERIOD_H1,0)) // покупка
{
opp = iTime(_Symbol,PERIOD_H1,0);
RefreshRates();
op = Ask;
Try a new bar control on H1
for (i=OrdersTotal()-1;i>=0;i--)
{
RefreshRates();
if(OrderSelect (i, SELECT_BY_POS, MODE_TRADES) == true) a = 0;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) b++;
}
if( stM1 <= 20 && stM0 > 20 && stH0 > 70 && b==0 && opp != iTime(_Symbol,PERIOD_H1,0)) // покупка
{
opp = iTime(_Symbol,PERIOD_H1,0);
RefreshRates();
op = Ask;
I'm not very good at programming, but this module does that
for (i=OrdersTotal()-1;i>=0;i--)
{
RefreshRates();
if(OrderSelect (i, SELECT_BY_POS, MODE_TRADES) == true) a = 0;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) b++;
}
No, that's definitely not what this piece of code does.
You need to check that the position opening bar on M15 period is not equal to zero - then you can open a position:
{
// код открытия позиции
}
Hello! Help me out with the classes, what am I doing wrong?
class ASDHello! Help me out with the classes, what am I doing wrong?
class ASDStart by reading the article.
I do read it, but I don't get it right.
Here's what I get:
class:
{
private:
// Здесь располагаются переменные и функции, доступные только внутри класса
int c(int m_a,int m_b)
{
m_a=a+b; m_b=a-b;
int m_d=m_a+m_b;
d=m_d;
return(c(m_a,m_b));
}
public:
int a;
int b;
int d;
};
script:
ASD ar;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
ar.a=1;
ar.b=3;
Alert(ar.d);
}
//+------------------------------------------------------------------+
Alert gives out zero. What's wrong?
I do read it, but I don't get it right.
Here's what I get:
class:
Alert gives out zero. What's wrong?
Is it difficult to insert the code via the SRC button ?
I have inserted the correct code for you.
I do read it, but I don't get it right.
Here's what I get:
class:
{
private:
// Здесь располагаются переменные и функции, доступные только внутри класса
int c(int m_a,int m_b)
{
m_a=a+b; m_b=a-b;
int m_d=m_a+m_b;
d=m_d;
return(c(m_a,m_b));
}
public:
int a;
int b;
int d;
};
script:
ASD ar;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
ar.a=1;
ar.b=3;
Alert(ar.d);
}
//+------------------------------------------------------------------+
Alert gives out zero. What's wrong?
Inside the class, make Prints to the values. And then look in the log what will be printed when the script runs ;)