fxDreema

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

    Are there

    Questions & Answers
    2
    5
    393
    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.
    • K
      kobiewel last edited by

      Need simple ea help

      K 1 Reply Last reply Reply Quote 0
      • K
        kobiewel @kobiewel last edited by

        Ea must open 1 buy trade at a chosen price. Trade must automatically close on chosen stop loss or profit. If trade hits stop loss another trade only opens at first chosen price. This must loop until manually closed or hit profit target.

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

          Hey, @kobiewel

          Unfortunately, this is really vague and it's going to be really difficult to assist.

          If you want an EA to open a trade at a chosen price, you can store the price you want to open trades at as a constant, or in a variable if you use some formula or indicator to calculate the price.

          You can also store the SL in pips, price, etc in variables or constants also, depending on if you want to specify it or variables if you want to retrieve that value from something else like an indicator or a calculation of some type.

          If the entry price and SL are stored in variables, as long as you don't have the loop set to recalculate these variables every time it passes through, then there's no issue placing trades at the same price (you could just use limit orders, also since everything is predefined, but that's your call).

          I'm still not sure I fully understand your question, so my ability to answer is limited, but you might try something like

          Condition True, change bool value from false to true.

          Then have a condition near the top of your structure that says "If bool true" then have all your trade logic stuff over on the true side. That way if the bool is false, then it updates your conditions, but once the bool is true, it keeps following the trade logic stuff you define and not your conditions/variables.

          I don't believe there's a way to tell if a TP was hit or not, but you can check if the trade was closed at a profit (and if the TP is the only profitable method for closing the trade, then checking that the trade was closed with profit should be enough).

          For this part, you might do something like

          If bool true,
          place limit order at price/SL determined earlier.

          Then you can elsewhere have an "if no trade/order", last trade closed with profit, then bool = false. That way it stops placing new orders. If trade was closed at a loss, then it leaves the bool true.

          I'm sure there's pieces I'm missing, but this general logic should work. Because your question was kinda vague, this is about the best I can say. Hopefully, this helps you solve your problem, at least.

          1 Reply Last reply Reply Quote 0
          • K
            kobiewel last edited by

            Thank u for your help.
            I have tried various ways to write this without success. I guess i just do not understand how this all works. Is there a basic ea for opening trades where i can decide at what price it needs to open and close with stop loss . Say i want to open a buy trade on EUR/USD at 1.1800 and close at 1.1795 stop loss. I also want to set a take profit. This ea must then always open a new trade at 1.1800 after hitting set stop loss until i cancel the trade.

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

              @kobiewel said in Are there:

              ere i can decide at what price it

              It sounds like you're really new and you're getting ahead of yourself a little bit. I'd really recommend thumbing through the FAQ example builds that FxDreema provides as a basic launching point (even if it means just building things you don't even intend to use, just for practice).

              You need to create inputs for your Entry, SL, TP, and maybe a bool (T/F) for if you're placing longs or shorts.

              You'd probably want to work with pending orders and not "buy now" since you're working with a specific price.

              You can go to your "on init" tab an simply set up a "once per bar", into a "No trade/Pending order", into a condition block that checks if you have true or false selected (for placing buy/sell), then out one side, place a pending sell at specified price with specified TP/SL, and the pending buy on the other side.

              Since you also have this added criteria that if the last trade was a loss, then to open a new trade, you can Once per bar (or leave it on tick if you must depending on your strategy, just going to be more resource demanding) into a "no trade/pending order", into a check profit of last closed trade, see if it was a loser. If it was, then it checks your true/false condition for buy sell, into a new pending buy/sell order, just like the last step, if that makes sense. If it was profitable on the last trade, if you don't connect anything there, then it will break the loop.

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

              Online Users

              E
              F
              E
              G
              M
              C
              E
              L
              K
              E
              S
              E
              P

              26
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors