fxDreema

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

    Adjusting TP to Include Commission in a Manual Trading Bot

    Questions & Answers
    3
    8
    465
    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.
    • AlirezaTrade
      AlirezaTrade last edited by

      Hello, good day.

      I have a manual trading bot in FXDreema that executes market trades or pending orders when a button is clicked.
      I want the bot to calculate the commission before opening a trade and add it to the take profit (TP) so that the net reward is exactly my target.

      For example, if I want to exit at 1R reward, the bot should first calculate the commission and then adjust the TP so that after deducting the commission, the net reward remains 1R (e.g., the final TP might be 1.3R if the commission is 0.3R).

      Additionally, I use "Risk fixed amount of money" for risk management.
      The stop loss for Sell trades is set at the high of candle ID 1 + spread,
      and for Buy trades, it is set at the low of candle ID 1.

      🤖 https://fxdreema.com/shared/q4BBI9D1c

      @jstap @l-andorrà @miki

      1 Reply Last reply Reply Quote 0
      • l'andorrà
        l'andorrà last edited by

        If the commission is fixed value you can add it directly to your formula, but I guess it is dynamic, right?

        (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

        (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

        (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

        AlirezaTrade 1 Reply Last reply Reply Quote 0
        • AlirezaTrade
          AlirezaTrade @l'andorrà last edited by

          @l-andorrà

          Yes, because I want to use this bot on different brokers, the commission is different.

          But if the commission is a fixed amount, how should I code it?

          1 Reply Last reply Reply Quote 0
          • jstap
            jstap last edited by

            The problem is as you said brokers, and assets have different values. FX can only get this from running trades/orders, I put this together that places an order retrieves the value then deletes the order, not ideal but should work. On backtest it didn't work, test it on a live account and see what it does, it should update if the chart symbol is changed: https://fxdreema.com/shared/RAgL4J6Pb

            Learn fxDreema Without the Wait!

            My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

            The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

            Don’t miss out

            Click here➡️ https://mybook.to/fxDreema to get your copy today!

            Enjoy! 😊

            1 Reply Last reply Reply Quote 0
            • AlirezaTrade
              AlirezaTrade last edited by

              Hello @jstap,

              I reviewed the code you sent, but unfortunately, it didn't work properly. I even tried writing the code as a market buy order, but the issue still wasn't resolved.

              I decided to add an input (constant) for the commission to the bot and set it to something like $7 per lot. Under these circumstances, please guide me on what changes I need to make in the code.

              📌 I intend for the commission to be applied in two different sections:

              1️⃣ In the input lot size: Since my risk management is based on a fixed dollar risk per trade, I want the commission to be included in the total account risk calculation. For example, if I set the risk to $30, this amount should include the commission as well. This means that if the stop loss is hit, the total loss, including the commission, should be $30.

              2️⃣ In the risk-to-reward ratio: I also want the commission to be considered when calculating the take profit. For example, if the risk-to-reward ratio is 1:1, I want the final reward to be calculated as 1 plus the commission amount.

              Ultimately, my goal is that if I am risking $30, in case the stop loss is hit, the net loss should be $30, and in case the take profit is hit, the net profit should also be $30.

              I will send the link to the bot I have written. I would appreciate it if you could review the code and guide me on how to implement these changes.

              🤖 https://fxdreema.com/shared/q4BBI9D1c

              1 Reply Last reply Reply Quote 0
              • jstap
                jstap last edited by

                You can't add candle price to spread (level - fraction (distance)). You can try candle price + 0 (in adjust put, SymbolInfoInteger(NULL, SYMBOL_SPREAD)

                Let me know if it works

                Learn fxDreema Without the Wait!

                My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                Don’t miss out

                Click here➡️ https://mybook.to/fxDreema to get your copy today!

                Enjoy! 😊

                AlirezaTrade 1 Reply Last reply Reply Quote 0
                • AlirezaTrade
                  AlirezaTrade @jstap last edited by

                  @jstap

                  I didn't understand what you meant.
                  If possible, please write the code so I can check it and let you know whether it works or not.

                  1 Reply Last reply Reply Quote 0
                  • jstap
                    jstap last edited by

                    Addt to a project and place a shared link to look at, Ill see what's right/wrong from there

                    Learn fxDreema Without the Wait!

                    My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                    The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                    Don’t miss out

                    Click here➡️ https://mybook.to/fxDreema to get your copy today!

                    Enjoy! 😊

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

                    Online Users

                    S
                    T
                    F
                    I
                    S
                    S
                    G
                    I
                    B
                    D

                    22
                    Online

                    146.6k
                    Users

                    22.4k
                    Topics

                    122.6k
                    Posts

                    Powered by NodeBB Forums | Contributors