Artyom Trishkin: 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.
I do not know much about programming, but this module deals with this
b=0; 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++; }
But the issue is that when the order is closed by SL or TP, the next signal at M15 will open it again.
Artyom Trishkin: Inside the class, make Prints to the values. And then look in the log what will be printed when the script runs ;)
Prints can only be inserted within a function, but how to call this function to make the print or alert work I do not understand. Can you help fixing my code with three simple variables??? I do everything as described in the article, but the editor won't accept it or something is missing, in any case a wall, that's why I am asking for help. Thanks for SKC.
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 ;)