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, 05-11-2026, 05:56 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    32 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    195 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    356 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    274 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X