Hey,
I am having the same problem as well. It seems that my code is being trigged and buying massive amounts of units over and over again on the same candle stick instead of being triggered by the trend happening within the candle stick. Since I am new to this there must be something I am missing. If I only want 1 indication of a buy/sell within a candle stick how do I properly exit out of the code once a signal has been triggered in the evaluation candle stick? I am currently using the Bars() as my counter which from my understand is counting the bars within a graph and not the ticks? But when I test this I dont think this is the case. Am I on the right track here?
No such thing as Bars(). Bars is unreliable, once you reach max bars on chart it won't change. Volume is unreliable, you can miss ticks. Always use time: My code
Thanks the Answer on the other thread. I had this same issue and I traced it back to a error inside a Program at the dealing desk. They Miss reported Server is busy.... At least that is my feeling. When a Order is sent the dealing desk for x amount of time they lock out all other orders to prevent atomic conditions. When did this they display all the not enough money. They should say we are busy. Anyway They lock out the funds and report out of money. This causes me to lower lots size and ALERT the USERS NOW.! .... It was really irritating ...... The Software. I was dealing with was in between Metatrader and the dealing desk and is called a MAT multi access terminal ..it is for CTA's and CPO's so several access point had hit the dealings desk multiplexers. They place mat in front of the multiplexer.
Use a mutex around your logic so that you get the lotsize calculation through opened order result. When you calculated the lotsize for the second order, you were using stale values because you were already in the process of opening the first order.
Server is busy only occurs when you send the orders to the server at the same time.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The journal displays:
EURUSD,M1: OrderSend error 134
Tester: PrevBalance: 9455.32, PrevPL: 2958.73, PrevEquity 12414.05, PrevMargin: 12015.81, NewMargin: 12417, FreeMargin: -3.41
Tester: not enough money for buy 0.30 EURUSD at 1.23443
EURUSD,M1: mf=378.3239 mpl=1234.34 lm=0.3065 ls=0.3065 min=0.01
The output from the Print shows free margin was $378 and generated a maximum lot size of 0.30. But the tester doesn't agree with MarketInfo.
At the end of the routine, I added:
and AFMC matches the tester's FreeMargin output.