Topics

Forum Topics not found

Replies

roul.charts
13 Jul 2024, 15:32

Update

Is there any update? I have just finished MCU my algo with 3000 lines of code. Backtesting and optimisation are fine. But without an Walk Forward test I'm not really happy to activate the Algo on my live account. 

 

Is the only option to switch the platform??


@roul.charts

roul.charts
13 Jul 2024, 15:32

Update

Is there any update? I have just finished MCU my algo with 3000 lines of code. Backtesting and optimisation are fine. But without an Walk Forward test I'm not really happy to activate the Algo on my live account. 

 

Is the only option to switch the platform??


@roul.charts

roul.charts
02 May 2024, 18:38 ( Updated at: 03 May 2024, 07:18 )

RE: RE: RE: CPU - Ryzen or Intel - Optimization/Backtesting

PanagiotisChar said: 

joel.salinaszk said: 

PanagiotisCharalampous said: 

Hi Jiggytrade,

To utilize all cores, you can apply this workaround and you should be fine.

Best Regards,

Panagiotis 

Join us on Telegram 

Hi Panagiotis, does this works on windows 11? i could not find  the /apps folder

Hi Joel,

This is a very old issue. I don't think this workaround is applicable or necessary on cTrader anymore

I came across this post. So first: Yes Ryzen rocks i'm optimizing on a simple machine but with Ryzen 9 5950X - and that is way faster then my old Dual Xeons.


2nd: I'm connecting to the Optimizer instances via Remote Desktop and after a while every time i'm reconnecting, the slider of the CPU Usage in the Optimizer mode is shifted back.
I start the optimizer like this:

I can reconnect from different machines and it stays at 100% in the first minutes:

 

But once the table is adding the scroll button on the right side - or it runs for the 2nd batch like here 64 passes or it adds the remaing time: the CPU slider wents down to 31% after each reconnect:

 

I can pull the slider up to 100% - reconnect and it goes down to 31% every time. That is really annoying…
 

I'm on Version 4.9.2.26009 but the bug was there in the previous versions also…


@roul.charts

roul.charts
20 Apr 2024, 09:23

RE: RE: cTrader backtests executes take profits often to optimistic. Seems like a bug

PanagiotisCharalampous said: 

roul.charts said: 

I'm also wondering when a stored TP is executed.

I'm in Tick-Data Backtester / Optimizer Mode
I had my own TP logic:
tpHit = position.TradeType == TradeType.Buy ? currentPrice >= targetTpLevel : currentPrice <= targetTpLevel;

And also set the same TP at Trade Execution direct with the SL in the Trade ID.

My code is always executed faster at a TP Level then the built in TP in Backtesting. I can't imagine why. Even if I set a threshold that my code is executed later - after the TP is reached. 
My code is executed earlier then the built in TP.

My aim was to let the built in TP close the trade if i only buy 1 lot instead of running through my code…

Hi there,

It is hard to understand your problem from an abstract description. Feel free to share source code and exact steps to reproduce what you are looking at and we will have a look.

Best regards,

Panagiotis

Ok, i can't share the whole bot. It's 3000 lines of code already. But i can make an example bot to show the difference / timing of TP execution. Is the Trade TP executed OnTick or OnBar if i'm in the backtester mode?

 


@roul.charts

roul.charts
20 Apr 2024, 00:15

I'm also wondering when a stored TP is executed.

I'm in Tick-Data Backtester / Optimizer Mode
I had my own TP logic:
tpHit = position.TradeType == TradeType.Buy ? currentPrice >= targetTpLevel : currentPrice <= targetTpLevel;

And also set the same TP at Trade Execution direct with the SL in the Trade ID.

My code is always executed faster at a TP Level then the built in TP in Backtesting. I can't imagine why. Even if I set a threshold that my code is executed later - after the TP is reached. 
My code is executed earlier then the built in TP.

My aim was to let the built in TP close the trade if i only buy 1 lot instead of running through my code…


@roul.charts

roul.charts
01 Apr 2024, 09:32 ( Updated at: 01 Apr 2024, 17:33 )

Can't stop thinking about the fitness function and how we can produce the best results out of it. I have a hard Stop in the Optimizer mode. So if the Optimizer Szenario breaches my DD parameter, it will immediatelly stop and doesn't waste computing time:


private void MonitorDrawdown()
{
   double currentEquity = Account.Equity;

   // Calculate overall drawdown from the initial balance
   double overallDrawdown = (initialBalance - currentEquity) / initialBalance * 100;

   // Calculate daily drawdown from the previous day's closing balance
   double dailyDrawdown = (previousDayClosingBalance - currentEquity) / previousDayClosingBalance * 100;

   // Overall Drawdown Management
   if (overallDrawdown > MaxOverallLossPercent)
   {
       // Close the single largest losing trade
       var largestLosingTrade = Positions.Where(p => p.SymbolName == Symbol.Name && p.NetProfit < 0)
                                           .OrderBy(p => p.NetProfit)
                                           .FirstOrDefault();
       if (largestLosingTrade != null)
       {
           ClosePosition(largestLosingTrade);
           Print($"Closed trade {largestLosingTrade.Id} to manage drawdown.");
       }

       botStoppedDueToMaxDrawdown = true;
       // Stop the bot: the maximum allowed overall drawdown has been exceeded
       Print($"Drawdown Control: Bot stopped due to overall drawdown! Current: {overallDrawdown}% | Max allowed: {MaxOverallLossPercent}%");

       Stop();
   }

   // Daily Drawdown Management
   else if (dailyDrawdown >= MaxDailyDrawdownPercent && !tradingHaltedToday)
   {
       // Close the single largest losing trade
       var largestLosingTrade = Positions.Where(p => p.SymbolName == Symbol.Name && p.NetProfit < 0)
                                           .OrderBy(p => p.NetProfit)
                                           .FirstOrDefault();
       if (largestLosingTrade != null)
       {
           ClosePosition(largestLosingTrade);
           Print($"Closed trade {largestLosingTrade.Id} to manage drawdown.");
       }

       // After managing trades, recheck drawdown
       dailyDrawdown = (previousDayClosingBalance - currentEquity) / previousDayClosingBalance * 100;
       if (dailyDrawdown >= MaxDailyDrawdownPercent)
       {
           // If still exceeding the limit after closing trades, halt further trading
           tradingHaltedToday = true;
       }
       if (!dailyDrawdownMessagePrinted)
       {
           Print($"Drawdown Control: Trading halted for today! Current: {dailyDrawdown}% | Max allowed: {MaxDailyDrawdownPercent}%");
           dailyDrawdownMessagePrinted = true;
       }
   }
}

So i have a hard stop so i don't want to weigh the Drawdown too much. It's important but not as much as Net Profit and Profit Factor now. The new Manage Drawdown Function will take care about excessive DDs…

There are not many people to discuss about this… seems that most are using other Tools with an Walk forward test possibilities or MT4/5… but i don't like the idea to code modern EAs with old C++ so i try to stick to C# and cTrader. 

Tried a lot now my latest iteration for the Fitness Function is like this:
protected override double GetFitness(GetFitnessArgs args) //It has to be an override - don't change!
{
    // Define weights for each criterion directly affecting their influence
    double netProfitWeight = 0.35;
    double profitFactorWeight = 0.25;
    double drawdownWeight = 0.1;
    double sortinoRatioWeight = 0.1;

    // Filter out undesired strategies
    if (args.ProfitFactor < 1.0) // Ensuring basic profitability
    {
        return 0; // Excludes strategies not meeting basic criteria
    }

    double numerator = (args.NetProfit * netProfitWeight) +
                       (args.ProfitFactor * profitFactorWeight) +
                       (args.SortinoRatio * sortinoRatioWeight);

    double denominator = 1 + (args.MaxEquityDrawdown * drawdownWeight);

    double fitnessScore = numerator / denominator;

    return fitnessScore;
}


@roul.charts

roul.charts
08 Mar 2024, 20:41 ( Updated at: 09 Mar 2024, 07:12 )

Is there any update?

It's a pain to manually export the best paramerte, run them in the backtester - export the HTML report. 

And if the PC crashes you have to re run that specific optimizer again and again. 

Please add an function to save an .optres file like described on your own help page:
https://help.ctrader.com/ctrader-automate/backtesting-and-optimizing-cbots/#saving-and-loading-optimisation-results


@roul.charts