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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    128 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    65 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    117 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X