Pass variable to external indicator

I’m sure this is a simple answer, but I can’t seem to find it.

How do I pass GUI-set variables to an external Indicator?

I have the other Indicator on the chart, and it has values set in its GUI, and I want the other Indicator that uses those plots to use the plots that are actually visible on the screen. What I’m getting, however, is that the calling Indicator uses values for the plots that would be generated using the default values for the external Indicator.

I have a variable in the GUI for the calling Indicator, which is set to match the plot that’s on the screen, and I thought I was passing that properly through the external call, but it’s still using the wrong values.

Thanks in advance!

After a little more digging, I finally figured it out. I didn’t realize it had to have [NinjaScriptProperty] in the variable definition in the external Indicator.

	// In Target Indicator
	[NinjaScriptProperty]
	[Display(Name="Period", GroupName="Parameters", Order=1)]
	public int Period { get; set; } = 14;

	// In Calling Script
	var myInd = MyIndicator(Period: 20);

You can pass the argument by name, as is shown here, or you can just pass the proper variables in comma-delimited sequence, using the IntelliPrompt as your aid.

Thanks everyone!

1 Like