MIR_KAZAN: How do I insert in OrderSend TP, Sl, so that SL contains the High of the previous candle and TP of the Low of the previous candle + TakeProfit ?
For example, like this:
int ticet = 0;
double Stop =0;
double Take =0;
Stop = NormalizeDouble(Low[1]-StopLoss*Point,Digits);
Take = NormalizeDouble(High[1]+TakeProfit*Point,Digits);
ticet=OrderSend(Symbol(), OP_BUYLIMIT, Lots, High[1],10, Stop, Take,"Set bu ForexRobot",Magic,0,clrNone);
if (Ticet==0) Print("Ошибка открытия ордера BUY LIMIT");
Stop = NormalizeDouble(High[1]+StopLoss*Point,Digits);
Take = NormalizeDouble(Low[1]-TakeProfit*Point,Digits);
Ticet = OrderSend(Symbol(), OP_SELLLIMIT, Lots, Low[1],10, Stop, Take,"Set bu ForexRobot",Magic,0,clrNone);
if (Ticet==0) Print("Ошибка открытия ордера SELL LIMIT"); )
In addition, please note that the 4th parameter of the OrderSend() function, the price at which the BUY LIMIT order will be set, must be lower than the current price. And for a SELL LIMIT order, this parameter should be higher than the current price. If you need to set a BUY pending order above the current price, you should use order type OP_BUYSTOP. Read the help on how STOP orders differ from LIMIT ones.
I would also add a check to see where the current price is at the moment of placing the order.
if (Bid>High[1])
ticet=OrderSend(Symbol(), OP_BUYLIMIT, Lots, High[1],10, Stop, Take,"Set bu ForexRobot",Magic,0,clrNone);
.....
if (Ask<Low[1])
Ticet = OrderSend(Symbol(), OP_SELLLIMIT, Lots, Low[1],10, Stop, Take,"Set bu ForexRobot",Magic,0,clrNone);
If I have understood your idea correctly, it should look like this
if the current price is below the minimum of the previous candle, then we will place an SELL LIMIT order at the minimum of the previous candle;
If the current price is above the maximum of the previous candle, then BUY LIMIT on the maximum of the previous candle.
In addition, please note that the 4th parameter of the OrderSend() function, the price at which the BUY LIMIT order will be set, must be lower than the current price. And for a SELL LIMIT order, this parameter should be higher than the current price. If you need to set a BUY pending order above the current price, you should use order type OP_BUYSTOP. Read the help on how STOP orders differ from LIMIT ones.
I would also add a check to see where the current price is at the moment of placing the order.
If I have understood your idea correctly, it should look like this
if the current price is below the minimum of the previous candle, then we will place an SELL LIMIT order at the minimum of the previous candle;
If the current price is above the maximum of the previous candle, then BUY LIMIT on the maximum of the previous candle.
Vitalii Ananev: You need the DayOfWeek() function. Returns the sequence number of the day of the week. For Monday it will be 1. For more details, please read the help.
Why in the beginning of the test is the Expert Advisor profitable, but on the last day of the tester it is losing money?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
How do I insert in OrderSend TP, Sl, so that SL contains the High of the previous candle and TP of the Low of the previous candle + TakeProfit ?
For example, like this:
In addition, please note that the 4th parameter of the OrderSend() function, the price at which the BUY LIMIT order will be set, must be lower than the current price. And for a SELL LIMIT order, this parameter should be higher than the current price. If you need to set a BUY pending order above the current price, you should use order type OP_BUYSTOP. Read the help on how STOP orders differ from LIMIT ones.
I would also add a check to see where the current price is at the moment of placing the order.
If I have understood your idea correctly, it should look like this
if the current price is below the minimum of the previous candle, then we will place an SELL LIMIT order at the minimum of the previous candle;
If the current price is above the maximum of the previous candle, then BUY LIMIT on the maximum of the previous candle.
Maybe you should get a service job?
So the topic is for freeloaders).
Greetings, can anyone tell me how to write a function, I've created a topic and there's silence... I guess everyone's here.
https://www.mql5.com/ru/forum/43095
Thanks in advance.
For example, like this:
In addition, please note that the 4th parameter of the OrderSend() function, the price at which the BUY LIMIT order will be set, must be lower than the current price. And for a SELL LIMIT order, this parameter should be higher than the current price. If you need to set a BUY pending order above the current price, you should use order type OP_BUYSTOP. Read the help on how STOP orders differ from LIMIT ones.
I would also add a check to see where the current price is at the moment of placing the order.
If I have understood your idea correctly, it should look like this
if the current price is below the minimum of the previous candle, then we will place an SELL LIMIT order at the minimum of the previous candle;
If the current price is above the maximum of the previous candle, then BUY LIMIT on the maximum of the previous candle.
How do I make my EA work only on Monday?
If you have a good strategy and are willing to share it, I can write an EA. I invite you to discuss it either publicly or in private messages.
How do I make my EA work only on Mondays ?
You need the DayOfWeek() function. Returns the sequence number of the day of the week. For Monday it will be 1. For more details, please read the help.