fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    EA uses wrong lotsize

    Questions & Answers
    3
    5
    557
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gajus last edited by

      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/ycCqrXpXb

      Any help is appreciated
      Thanx in advance

      chart3.png chart2.png chart1.png

      A 1 Reply Last reply Reply Quote 0
      • roar
        roar last edited by roar

        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.

        Need small help? Tag me in your post
        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

        1 Reply Last reply Reply Quote 0
        • A
          Alan.paredes2 @gajus last edited by Alan.paredes2

          @gajus ![alt text](a7fadcfd-5bf5-493e-a745-301d65647998-image.png image url) do you need 1000 free magin to open 1 lot, it is posible that i some case do dont have suficient margin

          1 Reply Last reply Reply Quote 0
          • G
            gajus last edited by

            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

            1 Reply Last reply Reply Quote 0
            • G
              gajus last edited by gajus

              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.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              Online Users

              H
              G

              10
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors