Hello,
On basis your ExampleIndicator I made ExampleStrategy to see how strategy is built with more than one data stream.
code:
------
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
namespace PowerLanguage.Strategy {
public class ExampleStrategy : SignalObject {
public ExampleStrategy(object _ctx):base(_ctx){
Output.Clear();
Output.WriteLine("Class constructor method");
}
private IOrderMarket buy_order;
protected override void Create() {
// create variable objects, function objects, order objects etc.
buy_order = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.Buy));
Output.WriteLine("Create() method");
}
protected override void StartCalc() {
// assign inputs
Output.WriteLine("StartCalc() method");
}
protected override void CalcBar(){
// strategy logic
//buy_order.Send();
if (Bars.CurrentBar <= 10)
{
Output.WriteLine(" CalcBar() method: Bar number: {0}", Bars.CurrentBar);
}
if (BarsOfData(2).CurrentBar <= 5)
{
Output.WriteLine(" CalcBar() method: BarsOfData number: {0}", BarsOfData(2).CurrentBar);
}
}
}}
------
So for the strategy I use two instruments(data) (1min and 5 min.)
And there is result:
Class constructor method
Create() method
StartCalc() method
CalcBar() method: Bar number: 1
StartCalc() method
CalcBar() method: Bar number: 1
CalcBar() method: BarsOfData number: 1
CalcBar() method: Bar number: 2
CalcBar() method: BarsOfData number: 1
CalcBar() method: Bar number: 3
CalcBar() method: BarsOfData number: 1
CalcBar() method: Bar number: 3
CalcBar() method: BarsOfData number: 2
CalcBar() method: Bar number: 4
CalcBar() method: BarsOfData number: 2
CalcBar() method: Bar number: 5
CalcBar() method: BarsOfData number: 2
CalcBar() method: Bar number: 5
CalcBar() method: BarsOfData number: 3
CalcBar() method: Bar number: 6
CalcBar() method: BarsOfData number: 3
CalcBar() method: Bar number: 7
CalcBar() method: BarsOfData number: 3
CalcBar() method: Bar number: 7
CalcBar() method: BarsOfData number: 4
CalcBar() method: Bar number: 8
CalcBar() method: BarsOfData number: 4
CalcBar() method: Bar number: 9
CalcBar() method: BarsOfData number: 4
CalcBar() method: Bar number: 10
CalcBar() method: BarsOfData number: 4
CalcBar() method: BarsOfData number: 4
CalcBar() method: BarsOfData number: 5
CalcBar() method: BarsOfData number: 5
CalcBar() method: BarsOfData number: 5
So why StartCalc() method and all code above row where is used BarsOfData (for first time) is called twice?
It cause problem while debugging in Visual studio as well:
'BarsOfData(2)' threw an exception of type 'ManagedStudies.details._ELAPI_exception_Wrap_' int
Is the any way how to handle the code to have process strategy correct with more then one data?
Thank you in advance.
Startegy computing with BarsOfData(2) - debuging problem [SOLVED]
Startegy computing with BarsOfData(2) - debuging problem
- Attachments
-
- error.png
- Visual Studio Error
- (30.92 KiB) Downloaded 798 times
-
- Capture.PNG
- Setting Chart
- (86.94 KiB) Downloaded 787 times
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Startegy computing with BarsOfData(2) - debuging problem [SOLVED]
Hello Drogo,So why StartCalc() method and all code above row where is used BarsOfData (for first time) is called twice?
Please see the following post.
You need to configure the VIsualStudio to catch only the exceptions you need, not all of them.It cause problem while debugging in Visual studio as well:
'BarsOfData(2)' threw an exception of type 'ManagedStudies.details._ELAPI_exception_Wrap_' int