using System;
using System.Linq;
using System.Collections.Generic;
using Matriks;
using Matriks.Data.Symbol;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
using Matriks.Enumeration;
using Matriks.Trader.Core.TraderModels;
namespace Matriks.Lean.Algotrader
{
public class TottLongFinal : MatriksAlgo
{
[SymbolParameter("DOGE_USDT_FBIN")]
public string Symbol1;
[Parameter(SymbolPeriod.Min)]
public SymbolPeriod SymbolPeriod1;
[Parameter(40)]
public int TottPeriod1;
[Parameter(1)]
public decimal TottOpt1;
[Parameter(0.001)]
public decimal TottTwinOttCoef1;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod1;
[Parameter(1000)]
public decimal OrderQuantity1;
[Parameter(0.4)]
public decimal TakeProfitPercent;
[Parameter(0.5)]
public decimal TrailingAtrMultiplier;
TOTT tott;
ATR atr;
bool isTrailingActive = false;
bool isHalfClosed = false;
decimal entryPrice = 0;
decimal highestPrice = 0;
decimal trailingDistance = 0;
public override void OnInit()
{
tott = TOTTIndicator(Symbol1, GetHeikinAshiPeriodInfo(SymbolPeriod1), OHLCType.Close,
TottPeriod1, TottOpt1, TottTwinOttCoef1, TottMovMethod1);
atr = ATRIndicator(Symbol1, SymbolPeriod1, OHLCType.Close, 14);
SendOrderSequential(true);
WorkWithPermanentSignal(true);
}
public override void OnDataUpdate(BarDataEventArgs barData)
{
decimal currentPrice = barData.BarData.Close;
var positions = GetRealPositions();
decimal quantity = 0;
bool hasPosition = false;
if (positions != null && positions.ContainsKey(Symbol1))
{
var rawPos = positions[Symbol1];
var pos = rawPos as PositionReceiveCompleted;
if (pos != null)
{
quantity = pos.PositionQuantity;
hasPosition = true;
}
}
// AL SİNYALİ (TOTT yukarı keserse)
if (!hasPosition || quantity == 0)
{
if (CrossAbove(tott, tott, 0, 1))
{
SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Buy);
entryPrice = currentPrice;
isTrailingActive = false;
isHalfClosed = false;
highestPrice = entryPrice;
}
}
// AKTİF POZİSYON YÖNETİMİ
if (hasPosition && quantity > 0)
{
// %0.4 TP'ye ulaşıldıysa yarısını sat
if (!isHalfClosed && currentPrice >= entryPrice * (1 + TakeProfitPercent / 100))
{
SendMarketOrder(Symbol1, OrderQuantity1 / 2, OrderSide.Sell);
isHalfClosed = true;
isTrailingActive = true;
highestPrice = currentPrice;
trailingDistance = atr.CurrentValue * TrailingAtrMultiplier;
}
// Trailing aktifse kontrol et
if (isTrailingActive)
{
if (currentPrice > highestPrice)
highestPrice = currentPrice;
if (currentPrice <= highestPrice - trailingDistance)
{
SendMarketOrder(Symbol1, OrderQuantity1 / 2, OrderSide.Sell);
isTrailingActive = false;
}
}
// SAT SİNYALİ (TOTT aşağı keserse pozisyonu kapat)
if (CrossBelow(tott, tott, 0, 2))
{
SendMarketOrder(Symbol1, quantity, OrderSide.Sell);
isTrailingActive = false;
isHalfClosed = false;
}
}
}
}
}
HATA: error CS0246: 'PositionReceiveCompleted' türü veya ad alanı adı bulunamadı (bir using yönergeniz veya derleme başvurunuz mu eksik?
bu sistemi çalıştırmak istiyorum fakat devamlı position hatası alıyorum nasıl düzelterek bu sistemi çalıştırabilirim.