Backtesting Result Differences
16 Jan 2016, 01:40
Hello everyone and thanks for your time in advance, there is something that I don't understand
I did a backtest for my algo (which you can find beneath this thread) and the results are so different with different start and end dates.
Let me show you what I mean
The parameters ,inputs, timeframe, currency and everything are the same in both charts
Settings used: Tick data from server , 01/01/2014 to 11/30/2014

And this is the second chart. Settings used: Tick data from server, 01/01/2014 to 12/30/2014 (+1 month)

I don't understand why there are such big differences. I checked the first backtest and all trades were closed on October 29th. So basically, shouldn't the results be the same until that point? In both charts?
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Grid : Robot
{
[Parameter(DefaultValue = 20)]
public int PipDifference { get; set; }
[Parameter(DefaultValue = 20)]
public int maxGrids { get; set; }
[Parameter(DefaultValue = 20)]
public int ProfitperGrid { get; set; }
protected override void OnStart()
{
int curGrid = 1;
double startprice = Symbol.Ask;
while (curGrid <= maxGrids / 2)
{
PlaceStopOrder(TradeType.Buy, Symbol, Symbol.QuantityToVolume(0.01), startprice + curGrid * PipDifference * Symbol.PipSize);
curGrid++;
}
while (curGrid <= maxGrids)
{
PlaceStopOrder(TradeType.Sell, Symbol, Symbol.QuantityToVolume(0.01), startprice - (curGrid - maxGrids / 2) * PipDifference * Symbol.PipSize);
curGrid++;
}
}
void nochmal()
{
int curGrid = 1;
double startprice = Symbol.Ask;
while (curGrid <= maxGrids / 2)
{
PlaceStopOrder(TradeType.Buy, Symbol, Symbol.QuantityToVolume(0.01), startprice + curGrid * PipDifference * Symbol.PipSize);
curGrid++;
}
while (curGrid <= maxGrids)
{
PlaceStopOrder(TradeType.Sell, Symbol, Symbol.QuantityToVolume(0.01), startprice - (curGrid - maxGrids / 2) * PipDifference * Symbol.PipSize);
curGrid++;
}
}
protected override void OnTick()
{
if (Positions.Count == maxGrids)
{
foreach (var ps in Positions)
{
ClosePosition(ps, Symbol.QuantityToVolume(0.01));
}
Print("Lost Grid");
nochmal();
}
if (Symbol.UnrealizedGrossProfit > ProfitperGrid)
{
Print("Won Grid");
foreach (var ps in Positions)
{
ClosePosition(ps, Symbol.QuantityToVolume(0.01));
}
foreach (var ps in PendingOrders)
{
CancelPendingOrder(ps);
}
nochmal();
}
}
protected override void OnStop()
{
}
}
}
Replies
danny.weckhuyzen
17 Jan 2016, 11:04
When I look into your code I see that you are using stop-orders. I've discouvered with this platform that the stoploss and takeprofit is not always correctly set when the entry-price is reached. In my code I especially made an extra routine to correct the stoploss-pips and takeprofit-pips after opening of the order. Regards
@danny.weckhuyzen
jan-vdh
17 Jan 2016, 18:29
RE:
danny.weckhuyzen said:
When I look into your code I see that you are using stop-orders. I've discouvered with this platform that the stoploss and takeprofit is not always correctly set when the entry-price is reached. In my code I especially made an extra routine to correct the stoploss-pips and takeprofit-pips after opening of the order. Regards
Thanks for your reply! But I'm not using Take Profits or Stop Losses in my code
But yeah currently I do think aswell that the backtesting system is just not accurate.
@jan-vdh

jan-vdh
16 Jan 2016, 05:30 ( Updated at: 21 Dec 2023, 09:20 )
Let me show a clear example. Same parameters, same everything. The trades were opened at the same time, but closed differently.
@jan-vdh