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 NullPointStrategies, Today, 05:17 AM
    0 responses
    44 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    65 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X