Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access a var from an indicator in a Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    laocoon, I'm not sure why you would see this error - what code did you use to call / integrate the Swing indicator in your strategy?

    Thanks,

    Comment


      #17
      Hi Bertrand

      Thanks for your reply. I just used this line in the variables section:
      double mySwingHigh = Swing(3).SwingHigh[0];

      And this one in my entry criteria:

      if (High[0] >= MAX(SwingHigh,3)[0]-5*TickSize)
      {
      DrawArrowUp("SwingLong" + CurrentBar, false, 0, Low[0]- 2*(TickSize), Color.Black);
      PlaySound("Swing.wav");
      }

      Thanks

      Comment


        #18
        Originally posted by laocoon View Post
        Hi Bertrand

        Thanks for your reply. I just used this line in the variables section:
        double mySwingHigh = Swing(3).SwingHigh[0];

        And this one in my entry criteria:

        if (High[0] >= MAX(SwingHigh,3)[0]-5*TickSize)
        {
        DrawArrowUp("SwingLong" + CurrentBar, false, 0, Low[0]- 2*(TickSize), Color.Black);
        PlaySound("Swing.wav");
        }

        Thanks
        (Emphasis mine) Your double assignation is trying to assign an output from an indicator when the variable is initialized. The variable value changes, so you want to assign it in OnBarUpdate(), after simply declaring it in Variables.

        Comment


          #19
          Please declare your variable in the variables section only, then set the indicator value in your OnBarUpdate().

          Comment


            #20
            Got it, thanks a lot Bertrand & Koganam.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            646 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            367 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            570 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X