Good morning,
Very good, I just don't understand one thing. When I place the order in WIN and WDO the EA opens 6 orders with the number of contracts I entered in "leverage". So even if I want to trade with 1 contract, I can't, it opens 6.
Is this a concept I've overlooked? I'm a beginner, so I'm starting from that premise.
Thank you very much for sharing.
Is this a concept I've overlooked? I'm a beginner, so I'm starting from that premise.
Thank you very much for sharing.
It could be that the system is sending more than one order when you click the mouse, the reasons could be different, but thanks for reporting it 😁👍, to solve this problem, you'll have to add an extra test when you click the mouse, the points to modify or add are marked in GREEN ... make sure you type it in the right way, otherwise the order may not be sent, or it may not be accepted by the server ... but adding this extra test should solve your problem. The logic is as follows: When the mouse is clicked, the STATIC variable will be set, and will only be reset to allow a new order to be sent when the mouse is no longer pressed.
inline void MoveTo(int X, int Y, uint Key) { static double d_block = 0; int w = 0; datetime dt; bool bEClick, bKeyBuy, bKeySell; double take = 0, stop = 0, price; bEClick = (Key & 0x01) == 0x01; //Left click bKeyBuy = (Key & 0x04) == 0x04; //SHIFT Pressed bKeySell = (Key & 0x08) == 0x08; //CTRL Pressed ChartXYToTimePrice(Infos.Id, X, Y, w, dt, price); ObjectMove(Infos.Id, Infos.szHLinePrice, 0, 0, price = (bKeyBuy != bKeySell ? AdjustPrice(price) : 0)); ObjectMove(Infos.Id, Infos.szHLineTake, 0, 0, take = price + (Infos.TakeProfit * (bKeyBuy ? 1 : -1))); ObjectMove(Infos.Id, Infos.szHLineStop, 0, 0, stop = price + (Infos.StopLoss * (bKeyBuy ? -1 : 1))); if ((bEClick) && (bKeyBuy != bKeySell) && (d_block == 0)) CreateOrderPendent(bKeyBuy, Infos.Volume, (d_block = price), take, stop, Infos.IsDayTrade); else d_block = 0; ObjectSetInteger(Infos.Id, Infos.szHLinePrice, OBJPROP_COLOR, (bKeyBuy != bKeySell ? Infos.cPrice : clrNONE)); ObjectSetInteger(Infos.Id, Infos.szHLineTake, OBJPROP_COLOR, (take > 0 ? Infos.cTake : clrNONE)); ObjectSetInteger(Infos.Id, Infos.szHLineStop, OBJPROP_COLOR, (stop > 0 ? Infos.cStop : clrNONE)); };
Good afternoon, where do I set the number of points and number of lots for the mini-index?
Actually, in this code the adjustment is automatic. You tell it the financier and the number of contracts to trade and the code makes the adjustment in terms of points... This information is given when you place the Expert Advisor on the chart. 😁👍
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Developing a trading Expert Advisor from scratch has been published:
In this article, we will discuss how to develop a trading robot with minimum programming. Of course, MetaTrader 5 provides a high level of control over trading positions. However, using only the manual ability to place orders can be quite difficult and risky for less experienced users.
The Expert Advisor presented in this article can be improved in various ways to work with sets of parameters, but this would require more code that will make it more independent from MetaTrader 5.
The great success of this EA is that it uses MetaTrader 5 itself to perform actions that are not in its code, and therefore it is extremely stable and reliable.
Author: Daniel Jose