Price predictions in calgo bot ?
Price predictions in calgo bot ?
28 Dec 2024, 09:38
I saw linear regression example to predict direction of trend .
I wonder if this uses train data model or its updated same way as rest of the indicators using formula ?
Would be possible to import into code our own trained models to predict prices?
Can we then utilise GPU to accelerate calculation inside CTrader itself ?
in case of Mac OS version is metal library planned to be implemented to improve performance/efficiency?
Replies
algobeginner
30 Dec 2024, 10:31
( Updated at: 30 Dec 2024, 10:41 )
RE: Price predictions in calgo bot ?
PanagiotisCharalampous said:
Hi there,
Can you please explain which example you are referring to?
Best regards,
Panagiotis
it using indicator LinearRegressionForecast
_ which I'm wonder if is trained model as name would suggest from Machine Learning ,or just some formula do calculations based on median's of source ?
if this utilise trained model could we somehow import our own model from MLX into Bot to improve accuracy for specific pair ?
Ctrader heavy load CPU during optimisation but it have lot of spare computing power on GPU left so it could use it .
This example code : → using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, AddIndicators = true)]
public class LinearRegressionForecastSample : Robot
{
private double _volumeInUnits;
private LinearRegressionForecast _linearRegressionForecast;
[Parameter("Volume (Lots)", DefaultValue = 0.01)]
public double VolumeInLots { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 10, MaxValue = 100, MinValue = 1, Step = 1)]
public double StopLossInPips { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 10, MaxValue = 100, MinValue = 1, Step = 1)]
public double TakeProfitInPips { get; set; }
[Parameter("Label", DefaultValue = "LinearRegressionForecastSample")]
public string Label { get; set; }
[Parameter("Source", Group = "Linear Regression Forecast")]
public DataSeries Source { get; set; }
[Parameter("Periods", DefaultValue = 9, Group = "Linear Regression Forecast", MinValue = 0)]
public int Periods { get; set; }
public Position[] BotPositions
{
get
{
return Positions.FindAll(Label);
}
}
protected override void OnStart()
{
_volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
_linearRegressionForecast = Indicators.LinearRegressionForecast(Source, Periods);
}
protected override void OnBarClosed()
{
if (Bars.ClosePrices.Last(0) > _linearRegressionForecast.Result.Last(0) && Bars.ClosePrices.Last(1) <= _linearRegressionForecast.Result.Last(1))
{
ClosePositions(TradeType.Sell);
ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
}
else if (Bars.ClosePrices.Last(0) < _linearRegressionForecast.Result.Last(0) && Bars.ClosePrices.Last(1) >= _linearRegressionForecast.Result.Last(1))
{
ClosePositions(TradeType.Buy);
ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
}
}
private void ClosePositions(TradeType tradeType)
{
foreach (var position in BotPositions)
{
if (position.TradeType != tradeType) continue;
ClosePosition(position);
}
}
}
}
@algobeginner
PanagiotisCharalampous
30 Dec 2024, 07:39
Hi there,
Can you please explain which example you are referring to?
Best regards,
Panagiotis
@PanagiotisCharalampous