fxDreema

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

    Check sell before buy

    Questions & Answers
    2
    3
    889
    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.
    • E
      Eric last edited by

      Hi

      I am new to this and hope for some help in the rigth direction

      I have a simple long only strategy that opens trades (buy) when price cross an indicator level,
      we can call the condition A

      and close the trade (sell) when price cross an another indicator
      we can call the condition B

      The problem is i want to use a filter when enter buy (A)
      and A give more than one signal when price rise to a new high and i risk getting in at the end of the move

      So the thing i want to do is to check that B condition has happened just before condition A
      so i can act on the first buy signal

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

        If "happened just before" can be described as something happened in the previous candle, then just set bigger number in "Candle ID" parameter (in Condition click on More settings). MetaTrader knows candles history data and indicators data, so if this data can be used - use it. I mean... in the present moment you ask for information in the past, and this is the best way to do conditions, because the data is always there are can be easily read.

        If two conditions should be true at the same time, then connect them one after another.

        If you don't know the exact time when B happened (the time between B and A is not the same every time), then you should use variable. Let's say the variable is initially "0" and becomes "1" when B happens. When before checking A you check if that variable is "1"... and then reset it back to "0" for the next turn.
        Variables can be defined in "Variables" (see on the right) and modified in many ways (for example "Modify Variables" block). Similar to this, blocks from category "Flags" can be used... they should be used in such situations actually.

        1 Reply Last reply Reply Quote 0
        • E
          Eric last edited by

          Thanks for the input 🙂

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

          Online Users

          M
          A
          E

          12
          Online

          146.7k
          Users

          22.4k
          Topics

          122.6k
          Posts

          Powered by NodeBB Forums | Contributors