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 charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            61 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            149 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            162 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            99 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            286 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X