fxDreema

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

    Coding Problem - comparing two prices

    Questions & Answers
    2
    4
    835
    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.
    • U
      uchiha last edited by

      Hello people I'm new to this software, and I have a problem thats giving me quite the headache...here's a statement of what I am trying to code:

      The current trade signal should be compared to the last trade of the same direction (the current buy/sell signal is compared to the previous buy/sell trade), if that trade ended in profit or break-even, the current trade can be opened as per the (buy/sell) signal, but** if the trade was a loss (stop loss or direct loss) then, do not open the trade unless the current signals price is higher (for BUY signal)/lower (for SELL signal) than the previous trades’ entry price.**

      I would appreciate any ideas and contribution. Thanks

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

        This is not correct: http://prntscr.com/4kgpfz
        Group mode is a string parameter with undocumented values, I will not recommend to use variables for this parameter and most of the drop-down (with multiple options) parameters.

        Otherwise I think you are doing it good. With "For each Closed Trade" you can load the last closed trade and do something with it. Note that when this block loads a trade, only pink blocks can be used to work with that particular trade. Other type of blocks can be used in the loop as well, but they work for themselves. For example, block 19 does not load the last buy trade for block 20, block 20 still works with the trade loaded in block 14.
        Again, I will not recommend to use non-pink blocks under "For each...." block, but when needed - no problem.

        So, if your Buy was closed on loss, you don't want to open new Buy when the current price is higher than the open price of the losable closed Buy. But you will probably be ok with opening a new sell. Then, can we say that you want to just invert the next trade on loss? If the last losable trade was Buy - wait for Sell condition?

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

          Or something like this: https://fxdreema.com/shared/hAdvsbOac
          This is the result: http://prntscr.com/4kgw6p

          I used two variables, AllowBuy and AllowSell. They can have values 0 or 1. They are both set to 1 in block 2, and then depending on the last closed trade - one of them is set to 0.
          Then, before buying/selling these are checked.

          1 Reply Last reply Reply Quote 0
          • U
            uchiha last edited by

            Thanks for the education, you sure put a lot into fxdreema

            I have modified the format based on your example and advice, it would be great if you could look through it and tell me if it functions like I described it in the template. Please also have a look at the 'onTrade' section. Any other advice to complete the EA is welcome. Also is it possible to know the right slippage number to use?

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

            Online Users

            H
            H
            G

            12
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors