SmartQuant Discussion

Spreads and global hashtable
Page 1 of 1

Author:  azuric [ Mon Mar 03, 2014 6:59 pm ]
Post subject:  Spreads and global hashtable

Hi can anyone explain why this code is not working. It is just showing the count is zero. Not sure why:

using System;
using System.Drawing;

using OpenQuant.API;
using OpenQuant.API.Indicators;

public class MyStrategy : Strategy
public static Instrument i1;
public static Instrument i2;

public int count1;
public int count2;

public override void OnStrategyStart()
i1 = Instruments["BN913"];
i2 = Instruments["BP913"];
if(Instrument == i1)
Strategy.Global["Count1"] = (int)count1;
if(Instrument == i2)
Strategy.Global["Count2"] = (int)count2;

public override void OnBar(Bar bar)
if(Instrument == i1)
count1 = Bars.Count;
int c1 = (int)Strategy.Global["Count1"];
Console.WriteLine("Count BN:" + c1);
int c2 = (int)Strategy.Global["Count2"];
Console.WriteLine("Count BP:" + c2);

Author:  Dr. Anton Fokin [ Mon Mar 03, 2014 7:27 pm ]
Post subject:  Re: Spreads and global hashtable

Why it shouldn't be zero if you add zero count1 and count2 to global table in OnStrategyStart and don't change it elsewhere.


Author:  azuric [ Mon Mar 03, 2014 7:45 pm ]
Post subject:  Re: Spreads and global hashtable

Sorry silly question! See what i have done wrong.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group