static void ResetStart()
{
marginCallBar = 0;
totalOrders = 0;
totalPositions = 0;
isScanned = false;
micron = InstrProperties.Point / 2d;
lastEntryTime = new DateTime();
calculations++;
// Sets the maximum lots
maximumLots = 100;
foreach (IndicatorSlot slot in Strategy.Slot)
if (slot.IndicatorName == "Lot Limiter")
maximumLots = (int)slot.IndParam.NumParam[0].Value;
maximumLots = Math.Min(maximumLots, Strategy.MaxOpenLots);
session = new Session[Bars];
for (int bar = 0; bar < Bars; bar++)
session[bar] = new Session(bar, MaxPositions, MaxOrders);
for (int bar = 0; bar < FirstBar; bar++)
{
session[bar].Summary.MoneyBalance = Configs.InitialAccount;
session[bar].Summary.MoneyEquity = Configs.InitialAccount;
}
ordCoord = new OrderCoordinates[Bars * MaxOrders];
posCoord = new PositionCoordinates[Bars * MaxPositions];
openTimeExec = Strategy.Slot[Strategy.OpenSlot ].IndParam.ExecutionTime;
closeTimeExec = Strategy.Slot[Strategy.CloseSlot].IndParam.ExecutionTime;
openStrPriceType = StrategyPriceType.Unknown;
if (openTimeExec == ExecutionTime.AtBarOpening)
openStrPriceType = StrategyPriceType.Open;
else if (openTimeExec == ExecutionTime.AtBarClosing)
openStrPriceType = StrategyPriceType.Close;
else
openStrPriceType = StrategyPriceType.Indicator;
closeStrPriceType = StrategyPriceType.Unknown;
if (closeTimeExec == ExecutionTime.AtBarOpening)
closeStrPriceType = StrategyPriceType.Open;
else if (closeTimeExec == ExecutionTime.AtBarClosing)
closeStrPriceType = StrategyPriceType.Close;
else if (closeTimeExec == ExecutionTime.CloseAndReverse)
closeStrPriceType = StrategyPriceType.CloseAndReverce;
else
closeStrPriceType = StrategyPriceType.Indicator;
if (Configs.UseLogicalGroups)
{
Strategy.Slot[Strategy.OpenSlot].LogicalGroup = "All"; // Allows calculation of open slot for each group.
Strategy.Slot[Strategy.CloseSlot].LogicalGroup = "All"; // Allows calculation of close slot for each group.
groupsAllowLong = new Dictionary<string, bool>();
groupsAllowShort = new Dictionary<string, bool>();
for (int slot = Strategy.OpenSlot; slot < Strategy.CloseSlot; slot++)
{
if (!groupsAllowLong.ContainsKey(Strategy.Slot[slot].LogicalGroup))
groupsAllowLong.Add(Strategy.Slot[slot].LogicalGroup, false);
if (!groupsAllowShort.ContainsKey(Strategy.Slot[slot].LogicalGroup))
groupsAllowShort.Add(Strategy.Slot[slot].LogicalGroup, false);
}
// List of logical groups
openingLogicGroups = new List<string>();
foreach (System.Collections.Generic.KeyValuePair<string, bool> kvp in groupsAllowLong)
openingLogicGroups.Add(kvp.Key);
// Logical groups of the closing conditions.
closingLogicGroups = new List<string>();
for (int slot = Strategy.CloseSlot + 1; slot < Strategy.Slots; slot++)
{
string group = Strategy.Slot[slot].LogicalGroup;
if (!closingLogicGroups.Contains(group) && group != "all")
closingLogicGroups.Add(group); // Adds all groups except "all"
}
if (closingLogicGroups.Count == 0)
closingLogicGroups.Add("all"); // If all the slots are in "all" group, adds "all" to the list.
}
return;
}