Why all the continues?
If the order is selected then the loop jumps to next iteration so the other continues will not do anything.
It is not clear what you are trying to do.
Seems like if there are less than 100 trades open you will try to open more.
You sleep for 10 seconds between each iteration so if you are using Bid and Ask, you must RefreshRates().
In the second loop, you check if the order's profit is >= Profit yet you don't try to close that order, you try to close the order with the ticket# OpenBuy or OpenSell.
Why all the continues?
If the order is selected then the loop jumps to next iteration so the other continues will not do anything.
It is not clear what you are trying to do.
Seems like if there are less than 100 trades open you will try to open more.
You sleep for 10 seconds between each iteration so if you are using Bid and Ask, you must RefreshRates().
In the second loop, you check if the order's profit is >= Profit yet you don't try to close that order, you try to close the order with the ticket# OpenBuy or OpenSell.
1. I'm trying to open a order, modify it with 1 stoploss=100 but loop it. The first loop i tried adding for(int Loop=0;Loop<OrdersTotal();Loop++) it does nothing when it comes to send an order.
2. The OrderBuy is giving me invalid stoploss for OrderModify.
3. I want to close my trade in profit, hence OrderProfit>=Profit.
I've sorted out my problem thank you :)
How did you solve it?
- Jack Buda: . I'm trying to open a order, modify it with 1 stoploss=100 but loop it.
If you select an order you continue, so eventually you exit the loop and you do nothing.
Jack Buda: I've sorted out my problem thank you :)Don't do that. Someone searching might find this thread and still be clueless. What solved what?
How To Ask Questions The Smart Way. 2004
When You Ask.
Follow up with a brief note on the solution. -
StopLossBid=Bid+StopLoss*Point; StopLossAsk=Ask-StopLoss*Point; int OpenBuy=OrderSend(Symbol(),OP_BUY,0.1,Ask,0,0,0,":)",0,0,clrBlue); if (OpenBuy>0) { bool ModBuy=OrderModify(OpenBuy,OrderOpenPrice(),OrderOpenPrice()-StopLossAsk
You buy at the Ask and sell at the Bid.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
-
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there, I have minor experience in MQL4, i have encountered a 2 problems with Invalid ticket Order Close error 4108 & invalid stop loss for OrderModoify but for BUY ORDER. Below i have posted the code & picture for the If anyone can help, your help will be appreciated a lot.