if(iTime(NULL,PERIOD_D1,i+1)!=iTime(NULL,PERIOD_D1,i)&& how do I write this? )
You need to extract date from time[i] and compare it with time[i+1]. If they are not equal, then extract time from time[i] and compare with given time. If they are the same, put in a line.
How all this is extracted - I have shown in the script. All that remains is to think about it.
You need to extract the date from time[i] and compare it with time[i+1]. If not equal, extract the time from time[i] and compare it with the given time. If they are the same, draw a line.
How it's all extracted - I've shown in the script. All that's left to do is think about it.
I entered a trade at some price, I always long) And I compare the price of the trade with the current bid, if we increased by 0.5% I close.Cursed at bid(((
if(MA1_buf[1]>Close_buf[1] && MA1_buf[0]<Close_buf[0]) //если значение индикатора были выше цены закрытия и стали ниже
{
if(m_Position.Select(my_symbol)) //если уже существует позиция по этому символу
{
if((m_Position.PositionType()==POSITION_TYPE_BUY) && (fabs(DEAL_PRICE-Bid[0])/DEAL_PRICE)>= 0.005) m_Trade.PositionClose(my_symbol); //и тип этой позиции Buy, то закрываем ееreturn;
}
m_Trade.Buy(0.1,my_symbol); //если дошли сюда, значит позиции нет, открываем ее
}
I entered a trade at some price, I am always longing)And I compare the price of the trade with the current bid, if we went up by 0.5% I close.It swears at bid(((
Probably because this is MQL5. There is no "bid" here butSymbolInfoDouble(_Symbol, SYMBOL_BID)
I entered the trade at some price, I always long) And I compare the price of the trade with the current bid, if we rose by 0.5% I close.It swears at bid(((
You're right to swear. There is no such array with Bid prices in MQL5.
Replace it with
m_symbol.Bid()
and before the cycle do not forget to update the prices:
And he is right to swear. There is no such array with Bid prices in MQL5.
Replace it with
and before the loop do not forget to update the prices:
I have done it in two different ways:
1) Expert Advisor works, but unfortunately it does not give me the idea. It is simple, I buy when the previous candle closed below and the next one closed above. And I close only if the price rose by 0.5%.
It makes strange deals(((
if(MA1_buf[1]>Close_buf[1] && MA1_buf[0]<Close_buf[0]) //если значение индикатора были выше цены закрытия и стали ниже
{
if(m_Position.Select(my_symbol)) //если уже существует позиция по этому символу
{
if((m_Position.PositionType()==POSITION_TYPE_BUY) && (SymbolInfoDouble(_Symbol,SYMBOL_BID)-DEAL_PRICE)/DEAL_PRICE>= 0.005) m_Trade.PositionClose(my_symbol); //и тип этой позиции Buy, то закрываем ееreturn;
}
m_Trade.Buy(0.1,my_symbol); //если дошли сюда, значит позиции нет, открываем ее
}
2) My method is as follows:
if(!RefreshRates())
return;
if(MA1_buf[1]>Close_buf[1] && MA1_buf[0]<Close_buf[0]) //если значение индикатора были выше цены закрытия и стали ниже
{
if(m_Position.Select(my_symbol)) //если уже существует позиция по этому символу
{
if((m_Position.PositionType()==POSITION_TYPE_BUY) && (m_symbol.Bid())-DEAL_PRICE)/DEAL_PRICE>= 0.005) m_Trade.PositionClose(my_symbol); //и тип этой позиции Buy, то закрываем ееreturn;
}
m_Trade.Buy(0.1,my_symbol); //если дошли сюда, значит позиции нет, открываем ее
}
1) The Expert Advisor works, but unfortunately it does not implement the idea. It is simple, I buy when the previous candle closed lower and the next one closed higher. And I close only if the price went up 0.5%.
It makes strange deals(((
2) My method is as follows:
I think I messed up(((.
It gives out an error:
Open any of my code and there you will see both m_symbol and RefreshRates.
Open any of my code and you will see both m_symbol and RefreshRates there.
Thank you. I've read it and done it.
Now I can't figure out why the algorithm doesn't work.
if(!RefreshRates())
return;
1) if(MA1_buf[1]>Close_buf[1] && MA1_buf[0]<Close_buf[0]) //если значение индикатора были выше цены закрытия и стали ниже
{
2) if(m_Position.Select(Symbol())) //если уже существует позиция по этому символу
{
return;
}
2*) m_Trade.Buy(0.1,Symbol()); //если дошли сюда, значит позиции нет, открываем ее
}
3) if
((m_Position.PositionType()==POSITION_TYPE_BUY) && (((m_symbol.Bid()-DEAL_PRICE)/DEAL_PRICE)>= 0.1))
{
m_Trade.PositionClose(Symbol()); //и тип этой позиции Buy, то закрываем ее
}
What happens is the following: the purchase is made under the condition
1) If the condition is fulfilled;
2) I check whether there is already an open position, if there is, I go to point 3), if not, I open a 2*)
3) If the position is buy, and the condition is fulfilled that the price has increased by 10% from the entry price, then I close it.
In the test, the following happens, position opens and closes, not on conditions (( Again, please help!
Now I can't figure out why the algorithm doesn't work.
What happens is the following: the purchase is made under the condition
1) If the condition is fulfilled;
2) I check whether there is already an open position, if there is, I go to point 3), if not, I open a 2*)
3) If the position is buy, and the condition is fulfilled that the price has increased by 10% from the entry price, then I close it.
When testing the following happens, position opens and closes, not on conditions (( Again, please help!
I propose the following algorithm:
if(!RefreshRates())
return;
if(MA1_buf[1]>Close_buf[1] && MA1_buf[0]<Close_buf[0]) //если значение индикатора были выше цены закрытия и стали ниже
{
if(m_Position.Select(Symbol())) //если уже существует позиция по этому символу
{
if(m_Position.PositionType()==POSITION_TYPE_BUY && (m_symbol.Bid()-m_Position.PriceOpen())/m_Position.PriceOpen()>=0.1)
{
m_Trade.PositionClose(Symbol()); //и тип этой позиции Buy, то закрываем ееreturn;
}
}
else
m_Trade.Buy(0.1,Symbol()); //если дошли сюда, значит позиции нет, открываем ее
}
if(iTime(NULL,PERIOD_D1,i+1)!=iTime(NULL,PERIOD_D1,i)&& how do I write this? )
You need to extract date from time[i] and compare it with time[i+1]. If they are not equal, then extract time from time[i] and compare with given time. If they are the same, put in a line.
How all this is extracted - I have shown in the script. All that remains is to think about it.
You need to extract the date from time[i] and compare it with time[i+1]. If not equal, extract the time from time[i] and compare it with the given time. If they are the same, draw a line.
How it's all extracted - I've shown in the script. All that's left to do is think about it.
Friday night, thinking badly) Nothing builds. Why?
then extract the time from time[i] and compare it with the set time.
Probably time[i+1], I need to put the line to the previous day after the close of the day.
Hello.
Stupid question but still, please help)
I entered a trade at some price, I always long) And I compare the price of the trade with the current bid, if we increased by 0.5% I close.Cursed at bid(((
I entered a trade at some price, I am always longing)And I compare the price of the trade with the current bid, if we went up by 0.5% I close.It swears at bid(((
Probably because this is MQL5. There is no "bid" here butSymbolInfoDouble(_Symbol, SYMBOL_BID)
Hello.
Stupid question but still, please help)
I entered the trade at some price, I always long) And I compare the price of the trade with the current bid, if we rose by 0.5% I close.It swears at bid(((
You're right to swear. There is no such array with Bid prices in MQL5.
Replace it with
m_symbol.Bid()and before the cycle do not forget to update the prices:
And he is right to swear. There is no such array with Bid prices in MQL5.
Replace it with
and before the loop do not forget to update the prices:
I have done it in two different ways:
1) Expert Advisor works, but unfortunately it does not give me the idea. It is simple, I buy when the previous candle closed below and the next one closed above. And I close only if the price rose by 0.5%.
It makes strange deals(((
2) My method is as follows:
I think I messed up(((.
It generates an error:
Did it in two different ways:
1) The Expert Advisor works, but unfortunately it does not implement the idea. It is simple, I buy when the previous candle closed lower and the next one closed higher. And I close only if the price went up 0.5%.
It makes strange deals(((
2) My method is as follows:
I think I messed up(((.
It gives out an error:
Open any of my code and there you will see both m_symbol and RefreshRates.
Open any of my code and you will see both m_symbol and RefreshRates there.
Thank you. I've read it and done it.
Now I can't figure out why the algorithm doesn't work.
What happens is the following: the purchase is made under the condition
1) If the condition is fulfilled;
2) I check whether there is already an open position, if there is, I go to point 3), if not, I open a 2*)
3) If the position is buy, and the condition is fulfilled that the price has increased by 10% from the entry price, then I close it.
In the test, the following happens, position opens and closes, not on conditions (( Again, please help!
Thank you. I've done the reading.
Now I can't figure out why the algorithm doesn't work.
What happens is the following: the purchase is made under the condition
1) If the condition is fulfilled;
2) I check whether there is already an open position, if there is, I go to point 3), if not, I open a 2*)
3) If the position is buy, and the condition is fulfilled that the price has increased by 10% from the entry price, then I close it.
When testing the following happens, position opens and closes, not on conditions (( Again, please help!
I propose the following algorithm:
Pay attention to m_Position.PriceOpen()