Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Plots for Strategy Builder

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

    Using Plots for Strategy Builder

    Hi,

    I have developed an indicator that I would like to make strategy builder friendly. I have ready through the forum and see that I need to associate the values I want to track with a plot so that I may access them in the strat builder. When I add a plot though I find that I the strat builder still doesn't seem to have access to the values.

    How do I set up this plot to be usable in the strategy builder?

    In the Strategy Builder:
    Condition: MyIndicator = 3
    Action: Enter Long

    My Code:
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> LegType
    {
    get { return Value; }
    }

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    AddPlot(Brushes.Transparent, "LegType");
    }
    }

    protected override void OnBarUpdate()
    {
    if (something happens)
    Value[0] = 1;
    else if (something else happens)
    Value[0] = 2;
    else
    Value[0] = 3;
    }

    Thanks for all the help!

    #2
    Hi Kreyenhagen, thanks for writing in.

    This should show up in the builder. Did you try Printing the value? I also attached a test indicator that is showing up in the builder properly.

    https://clauber.tinytake.com/msc/NjAzNTAwMF8xODI3MTgxOA - print example

    Best regards,
    -ChrisL
    Attached Files

    Comment


      #3
      Hi Chris!

      I just tried printing the value and that worked great. Printed a 3 like it was supposed to. Once I add an Enter Long action though it still prints 3 but doesn't enter long... At least I know the indicator is working as it's supposed to.

      Comment


        #4
        Hi Kreyenhagen, thanks for your reply.

        If you can provide some more details I can help out more if needed.

        Best regards,
        -ChrisL

        Comment


          #5
          Hi Chris,

          Thanks for your help so far, I really appreciate it!

          After playing around with it for a bit I figured out that it does enter into trades properly when using the single plot. For some reason it needed to ignore the first potential trade, and then on the second one it would start entering into trades. It stopped doing this after a few attemps so I'm unsure of why that was happening. Now it appears to be working fine with the single plot.

          Anyways now that that is all sorted, I tried adding more plots to set the profit target and stop loss. When I print these values it works great again, but when I assign these values to the profit target and stop loss I get this error: "Strategy 'MyIndicator': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object."

          Attached Files

          Comment


            #6
            Hi, thanks for your reply.

            The strategy builder can not use indicator values within the Stop and Target section because it places the code within the State.Configure state, before any data is loaded. The script needs to be unlocked to place the stop and target in OnBarUpdate to use the indicator value as the limit/stop price.

            Best regards,
            -ChrisL

            Comment


              #7
              Thanks for all your help Chris!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              579 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X