Input's location
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Input's location
Because they are C# properties (so methods), and therefore need to be placed inside the indicator's or strategy's class (because all methods need to be placed inside a class). They can also not be placed inside another method (or property), because methods can't be nested (but they can call each other, though).Question: Why do the inputs for a study have to be at a particular place within the class?
However, besides those limitations the properties can be placed everywhere. For instance:
Code: Select all
namespace PowerLanguage.Indicator
{
public class Snippet_Indicator : IndicatorObject
{
[Input]
public int FirstInput { get; set; }
public Snippet_Indicator(object _ctx) : base(_ctx) { }
protected override void StartCalc()
{
}
[Input]
public int SecondInput { get; set; }
protected override void CalcBar()
{
}
[Input]
public int ThirdInput { get; set; }
}
}
More about properties can be found here: MSDN and MSDN properties.
Re: Input's location
Hi Josh,
I should have been clearer on my question. The problem I am running into is that if I move my properties to the bottom of the class definition the strategy compiles fine but when I add it to a chart I receive an error. If I move my properties right after the class constructor everything works fine when I add it to a chart.
I should have been clearer on my question. The problem I am running into is that if I move my properties to the bottom of the class definition the strategy compiles fine but when I add it to a chart I receive an error. If I move my properties right after the class constructor everything works fine when I add it to a chart.
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Input's location
Not sure if I follow you. Do you mean the properties themselves (like the ones I showed in the code example in my post), or giving the properties a default value?I should have been clearer on my question. The problem I am running into is that if I move my properties to the bottom of the class definition the strategy compiles fine but when I add it to a chart I receive an error. If I move my properties right after the class constructor everything works fine when I add it to a chart.
If I add the snippet example from my previous post to the chart, it works fine (on MultiCharts .NET64 Version 9.0 Release (Build 10362)):
I don't have the issue that the last property (`ThirdInput` which is at the bottom of the class) doesn't work or gives an error.
- Attachments
-
- scr.22-10-2015 17.31.14.png
- (1.5 KiB) Downloaded 986 times
Re: Input's location
That's exactly the issue I'm having. No big deal as I can just put them up further in the class definition for the strategy I'm working on, but I assumed that it was a requirement or something.