[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 1100

 
kolyango:

Stop Loss and Take Profit have already been set! If the set StopLoss is less than the opening price of the order, you only need to move the StopLoss above the opening price by 50 pips (to the loss) if the current price is more or equal to 80 pips from the opening price of the order. And we don't need to rearrange StopLoss and TakeProfit all the time!

Kolyana, you are getting tired of your unwillingness to think.
 
DhP:

Kolya, you are tiring with your unwillingness to think.

I just started studying MQL4, so I don't know a lot...
 

I have this question. It's done like this: on H1 chart every tick comes after a new bar is fully formed, i.e. once an hour. Trade orders look like this:

To buy:


OrderSend(Symbol(),OP_BUY,LOT,Ask,slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",3,Green); // Открытие BUY
Alert (GetLastError()); // Выводит сообщение об ошибке

To sell:


OrderSend(Symbol(),OP_SELL,LOT,Bid,slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",3,Red); // Открытие SELL
Alert (GetLastError()); // Выводит сообщение об ошибке

And I noticed that sometimes error 129 comes out and then not all trade orders are executed. I think it's the number of digits after the decimal point. I think we should add Digits. But where exactly? Or, how to form the correct trade order so that it is always executed, even if the Expert Advisor is executed only once a day? Is it necessary to add the function:
RefreshRates(); // Обновим данные

Before the trade order? Approximately like this:

RefreshRates(); // Обновим данные

OrderSend(Symbol(),OP_BUY,LOT,NormalizeDouble(Ask,Digits),slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",3,Green); // Открытие BUY
Alert (GetLastError()); // Выводит сообщение об ошибке

How to make it right and always execute flawlessly at any timeframe?

 

How do I write this condition? If present price >= OrderOpenPrice() by 60 p. (If present price is greater than or equal to open order price by 60 p.)

Would that be correct?

if ((NormalizeDouble(Ask,Digits))>=(OrderOpenPrice()+Dist*Point))

 
kolyango:

How do I write this condition? If present price >= OrderOpenPrice() by 60 p. (If present price is greater than or equal to open order price by 60 p.)

Would that be correct?

if ((NormalizeDouble(Ask,Digits))>=(OrderOpenPrice()+Dist*Point))



if ( Ask > (OrderOpenPrice()+(-0.5+ Dist)*Point) )



 
kolyango:

How do I write this condition? If present price >= OrderOpenPrice() by 60 p. (If present price is greater than or equal to open order price by 60 p.)

Would that be correct?

if ((NormalizeDouble(Ask,Digits))>=(OrderOpenPrice()+Dist*Point))

double pa=MarketInfo(Symbol(),MODE_ASK);
int    pt=MarketInfo(Symbol(),MODE_POINT);
int    dg=MarketInfo(Symbol(),MODE_DIGITS);

if (NormalizeDouble(pa-OrderOpenPrice()+60*pt,dg)>=0) {    // если Ask больше либо равен цене открытия выбранного ордера + 60 пунктов
    // ... код, обрабатывающий истинностть выражения оператора if ...
   }
 
artmedia70:



Artem, there are questions not worth answering.

Somebody should think before asking a question.

Merry Christmas!!!

 
Vinin:


Artem, there are questions not worth answering.

Somebody should think before asking a question.

Merry Christmas!!!

Hi mate!!! Thanks, you too! :))))
May it be a Christmas Miracle to someone... :)
 
Dear MQL4 experts
Please help me to write a simple indicator.

1) Gap Up indicator


If Open Price yesterday is lower than today's LOWER price, then the indicator calls today's Opening Price.
if the condition is not met, then the indicator leaves the previous value.

2) Gap down indicator

if the Upper Price today is lower than the Upper Price yesterday, then the indicator calls today's Opening Price.
if the condition is not fulfilled, then the indicator leaves the previous value.

3) Local high and low indicator

if the day before yesterday's Top is lower than yesterday's Top and yesterday's Top is higher than today's Top, then the indicator calls yesterday's high price if the condition is not met, then the indicator leaves the previous value, i.e. it keeps the resistance level

On the metastock it is clear If((Ref(H,-1) >Ref(H,0)) AND (Ref(H,-2) < Ref(H,-1) ), Ref( H,-1),PREV); but in MQL4 I am a beginner.

Thanks in advance for help

 
Error 4109 trade is not allowed. How to fix it?
Reason: