This is my code....
I have variours time series being added in Initialize() method and tonne of variables being used in the code. The startegy is taking atleast 15 min to enable itself when I try to enable in the strategy window. ..... I have even kept barsrequired to zero in parameters.
Please help.
public class test : Strategy
{
#region Variables
private int profit =10,profit2=50,stop=200,maxTrades=8,trail1=2,sprea d=100,squeeze=30,q=300000,gain=1000,loss=-800,nbar=3,winbar=20,losebar=10;
private int tradeCounter = 0; // This variable represents the number of trades taken per day.
private int priorTradesCount = 0;
private double priorTradesCumProfit = 0;
private int priorCount = 0;
private double priorCumProfit = 0;
// Wizard generated variab les
private string path1 = @"C:\logs\";
private string path2 = DateTime.Now.ToString("ddMMyy") ;
private string path= "C:\\Users\\Administrator\\AppData\\Roaming\\MetaQ uotes\\Terminal\\B3AD00E60C4FED07DC761A30A564C6E9\ \MQL4\\Files\\";
private string pathcapital= "C:\\Users\\Administrator\\AppData\\Roaming\\MetaQ uotes\\Terminal\\70933713A5E7A19E5E237AA178E5C022\ \MQL4\\Files";
private string ohlc="";
bool entrycond = false;
bool tu1=false,tu2=false, tu3=false,tu4=false,tu5=false,tu6=false,tu7=false, tu8=false,td1=false,td2=false,td3=false,td4=false, td5=false,td6=false,td7=false,td8=false;
bool tu1dc=false,td1dc=false;
bool tu1dc60=false,td1dc60=false;
bool tu9=false, td9=false,tu10=false, td10=false,tu11=false, td11=false;
int avcount =1;
double avsma=0,globalpl=0;
double[] av = new double[13];
private IOrder entryOrder1 = null;
private IOrder entryOrder2 = null;
private IOrder entryOrder3 = null;
// User defined variables (add any user defined variables below)
#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()
{
CalculateOnBarClose =true;
//AccountSize=1000000;
//TraceOrders = true;
this.QuantityType = QuantityType.DefaultQuantity;
this.DefaultQuantity = q;
SyncAccountPosition = true;
Add(PeriodType.Tick, 1); // given an index value of 1
Add(PeriodType.Minute, 5); //index 2
Add( PeriodType.Minute, 15); //index 3
Add( PeriodType.Minute, 15); //index 4
Add( PeriodType.Minute, 15); //index 5
Add( PeriodType.Minute, 30 ); //index 6
Add( PeriodType.Minute, 60 ); //index 7
Add( PeriodType.Minute, 480 ); //index 8
//Add( PeriodType., 1); //index 6
BarsRequired =0;
EntriesPerDirection = 2;
EntryHandling = EntryHandling.AllEntries;
path2=path2+ Instrument.FullName+".txt";
ExitOnClose = false;
}
public override void Dispose()
{
base.Dispose();
// clase the db connection at the end
if (connection != null) {
connection.Close();
connection = null;
}
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBars[1]<BarsRequired||CurrentBars[2] <= BarsRequired||CurrentBars[3] <= BarsRequired||CurrentBars[4] <= BarsRequired||CurrentBars[5] <= BarsRequired||CurrentBars[6] <= BarsRequired){
Print("Not enough Bars: "+Instrument.FullName+" "+ BarsInProgress);
return; }
if(!FirstTickOfBar) return;
if (BarsInProgress==1 )
{
prevTick = currTick;
currTick = Close[1];
}
// ====logic follows after this====
}
Comment