Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimiztion && backtest take lot of time

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

    Optimiztion && backtest take lot of time

    first i run bulid in staregy to check if its my computer problem or not , the Optimiztion running fast and good,
    then i run my code and all goes very slow
    what change in the code to get better running ?

    else if (State == State.Configure)
    {
    AddDataSeries("MES 03-25", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    SetStopLoss("", CalculationMode.Ticks, Stoplossbyticks, false);
    SetProfitTarget("", CalculationMode.Ticks, TPbyTicks);

    }
    }
    double currLowNq = 0;
    double currLowEs = 0;
    double esHighestHigh = 0;
    double esLowestLow = 0;

    double nqhighestHigh = 0;
    double nqlowestLow = 0;
    protected override void OnBarUpdate()
    {



    if (BarsInProgress == 1 )
    {
    // Get the highest high and lowest low for ES
    esHighestHigh = SampleGetHighLowByTimeRange(5, 17, 8, 0).HighestHigh[0];
    esLowestLow = SampleGetHighLowByTimeRange(5, 17, 8, 0).LowestLow[0];

    // Log ES values
    Log("ES Highest High between 5:17 AM and 8:00 AM: " + esHighestHigh, LogLevel.Information);
    Log("ES Lowest Low between 5:17 AM and 8:00 AM: " + esLowestLow, LogLevel.Information);
    }

    if (BarsInProgress == 0 )
    {

    nqhighestHigh = SampleGetHighLowByTimeRange(5, 17, 8, 0).HighestHigh[0];
    nqlowestLow = SampleGetHighLowByTimeRange(5, 17, 8, 0).LowestLow[0];




    Log("Highest High between 5:17 AM and 8:00 AM: " + nqhighestHigh, LogLevel.Information);
    Log("Lowest Low between 5:17 AM and 8:00 AM: " + nqlowestLow, LogLevel.Information);
    }

    currLowEs = Lows[1][0];
    Log("curr low es " + currLowEs, LogLevel.Information);
    currLowNq = Low[0];
    Log("curr low nq: " + currLowNq, LogLevel.Information);


    if (currLowNq < nqlowestLow && currLowEs >=esLowestLow && BarsInProgress == 0 && Time[0].Hour == 5 && Time[0].Minute > 17 )
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");


    }




    }
    region Properties
    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name = "Stoplossbyticks", Order = 1, GroupName = "Parameters")]
    public int Stoplossbyticks
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name = "TPbyTicks", Order = 2, GroupName = "Parameters")]
    public int TPbyTicks
    { get; set; }
    #endregion
    }
    }

    #2
    Hello matanamar,

    That may be due to using Log, you should be using Print for outputting debug information. Log has to write that data to file and will be overall much slower to output the information.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Working...
    X