Prelude: I am not expert yet, but I have read last few hours documentation and large parts of this forum. I have found, read and played with "C# Solution for Global Storage described ...".
Problem: I would like to have two indicators that work together. One computes a value X in each CalcBar, the second indicator must plot this value.
Background: I would like to have a set of indicators that work as "filters" that other indicators to access before generating a signal that a strategy can use to fire orders.
I have looked at the global storage things and understand roughly how it works. However, it looks for me like each indicator is calculated independent of one another.
(a) How do I get indicators to be calculated bar by bar together? Meaning A.CalcBar() is called and then B.CalcBar() is called?
(b) How can I set/control the behaviour so that always indicator A is calculated before B?
Thanks, Brian
Global Variables and CalcBar() Sequences
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Re: Global Variables and CalcBar() Sequences
Hello Brian,
That is possible to create a function that will calculate the values, then use this function in an indicator or signal for doing plots and generating orders. In this case that is guaranteed that the function will be calculated first, then will be calculated the indicator.
That is possible to create a function that will calculate the values, then use this function in an indicator or signal for doing plots and generating orders. In this case that is guaranteed that the function will be calculated first, then will be calculated the indicator.
Re: Global Variables and CalcBar() Sequences
The problem is more described in the attached image.
(a) The user adds any number of indicators onto the chart. Each indicator has its own parameters and works and draws as it usually does.
(b) The indicators "send" their signals to one central engine. This decides from the sum of the signals whether to make the trade or not.
I know roughly how to get share the signals between the indicators via statics. I have looked at the global examples.
Problem: I want all the indicators to work bar by bar together so that at the end of each bar I have all the signals from all indicators. However, (maybe I am still missing a piece of the puzzle?) to me it looks like the indicators are processed separately from one another.
Or do I miss the forest because of all the trees?
Thanks, Brian
(a) The user adds any number of indicators onto the chart. Each indicator has its own parameters and works and draws as it usually does.
(b) The indicators "send" their signals to one central engine. This decides from the sum of the signals whether to make the trade or not.
I know roughly how to get share the signals between the indicators via statics. I have looked at the global examples.
Problem: I want all the indicators to work bar by bar together so that at the end of each bar I have all the signals from all indicators. However, (maybe I am still missing a piece of the puzzle?) to me it looks like the indicators are processed separately from one another.
Or do I miss the forest because of all the trees?
Thanks, Brian
- Attachments
-
- problem description.jpg
- (351.41 KiB) Downloaded 964 times
-
- problem description.jpg
- (351.41 KiB) Downloaded 949 times
Re: Global Variables and CalcBar() Sequences
I am really still lost. How do I get two indicators to co-operate so that I dont have to cut-and-paste all code into one major indicator/strategy.
Multicharts: is this possible?
Here are two simple indicators (see attached image) where I have reduced the problem to the minimum. Simple: I want them both to draw the same lines, using one value from own indicator, once from other indicator. If this works, then I off to the races.
Somehow I still think I am missing something obvious, for this work in TS, etc.
Multicharts: is this possible?
Here are two simple indicators (see attached image) where I have reduced the problem to the minimum. Simple: I want them both to draw the same lines, using one value from own indicator, once from other indicator. If this works, then I off to the races.
Somehow I still think I am missing something obvious, for this work in TS, etc.
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator{
public class A : IndicatorObject {
[Input] public int toggle { get; set; }
public A(object _ctx):base(_ctx){}
private IPlotObject plotL, plotH;
public static double valueHigh;
public static double valueLow;
protected override void Create() {
plotL = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
plotH = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Blue));
}
protected override void StartCalc() {
A.valueHigh = 27.7;
A.valueLow = 27.3;
}
protected override void CalcBar(){
A.valueLow = Bars.Low[0];
A.valueHigh = Bars.High[0];
plotL.Set(A.valueLow);
plotH.Set(B.valueHigh);
}
}
}
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator{
public class B : IndicatorObject {
[Input] public int toggle { get; set; }
public B(object _ctx):base(_ctx){}
private IPlotObject plotL, plotH;
public static double valueHigh;
public static double valueLow;
protected override void Create() {
plotL = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
plotH = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Blue));
}
protected override void StartCalc() {
B.valueHigh = 29.7;
B.valueLow = 29.3;
}
protected override void CalcBar(){
B.valueLow = Bars.Low[0];
B.valueHigh = Bars.High[0];
plotL.Set(A.valueLow);
plotH.Set(B.valueHigh);
}
}
}
- Attachments
-
- IndicatorsRunningSeparately.jpg
- (250.54 KiB) Downloaded 958 times
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Re: Global Variables and CalcBar() Sequences
Brian, indicators of each chart are calculated in a separate flow. This is an asynchronous process. Here is a concept we have described earlier that can help you to implement what you need. If you need to differentiate the values on a bar by bar basis, that is possible you will need to add an additional parameter that will be passed, like the bar close time.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Re: Global Variables and CalcBar() Sequences
Yes, I had already that post as well. I slightly defeats the purpose. I dont want to manually set the parameters. I dont want to have in code redraw all indicators.
I want the user to add any N number of indicators onto the chart. The user (and the backtest system!) must have access to all the indicator parameters to set them as he wants. The indicators must draw themselves. Then my engine can just get the signals and filters and make decisions.
The important aspect here is SYNCHRONOUS execution BAR-by-BAR of a specific set of indicators together.
Or probably I am just on the wrong road and need somebody to point me in the right direction.
Brian
I want the user to add any N number of indicators onto the chart. The user (and the backtest system!) must have access to all the indicator parameters to set them as he wants. The indicators must draw themselves. Then my engine can just get the signals and filters and make decisions.
The important aspect here is SYNCHRONOUS execution BAR-by-BAR of a specific set of indicators together.
Or probably I am just on the wrong road and need somebody to point me in the right direction.
Brian
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Global Variables and CalcBar() Sequences
May we also know the answer to this topic?zr6bcm, I have sent you a PM.
Re: Global Variables and CalcBar() Sequences
Of course! In summary, I can pay money and they will then program for me a solution. An email to MultiCharts to followup on this is still open, when I get an answer I can post here.
In my personal opinion, and in all respect to Henry, and in all positive impressions I have of MultiCharts, my impressions are: (a) Henry never really understood the problem (assume complexity of English) and (b) that this is an inherent problem of "works as designed" architecture versus "works as expected".
Personally, from looking at the problem from different sides, I have come to the conclusion there is no answer, as each indicator is computed separately on different threads and not synchronously bar-by-bar. I have for the moment put the problem to rest (and sadly also my evaluation of MC.NET) and am evaluating other options.
In my personal opinion, and in all respect to Henry, and in all positive impressions I have of MultiCharts, my impressions are: (a) Henry never really understood the problem (assume complexity of English) and (b) that this is an inherent problem of "works as designed" architecture versus "works as expected".
Personally, from looking at the problem from different sides, I have come to the conclusion there is no answer, as each indicator is computed separately on different threads and not synchronously bar-by-bar. I have for the moment put the problem to rest (and sadly also my evaluation of MC.NET) and am evaluating other options.
Re: Global Variables and CalcBar() Sequences
Having tried every platform out there, the main problem is how certain platforms differentiate between indicators and systems/signals. You should be able to write a signal and have the ability to plot (to any pane in the chart) from within the signal directly without having to create a separate indicator. Separating the two creates a huge code redundancy.
Henry, any thoughts on allowing this functionality down the road? I understand that it is a massive change to the application to do it correctly but perhaps there is a way it could be accomplished through an extension library?
Henry, any thoughts on allowing this functionality down the road? I understand that it is a massive change to the application to do it correctly but perhaps there is a way it could be accomplished through an extension library?
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Global Variables and CalcBar() Sequences
Can a singleton class be used to communicate the data? That way, the multi-thread challenge would likely be solved (if I understand this topic correctly).
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Re: Global Variables and CalcBar() Sequences
Yes, that is possible to do that.Can a singleton class be used to communicate the data? That way, the multi-thread challenge would likely be solved (if I understand this topic correctly).