Global fix (#9)
* Fix time for candle * Fix out ouf range * Fix pnl, fix custom money management * Clean a bit
This commit is contained in:
@@ -46,8 +46,8 @@ public static class TradingBox
|
||||
Signal signal = null;
|
||||
if (strategies.Count > 1)
|
||||
{
|
||||
var trendSignal = signalOnCandles.Where(s => s.SignalType == SignalType.Trend);
|
||||
var signals = signalOnCandles.Where(s => s.SignalType == SignalType.Signal);
|
||||
var trendSignal = signalOnCandles.Where(s => s.SignalType == SignalType.Trend).ToList();
|
||||
var signals = signalOnCandles.Where(s => s.SignalType == SignalType.Signal).ToList();
|
||||
var contextStrategiesCount = strategies.Count(s => s.SignalType == SignalType.Context);
|
||||
var validContext = true;
|
||||
|
||||
@@ -111,7 +111,7 @@ public static class TradingBox
|
||||
{
|
||||
var position = positions[i];
|
||||
var nextPosition = i + 1 < positions.Count ? positions[i + 1] : null;
|
||||
var (stopLoss, takeProfit) = GetBestSLTPForPosition(candles, position, nextPosition);
|
||||
var (stopLoss, takeProfit) = GetBestSltpForPosition(candles, position, nextPosition);
|
||||
|
||||
stoplossPercentage.Add(stopLoss);
|
||||
takeProfitsPercentage.Add(takeProfit);
|
||||
@@ -126,13 +126,14 @@ public static class TradingBox
|
||||
return moneyManagement;
|
||||
}
|
||||
|
||||
public static (decimal Stoploss, decimal TakeProfit) GetBestSLTPForPosition(List<Candle> candles, Position position,
|
||||
public static (decimal Stoploss, decimal TakeProfit) GetBestSltpForPosition(List<Candle> candles, Position position,
|
||||
Position nextPosition)
|
||||
{
|
||||
var stopLoss = 0M;
|
||||
var takeProfit = 0M;
|
||||
var candlesBeforeNextPosition = candles.Where(c =>
|
||||
c.Date >= position.Date && c.Date <= (nextPosition == null ? candles.Last().Date : nextPosition.Date));
|
||||
c.Date >= position.Date && c.Date <= (nextPosition == null ? candles.Last().Date : nextPosition.Date))
|
||||
.ToList();
|
||||
|
||||
if (position.OriginDirection == TradeDirection.Long)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user