NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

using System;
using System.Collections.Generic;
using System.Linq;
using Matriks.Data.Symbol;
using System.Windows.Media;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.AlgoTrader;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Trader.Core.TraderModels;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
using System.Timers;

namespace Matriks.Lean.Algotrader
{
public class TKFEN : MatriksAlgo
{
[SymbolParameter("TKFEN")]
public string Symbol;

[Parameter(SymbolPeriod.Min60)]
public SymbolPeriod SymbolPeriod60;

[Parameter(SymbolPeriod.Day)]
public SymbolPeriod SymbolPeriodDay;

[Parameter(1)]
public decimal buyPrice;

[Parameter(1)]
public decimal lastProc;

[Parameter(2)]
public decimal atrLimit;

[Parameter(true)]
public bool flag;

[Parameter(5)]
public decimal OrdQty;

EMA ema60;
EMA emaDay;

RSI rsi60;
RSI rsiDay;

ATR atr60;

StochasticRSI stochasticRSI60;
StochasticRSI stochasticRSI60Op;
StochasticRSI stochasticRSIDay;

/// <summary>
/// Strateji ilk çalıştırıldığında bu fonksiyon tetiklenir. Tüm sembole kayit işlemleri,
/// indikator ekleme, haberlere kayıt olma işlemleri burada yapılır.
/// </summary>
public override void OnTimer()
{
var barData = GetBarData();
decimal lastValue2 = barData.Close[barData.Close.Count -1];
if (!flag)
{
if (lastValue2 <= (lastProc - (atr60.CurrentValue * 2)) || lastValue2 >= (lastProc + (atr60.CurrentValue * 2)))
{
SendMarketOrder(Symbol, (int) OrdQty, OrderSide.Sell);
Debug("Satış Emri Gönderildi: " + lastValue2);
flag = true;
}
}
}

public override void OnInit()
{
AddSymbol(Symbol, SymbolPeriod60);

atr60 = ATRIndicator(Symbol, SymbolPeriod60, OHLCType.Close, 14);

rsi60 = RSIIndicator(Symbol, SymbolPeriod60, OHLCType.Close, 14);
rsiDay = RSIIndicator(Symbol, SymbolPeriodDay, OHLCType.Close, 14);

ema60 = EMAIndicator(Symbol, SymbolPeriod60, OHLCType.Close, 200);
emaDay = EMAIndicator(Symbol, SymbolPeriodDay, OHLCType.Close, 200);

stochasticRSI60 = StochasticRSIIndicator(Symbol, SymbolPeriod60, OHLCType.Close, 14, 14, 7, 7, MovMethod.E);
stochasticRSI60Op = StochasticRSIIndicator(Symbol, SymbolPeriod60, OHLCType.Open, 14, 14, 7, 7, MovMethod.E);
stochasticRSIDay = StochasticRSIIndicator(Symbol, SymbolPeriodDay, OHLCType.Close, 14, 14, 3, 3, MovMethod.E);

// Algoritmanın kalıcı veya geçici sinyal ile çalışıp çalışmayacağını belirleyen fonksiyondur.
// true geçerseniz algoritma sadece yeni bar açılışlarında çalışır, bu fonksiyonu çağırmazsanız veya false geçerseniz her işlem olduğunda algoritma tetiklenir.
WorkWithPermanentSignal(true);

//Eger emri bir al bir sat seklinde gonderilmesi isteniyor bu true set edilir.
//Alttaki satırı silerek veya false geçerek emirlerin sirayla gönderilmesini engelleyebilirsiniz.
SendOrderSequential(true);

SetTimerInterval(3);
}

/// <summary>
/// Eklenen sembollerin bardata'ları ve indikatorler güncellendikçe bu fonksiyon tetiklenir.
/// </summary>
/// <param name="barData">Bardata ve hesaplanan gerçekleşen işleme ait detaylar</param>
public override void OnDataUpdate(BarDataCurrentValues barDataCurrentValues)
{
var lastValue = barDataCurrentValues.LastUpdate.Close;
decimal oldStoc60 = Ref(stochasticRSI60, 0);
decimal oldStoc60OpK = Ref(stochasticRSI60Op.StocRsiK, 0);
decimal oldStoc60OpD = Ref(stochasticRSI60Op.StocRsiD, 0);

decimal oldStoc60CLK = Ref(stochasticRSI60.StocRsiK, 0);
decimal oldStoc60CLD = Ref(stochasticRSI60.StocRsiD, 0);

Debug("ATR: " + atr60.CurrentValue);
Debug("Flag: " + flag);

if (flag)
{
Debug("Şartlar Sağlanıyor İse Alım Yapılacak");
Debug("Atr60: " + ((atr60.CurrentValue * 100) / lastValue));

if (((atr60.CurrentValue * 100) / lastValue) >= atrLimit)
{
Debug("ATR şartı sağlanıyor");
if (oldStoc60OpK<oldStoc60OpD && oldStoc60CLK>oldStoc60CLD)
{
Debug("Stock Kırdı");
if (ema60.CurrentValue < lastValue && emaDay.CurrentValue < lastValue && stochasticRSIDay.StocRsiK > stochasticRSIDay.StocRsiD
&& rsi60.CurrentValue < 70 && stochasticRSI60.CurrentValue < 80)
{
SendMarketOrder(Symbol, (int)(1500 / lastValue), OrderSide.Buy);
OrdQty = 1500 / lastValue;
lastProc = lastValue;
Debug("Alış Emri Gönderildi: " + lastValue);
flag = false;
}
}
}
}
}

/// <summary>
/// Gönderilen emirlerin son durumu değiştikçe bu fonksiyon tetiklenir.
/// </summary>
/// <param name="barData">Emrin son durumu</param>
public override void OnOrderUpdate(IOrder order)
{
var barData = GetBarData();
decimal value = barData.Close[barData.Close.Count -1];
String side;

if (order.Side.ToString().Equals("1"))
{
side = "alındı";
flag = false;
}
else
{
side = "satıldı";
flag = true;
}
if (order.OrdStatus.Obj == OrdStatus.Filled)
{
decimal OrdQty2 = order.OrderQty;
Debug(order.Price + " Fiyatından, " + order.OrderQty + " Lot " + side);
Debug("Emir Tamam");
}
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.