Chosen instrument name is not "stored" when a new instance of strategy created through the subsequent call of Initialize() method.
It most likely happens all the time when creating a new instance of a strategy and than trying to edit the same strategy. My experiment focused on the "Strategy" tab.
Steps to recreate I've used the SampleMACrossover, saved as SampleMACrossover02 and made the code changes below in red and bold.
Compile the new strategy and than create a new instance on the "Strategy" tab.
Select other then default Instrument and account...
Click ok than highlight and edit the strategy and see how the Instrument Name will change...
See results on the output window
note: OnbarUpdate() seems to work fine...
My problem is that my DB based initialization done through the Initialize() method is messing up my custom settings. I am able to work around this doing it again in the OnbarUpdate() however that is not the behavior I am expecting when the Initialize() method is called.
Please advise! Thanks atata,
#region Variables
private int fast = 10;
private int slow = 25;
private string sInstrumentName;
private string sAccountName;
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Print("++++++++++++ Start SampleMACrossOver02 - Initialize() +++++++++++++++++");
sInstrumentName = Instrument.FullName.ToString();
Print("sInstrumentName is... " + sInstrumentName);
sAccountName = Account.Name.ToString();
Print("Account Name... " + sAccountName);
SMA(Fast).Plots[0].Pen.Color = Color.Orange;
SMA(Slow).Plots[0].Pen.Color = Color.Green;
Add(SMA(Fast));
Add(SMA(Slow));
CalculateOnBarClose = true;
Print("++++++++++++ Done SampleMACrossOver02 - Initialize() +++++++++++++++++");
}

Comment