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;

namespace Matriks.Lean.Algotrader
{
public class Robot3 : 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.

[SymbolParameter("GARAN")]
public string Symbol;

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

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

[Parameter(1)]
public decimal BuyOrderQuantity;

[Parameter(1)]
public decimal SellOrderQuantity;

[Parameter(1)]
public decimal lastProc;

public bool flag = true;

decimal takeProfit;
decimal stopLoss;


// indikator tanımları.

EMA ema60;
EMA emaDay;

RSI rsi60;
RSI rsiDay;

ATR atr60;

StochasticRSI stochasticRSI60;
StochasticRSI stochasticRSIDay;


//StochasticFast stochasticFast;

//StochasticSlow stochasticSlow;

/// <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 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);
stochasticRSIDay = StochasticRSIIndicator(Symbol, SymbolPeriodDay, OHLCType.Close, 14, 14, 7, 7, MovMethod.E);


// stochasticSlow = StochasticSlowIndicator(Symbol, SymbolPeriod, OHLCType.Close, 5, 7, 5, MovMethod.Exponential);
// stochasticFast = StochasticFastIndicator(Symbol, SymbolPeriod, OHLCType.Close, 5, 7, MovMethod.Exponential);



// 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);

}

/// <summary>
/// Init islemleri tamamlaninca, bardatalar kullanmaya hazir hale gelince bu fonksiyon tetiklenir. Data uzerinde bir defa yapilacak islemler icin kullanilir
/// </summary>
public override void OnInitComplated()
{

}

/// <summary>
/// SetTimerInterval fonksiyonu ile belirtilen sürede bir bu fonksiyon tetiklenir.
/// </summary>
public override void OnTimer()
{

}

/// <summary>
/// AddNewsSymbol ve AddNewsKeyword ile haberlere kayit olunmuşsa bu fonksiyon tetiklenir.
/// </summary>
/// <param name="newsId">Gelen haberin id'si</param>
/// <param name="relatedSymbols">Gelen haberin ilişkili sembolleri</param>
public override void OnNewsReceived(int newsId, List<string> relatedSymbols)
{

}

/// <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)
{

// Debug("stochasticRSI60.KPeriod: " + stochasticRSI60.StocRsiK.CurrentValue);
// Debug("stochasticRSI60.DPeriod: " + stochasticRSI60.StocRsiD.CurrentValue);

var lastValue = barDataCurrentValues.LastUpdate.Close;

if (flag)
{
// if (((atr60.CurrentValue * 100) / lastValue) >= 1 / 100)
// {
if (CrossAbove(stochasticRSI60.StocRsiK, stochasticRSI60.StocRsiD))
{
if (ema60.CurrentValue < lastValue && emaDay.CurrentValue < lastValue && stochasticRSIDay.StocRsiK > stochasticRSIDay.StocRsiD
&& stochasticRSI60.StocRsiK.CurrentValue<20 && stochasticRSI60.StocRsiD < 20)
{
SendMarketOrder(Symbol, BuyOrderQuantity, OrderSide.Buy);
lastProc = barDataCurrentValues.LastUpdate.Close;
Debug(lastProc + " fiyatından alım yapıldı.");
}
}
// }
}

else
{
takeProfit = atr60.CurrentValue * (2);
stopLoss = atr60.CurrentValue * (3 / 2);
Debug("KarAl Miktarı: " + takeProfit);
Debug("ZararDurdur Miktarı: " + stopLoss);
var tp = TakeProfit(Symbol, SyntheticOrderPriceType.PricePoint, takeProfit);
var sl = StopLoss(Symbol, SyntheticOrderPriceType.PricePoint, stopLoss);
Debug(tp);
Debug(sl);
}
}

/// <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)
{
if (order.OrdStatus.Obj == OrdStatus.Filled)
{
if (flag)
{
Debug("Alış: " + lastProc);
flag = false;
}
else
{
Debug("Satış: " + lastProc);
flag = true;
}

}
}
}
}
     
 
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.