fxDreema

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

    Loop to compare size of 20 previous candles

    Questions & Answers
    2
    2
    1865
    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.
    • I
      Izis last edited by

      Hello,
      This is my first loop ever done in FXdreema.
      Could you please have a look on it and check if it is correct or I need to write custom code to make it work?
      I would like to compare last closed candle total size(of CandleID=1) with twenty previous candles (CandleID1=2,3,4....)and use a loop for it. If size is grater, it increases count value (+1) and CandleID1 (+1), if not it is checking next candle and doing nothing with count and so on until CandleID1=21. Then if count is grater than 10, the condition is true and if other conditions are met EA sets pending buy order.

      Unfortunately when I added size condition, no single order was set during backtesting.

      https://fxdreema.com/shared/AlHGfVg4

      Thanks in advance for your advices!

      1 Reply Last reply Reply Quote 1
      • M
        miro1360 last edited by

        you have to add a reset of variables before loop:
        0_1543321933122_781f308e-0435-4a24-badb-c8df7745b4bf-image.png

        problem with not opening trades is not in the loop, it is in other conditions before AND block, trades are not opened:
        0_1543322099440_f8e03566-5e53-4426-8be5-40329f863048-image.png

        here are trades opened:
        0_1543322168793_597c84fd-d409-4cf4-b284-663c3247935e-image.png

        but this is not good, because each loop cycle where condition is true will open a trade ...
        you have to create few logic changes:
        0_1543322732405_2604b920-c958-4809-ada8-52664fd1a713-image.png

        Between trading and gambling is a very small gap, be careful.

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

        Online Users

        L
        S
        A
        F

        9
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors