EA uses wrong lotsize
-
Hi all, I'm wondering why my EA often uses the wrong lotsize.
EA should trade on DAX40mini where I can trade Mini-Lots (0.1)
I use a constant where I put my max risk in money (e.g. 10 € on a 1000 € account. I know that due to spreads etc. the result is roughly 10 €, but that's ok for me).
The SL is calculated by body sizes of candle 1 + 2 but must not be greater than constant "ATR_High" (in this example 50). To get the Lotsize ("Risk") I use a formula "Money Risk/SL-Size" and round the entire result.
So far the results seem to be correct as they can be seen on the upper left corner of the chart.Here are my issues/questions:
a) Why does the EA not use the "Risk Rounded" but some other "random" Lotsize (e.g. in picture "chart3")
b ) Why is a trade opened though the Risk-Size (SL) is greater than 50 (chart3)?
c) Why do I get an error ("invalid SL requested", picture "chart 1"), when after that message the SL is accepted (picture "chart 2")?
Here is the link to my project: https://fxdreema.com/shared/ycCqrXpXbAny help is appreciated
Thanx in advance

-
To me, there is lots of weird stuff happening in your project. Here's some of them:
- "Once per position" block needs a parent block that seeks the position in question. So the loop "For each position" must be on top there.
- Formula #42 needs the result of formula #15, so those blocks should be linked together, not parallel (although your block IDs luckily avoid problems there)
- You are using candle close ID 3 as the stop-loss level, without checking that this level is below/above for buy/sell trades
- You are using a pip value as trade volume, and furthermore, a pip value converted into a string. Trade size should be a number.
-
@gajus  do you need 1000 free magin to open 1 lot, it is posible that i some case do dont have suficient margin -
Hi @roar, @Alan-paredes2,
thanks for pointing me in the right direction, it looks as if it's still a way to go

@roar: I did change things you suggested but with no better result. Still the Risk seems to be set randomly and not corresponding to the formula and also opens trades when it shouldn't because of the condition in block 44. Why do I have to check SL-level? To me it's part of the trading idea that Close C3 ist below Open C0 (buy) and vice versa on sell@Allan.paredes2
I don't think it's the free margin - the trade should never be opened as the risk-size is greater than ATR-High (see condition block 44) and when the volume shouldn't be higher than 0.2 -
I was able to find the solution by myself. I had two parallel trees of options and formulas. Although i was saving some values like "Volume" or "SL-Size" as variables EA didn't work as expected. I put my formulas inside the "option-tree" and now it works like charm.