Questions from Beginners MQL4 MT4 MetaTrader 4 - page 222
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
You can check the trading robot
//+------------------------------------------------------------------+
//| Experts1.mq4 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp.
#property link "https://www.mql5.com"
input double Lots=0.01;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
( OrderSend(Symbol(),OP_BUY,Lots,3,0,Ask+0.0084,Ask-0.0084)
double lot=Lots;
if profit then Lots=lot+0.01 else Lots=lot-0.01
if Lots=0 then Lots=0.01
if Lots>0.03 then Lots=0.01
//---
//---
return();
}
Good afternoon, dear experts!
Please help, tips on how to do it, where to read, writing part of the code.
I have attached a part of the code. I need to be able to enter my comment when opening an order or a limit order. I.e., not right in the code, but when opening the EA panel.
I need to be able to enter my comment when opening an order or a limit order.
The comment is written when the order is created and cannot be changed again.
The comment is written when the order is created and it can no longer be changed.
Thank you very much. This is exactly what I need.
Please advise how to write a condition whena pending orderwill be moved once at a certain price movement,
1. Create an array in which to store the tickets of open orders and a flag that the order has already been moved.
2. Keep track of newly appearing orders and record in this array information about the open order with the flag "has not moved".
3. Delete information from the array if the order is closed, deleted, or transformed.
4. Check the condition for moving, if the condition is met and the flag "did not move", then move and change the flag to "moved".
1. Create an array in which to store the tickets of open orders and a flag that the order has already been moved.
2. Keep track of newly appearing orders and record in this array information about the open order with the flag "has not moved".
3. Delete information from the array if the order is closed, deleted, or transformed.
4. Check condition for moving, if condition has come and flag "did not move", then move and change flag to "moved"
I don't think it's reliable.
I would solve such a problem in a simpler way: put a pending order with magic number 2 and delete a pending order with magic number 1 under the condition of which the order should be moved
The code would be simple - after the tick receipt, the loop would loop through the order with magic number 1 if it is found and needed to move, then we would delete this order and place a new one with magic number 2
Yes, it's a good option.
Yes, that's a good option.
UPD: the code will be simple - when the tick comes the loop on the order with magic number 1 if found and need to move, then delete this order and set a new order with magic number 2
.... then we will try to set a new order with magic number 2 and if it is OK then we will delete the order with magic number 1
so less checks to come up with - for example levels of stop level has expanded and will not be able to move the order once and we have already deleted the order found
that way ;)