fxDreema

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

    How to make EA to look back past x number of candles?

    Questions & Answers
    2
    2
    1230
    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.
    • P
      polishinglife last edited by polishinglife

      Hello, I have an EA im planning to make.

      1st question is : how can i make EA to look back past x number of candles for the conditions to be met?

      I need the EA to observe the past 100 candles to see if all conditions are met.

      An example of such scenario that requires the above function is:
      To execute sell trade, 4 steps need to be met.

      RSI crosses above 75 - step 1
      RSI falls below 60 but not less than 40 - step 2
      RSI crosses above 75 again -step 3
      Finally, RSI falls below 60 -step 4

      When step 4 is completed, the EA will execute the Sell trade.
      But I want there to be a time limit whereby if all 4 steps are not done within past 100 candles, it will not execute.

      2nd question is,
      I want there to be at least 4 candles above RSI 75 for step 1 and step 3.
      How can I set such setting?

      Thank you all and much love

      T 1 Reply Last reply Reply Quote 0
      • T
        trader.philipps @polishinglife last edited by trader.philipps

        @polishinglife I think you have to loop. However, have those condition be met after another or could there be some other RSI cycles that don't hit above 75 or below 40?

        I'd start a loop from candle ID1 to candle ID100. The last condition is the trigger for the loop.

        Order:

        1. ID1 RSI x< 60 (don't know if x< works here otherwise <)
        2. loop from ID2 to IDx where >75 [exit condition RSI < 40 or loop counter 100]
        3. check if IDx+1 and x+2 were also >75
        4. create another loop for candle IDx+4 until <60 say it's candle IDy with [exit condition RSI < 40 or loop counter 100]
        5. create another loop starting from candle ID y+1 and check if RSI >75. If true asuming candle IDz [exit condition RSI < 40 or loop counter 100]

        For the 75 condition may work this block, but if going backward in the loop you need to care that "iterator+3" is less than 100, where the integer variable iterator is the loop index.
        0_1570548613621_4ad6f696-4909-4c93-bb66-167c3fc7a0eb-image.png

        I like to share my knowledge, but expect the others to contribute as well.

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

        Online Users

        M
        V
        W
        S

        10
        Online

        146.8k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors