Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Long time for strategy to enable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Long time for strategy to enable

    Hi

    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====
    }
    Last edited by roberto2014; 09-28-2015, 02:01 AM.

    #2
    Hello roberto2014,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    Can you attach the strategy's .cs file to your response so we may test on out end?
    You will find the file under (My) Documents\NinjaTrader 8\bin\Custom\Strategy on your PC.

    I look forward to assisting you further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    46 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    14 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X