fxDreema

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

    Variables do not work correctly...

    Questions & Answers
    2
    2
    463
    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.
    • rsquared1
      rsquared1 last edited by rsquared1

      Hello,
      I am currently trying to create a ea based on the tdi and heiken ashi indicators.
      I came across a problem which I can't fix for some reason.
      I created a workaround for an array to save values in variables.
      0_1630630948724_1.PNG
      1_1630630948725_2.PNG
      The variable ha_dir_trend_counter is reset before every run of the "array workaround"... (ha_dir_trend_counter = 0;)
      The ea then identifies long/short heiken ashi candles. Afterwards 1/-1 is saved in the variable ha_dir (ha_dir = -1; or ha_dir = 1;).
      Then I use the array workaround to move all variables one spot up in the array (e.g. ha_dir_bar_12 = ha_dir_bar_11; etc. and save the ha_dir value into ha_dir_bar_1)
      Afterwards I am checking the saved "array" for trend pattern but here the problem starts... The reset of the ha_dir_trend_counter doesnt work. It somehow always increments... here is some console output I generated to debug:
      2021.09.03 02:48:57.440 2020.01.02 05:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
      2021.09.03 02:48:57.428 2020.01.02 04:00:00 TDI_Version_2 EURUSD,H1: Alert: 5.0
      2021.09.03 02:48:57.428 2020.01.02 04:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
      2021.09.03 02:48:57.412 2020.01.02 03:00:00 TDI_Version_2 EURUSD,H1: Alert: 4.0
      2021.09.03 02:48:57.412 2020.01.02 03:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
      2021.09.03 02:48:57.400 2020.01.02 02:00:00 TDI_Version_2 EURUSD,H1: Alert: 3.0
      2021.09.03 02:48:57.400 2020.01.02 02:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
      2021.09.03 02:48:57.388 2020.01.02 01:00:00 TDI_Version_2 EURUSD,H1: Alert: 2.0
      2021.09.03 02:48:57.388 2020.01.02 01:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0
      2021.09.03 02:48:57.368 2020.01.02 00:00:00 TDI_Version_2 EURUSD,H1: Alert: 1.0
      2021.09.03 02:48:57.348 2020.01.02 00:00:00 TDI_Version_2 EURUSD,H1: Alert: 0.0

      Why does this happen?

      Thanks in advance... I'm sry for the confusing representation of the problem...

      jstap 1 Reply Last reply Reply Quote 0
      • jstap
        jstap @rsquared1 last edited by

        @rsquared1 From what I see this should work, you could try separating this code and placing a modify variables block in between custom code blocks to solely reset the variable, or maybe just separating will ensure one task is finished before starting the next.

        Learn fxDreema Without the Wait!

        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

        Don’t miss out

        Click here➡️ https://mybook.to/fxDreema to get your copy today!

        Enjoy! 😊

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

        Online Users

        R
        A
        E

        15
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors