Merhaba, aşağıdaki kodu Matriks Gold da sorunsuz kullanıyorum.
---------------------------KURGU-----------------------------------------
AL;
if(MOV(C,opt1,VAR)>OTT(C,opt1,7),
MOV(C,opt1,VAR)>OTT(C,opt1,opt2)*(1+0.0008) AND STOSK(opt3,opt4,111,VAR)+1000>OTT(STOSK(opt3,opt4,111,VAR)+1000,2,0.3) AND
H>REF(HHV(H,20),-1) AND H>OTT(HHV(H,20/2),2,0.5),
MOV(C,opt1,VAR)>OTT(C,opt1,3.5) AND MOV(C,opt1,VAR)>OTT(C,opt1,opt2)*(1+0.0008) AND STOSK(opt3,opt4,111,VAR)+1000>OTT(STOSK(opt3,opt4,111,VAR)+1000,2,0.3) AND
H>REF(HHV(H,20),-1) AND H>OTT(HHV(H,20/2),2,0.5))
SAT
if(MOV(C,opt1,VAR)>OTT(C,opt1,7),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2)*(1-0.0008) AND STOSK(OPT3,OPT4,111,VAR)+1000<OTT(STOSK(OPT3,OPT4,111,VAR)+1000,2,0.3) AND
L<REF(LLV(L,20),-1) AND L<OTT(LLV(L,20/2),2,0.5),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2)*(1-0.0008) AND STOSK(OPT3,OPT4,111,VAR)+1000<OTT(STOSK(OPT3,OPT4,111,VAR)+1000,2,0.3) AND
L<REF(LLV(L,20),-1) AND L<OTT(LLV(L,20/2),2,0.5))
-------------------------------------------------------------------------------
sizden ricam;
1- bu kurguyu spot al-sat olarak BIST senetleri ve coinlerde kullanmak için bir strateji,
2- bu kurguyu BIST viop ve coin piyasasında long/short yönlü işlemlerde kullanmak için bir strateji,
3- sadece BIST de "((HOUR()=10 AND MINUTE()>=03) OR HOUR()>=11) AND ((HOUR()=17 AND MINUTE()<=58) OR HOUR()<=16)" zaman yaması ilavesi
edit: ben bir şey hazırladım. hhv kapısı da ekledim. ama bazı şeyler sanırım kaldıraçlı piyasalar için gerekli.
using System;
using System.Collections.Generic;
using System.Linq;
using Matriks.Data.Symbol;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
using Matriks.AI;
using Matriks.AI.AiParameters;
using Matriks.AI.Data;
using Matriks.Trader.Core.TraderModels;
/*
AL
if(MOV(C,opt1,VAR)>OTT(C,opt1,opt7),
MOV(C,opt1,VAR)>OTT(C,opt1,opt2)*(1+opt5) AND STOSK(opt3,opt4,333,VAR)+1000>OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6),
MOV(C,opt1,VAR)>OTT(C,opt1,opt8) AND MOV(C,opt1,VAR)>OTT(C,opt1,opt2)*(1+opt5) AND STOSK(opt3,opt4,333,VAR)+1000>OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6))
SAT
if(MOV(C,opt1,VAR)>OTT(C,opt1,opt7),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2)*(1-opt5) AND STOSK(opt3,opt4,333,VAR)+1000<OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2)*(1-opt5) AND STOSK(opt3,opt4,333,VAR)+1000<OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6))
*/
namespace Matriks.Lean.Algotrader
{
public class TOTTSOTTHHV : MatriksAlgo
{
// Strateji çalıştırılırken kullanacağımız parametreler. Eğer sembolle ilgili bir parametre ise,
// "SymbolParameter" ile, değilse "Parameter" ile tanımlama yaparız. Parantez içindeki değerler default değerleridir.
[Parameter(1)]
public decimal BuyOrderQuantity;
[Parameter(1)]
public decimal SellOrderQuantity;
[Parameter(false)]
public bool AcigaSatisYapilsin;
[Parameter(false)]
public bool AksamSeansiniDahilEt;
[Parameter("THYAO")]
public string Symbol;
[Parameter(SymbolPeriod.Min)]
public SymbolPeriod SymbolPeriod;
[Parameter(20)]
public int OPT1;
[Parameter(1.0)]
public decimal OPT2;
[Parameter(500)]
public int OPT3;
[Parameter(200)]
public int OPT4;
[Parameter(0.0008)]
public decimal OPT5;
[Parameter(0.2)]
public decimal OPT6;
[Parameter(7)]
public int OPT7;
[Parameter(3.5)]
public decimal OPT8;
[Parameter(20)]
public int OPT9;
[Parameter(20)]
public int OPT10;
[Parameter(20)]
public int OPT11;
[Parameter(20)]
public int OPT12;
TOTT tott;
SOTT sott;
OTT ott;
HighestHigh HHV;
HighestHigh HHV1;
LowestLow LLV;
LowestLow LLV1;
public override void OnDataUpdate(BarDataEventArgs barData)
{
var barData1 = GetBarData(Symbol, SymbolPeriod);
var h = GetSelectedValueFromBarData(barData1, OHLCType.High);
var l = GetSelectedValueFromBarData(barData1, OHLCType.Low);
/* AL
if(MOV(C,opt1,VAR)>OTT(C,opt1,opt7),
MOV(C,opt1,VAR)>OTT(C,opt1,opt2)*(1+opt5) AND STOSK(opt3,opt4,333,VAR)+1000>OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6) AND
H>REF(HHV(H,opt9),-1),
MOV(C,opt1,VAR)>OTT(C,opt1,opt8) AND MOV(C,opt1,VAR)>OTT(C,opt1,opt2)*(1+opt5) AND STOSK(opt3,opt4,333,VAR)+1000>OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6) AND
H>REF(HHV(H,opt10),-1))
*/
if (ott.Value[1][ott.CurrentIndex] >ott.Value[0][ott.CurrentIndex])
{
if (tott.Value[0][tott.CurrentIndex] > tott.Value[1][tott.CurrentIndex] &&
sott.Value[0][sott.CurrentIndex] > sott.Value[1][sott.CurrentIndex] &&
h>HHV.Value[0][HHV.CurrentIndex -1] &&
LastOrderSide.Obj != Side.Buy)
{
FX_Alis();
// Senntetik emirler tanımlanıyor
// StopLoss(Symbol, SyntheticOrderPriceType.Percent, 3);
// TakeProfit(Symbol, SyntheticOrderPriceType.Percent, 3);
}
}else
{
if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex] &&
tott.Value[0][tott.CurrentIndex] > tott.Value[1][tott.CurrentIndex] &&
sott.Value[0][sott.CurrentIndex] > sott.Value[1][sott.CurrentIndex] &&
h>HHV1.Value[0][HHV1.CurrentIndex -1] &&
LastOrderSide.Obj != Side.Buy)
{
FX_Alis();
// Senntetik emirler tanımlanıyor
// StopLoss(Symbol, SyntheticOrderPriceType.Percent, 3);
// TakeProfit(Symbol, SyntheticOrderPriceType.Percent, 3);
}
}
/* SAT
if(MOV(C,opt1,VAR)>OTT(C,opt1,opt7),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2)*(1-opt5) AND STOSK(opt3,opt4,333,VAR)+1000<OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6) AND
L<REF(LLV(L,opt11),-1),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2)*(1-opt5) AND STOSK(opt3,opt4,333,VAR)+1000<OTT(STOSK(opt3,opt4,33,VAR)+1000,2,opt6) AND
L<REF(LLV(L,opt12),-1))
*/
if (ott.Value[1][ott.CurrentIndex] >ott.Value[0][ott.CurrentIndex])
{
if (tott.Value[0][tott.CurrentIndex] < tott.Value[2][tott.CurrentIndex] &&
sott.Value[0][sott.CurrentIndex] < sott.Value[1][sott.CurrentIndex] &&
l<LLV.Value[0][LLV.CurrentIndex -1] &&
LastOrderSide.Obj != Side.Sell)
{
FX_Satis();
// Senntetik emirler tanımlanıyor
// StopLoss(Symbol, SyntheticOrderPriceType.Percent, 3);
// TakeProfit(Symbol, SyntheticOrderPriceType.Percent, 3);
}
}else
{
if (tott.Value[0][tott.CurrentIndex] < tott.Value[2][tott.CurrentIndex] &&
sott.Value[0][sott.CurrentIndex] < sott.Value[1][sott.CurrentIndex] &&
l<LLV1.Value[0][LLV1.CurrentIndex -1] &&
LastOrderSide.Obj != Side.Sell)
{
FX_Satis();
// Senntetik emirler tanımlanıyor
// StopLoss(Symbol, SyntheticOrderPriceType.Percent, 3);
// TakeProfit(Symbol, SyntheticOrderPriceType.Percent, 3);
}
}
}
public override void OnInit()
{
AddSymbol(Symbol, SymbolPeriod);
ott = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OPT1, OPT7, MovMethod.VAR, true);
tott = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OPT1, OPT2, OPT5, MovMethod.Variable);
sott = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OPT3, OPT4, 2, OPT6, MovMethod.Variable, MovMethod.Variable);
HHV = HighestHighIndicator(Symbol, SymbolPeriod, 20);
HHV1 = HighestHighIndicator(Symbol, SymbolPeriod, 20);
LLV = LowestLowIndicator(Symbol, SymbolPeriod, 20);
LLV1 = LowestLowIndicator(Symbol, SymbolPeriod, 20);
// Gerekli
WorkWithPermanentSignal(true);
if (AcigaSatisYapilsin)
{
SendOrderSequential(true, Side.All);
}else
{
SendOrderSequential(true, Side.Buy);
}
}
List<string> orderIDList = new List<string>();
string orderID;
public void FX_Alis()
{
if (LastOrderSide.Obj != Side.Buy)
{
if (LastOrderSide.Obj == Side.All || !AcigaSatisYapilsin)
{
orderID = SendMarketOrder(Symbol, BuyOrderQuantity, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
orderIDList.Add(orderID);
Debug("Alış emri gönderildi.[ " + BuyOrderQuantity + " adet ]");
}else
{
// pozsiyon kapat ve al
orderID = SendMarketOrder(Symbol, BuyOrderQuantity * 2, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
orderIDList.Add(orderID);
Debug("Alış emri gönderildi.[ " + (BuyOrderQuantity * 2) + " adet ]");
}
}
}
public void FX_Satis()
{
if (LastOrderSide.Obj != Side.Sell)
{
if (LastOrderSide.Obj == Side.All || !AcigaSatisYapilsin)
{
orderID = SendMarketOrder(Symbol, SellOrderQuantity, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
orderIDList.Add(orderID);
Debug("Satış emri gönderildi.[ " + (SellOrderQuantity) + " adet ]");
}else
{
orderID = SendMarketOrder(Symbol, SellOrderQuantity * 2, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
orderIDList.Add(orderID);
Debug("Satış emri gönderildi.[ " + (SellOrderQuantity * 2) + " adet ]");
}
}
}
public override void OnOrderUpdate(IOrder order)
{
if (order.OrdStatus.Obj == OrdStatus.Filled)
{
if (!orderIDList.Contains(order.CliOrdID) && AcigaSatisYapilsin)
{
LastOrderSide.Obj = Side.All;
Debug("Sentetik emir tetiklendi");
}
}
}
// #Gerekli
}
}