Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    31 views
    0 likes
    Last Post love2code2trade  
    Started by cls71, Today, 04:45 AM
    2 responses
    10 views
    0 likes
    Last Post eDanny
    by eDanny
     
    Started by proptrade13, Today, 11:06 AM
    0 responses
    5 views
    0 likes
    Last Post proptrade13  
    Started by kulwinder73, Today, 10:31 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by RookieTrader, Today, 09:37 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X