demek ki ne yapması gerektiğini robota anlatamıyorsunuz.
kademeli alım -satım robotları diğerlerine göre (çift yön ) biraz daha karışıktır.
alt tarafı bir tost yapmak için bile ne kadar detay gerekiyor. izleyin.
Printable View
Hocam çok teşekkür ederim.
Bir de volume profile bulabilirsek iki ekrandan kurtulmuş olacağız.
mql5 kodunu buraya bırakıyorum. Belki bir hayır sever çıkar :)
//+------------------------------------------------------------------+
//| Volume Profile.mq5 |
//| Copyright 2022, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Mohammad E. Baset"
#property link "baset84@gmail.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
//--- input parameters
input ENUM_TIMEFRAMES tf0=PERIOD_CURRENT; // calcualtion timeframe
input int precision = 100; // number of VP bars
input ENUM_APPLIED_VOLUME av = VOLUME_REAL; // applied volume
input double ratio=0.25; // ratio of maximum VP bar length to chart width
input color gc=clrSlateGray; // bars color
input color pocc=clrOrange; // POC color
input color svlc=clrGreen; // start vline color
input color evlc=clrGreen; // end vline color
ENUM_TIMEFRAMES tf = tf0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---number of VP bars couldn't be zero or less than zero
if(precision<=0)
{
Alert("precision couldn't be zero or less than zero");
return(INIT_FAILED);
}
//---if the calculation timeframe is greater than the current timeframe, use the current timeframe
if(PeriodSeconds(PERIOD_CURRENT)<PeriodSeconds(tf0 ))
tf=PERIOD_CURRENT;
ChartRedraw(0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---Delete vertical lines indicating the beginning and end of the range just when the indicator has been removed
if(reason==1)
ObjectsDeleteAll(0,"VP",-1,-1);
//---otherwise just redraw the chart
if(reason!=1)
ChartRedraw();
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
{
//---Check for vertical lines indicating the beginning and end of the range. If they are not present, draw them.
if(ObjectFind(0,"VP begin")<0)
VLineCreate("VP begin",TimeCurrent()-61*PeriodSeconds(PERIOD_CURRENT),svlc);
if(ObjectFind(0,"VP finish")<0)
VLineCreate("VP finish",TimeCurrent()-1*PeriodSeconds(PERIOD_CURRENT),evlc);
//---Do not run the program unless an object has dragged or the chart has changed
if(id!=CHARTEVENT_OBJECT_DRAG && id!=CHARTEVENT_CHART_CHANGE)
return;
if(id==CHARTEVENT_OBJECT_DRAG && (sparam=="VP begin" || sparam=="VP finish"))
ChartRedraw(0);
//---Get the datetime data of the begining and end of the range.
datetime time_begin = (datetime)ObjectGetInteger(0,"VP begin",OBJPROP_TIME);
datetime time_finish = (datetime)ObjectGetInteger(0,"VP finish",OBJPROP_TIME);
//---Number of bars in the range based on the calculation timeframe (not the current timeframe visible in the chart).
int bars = Bars(_Symbol,tf,time_begin,time_finish);
if(time_begin>=time_finish)
return;
//---Copy high-low-volume data of the calculation timeframe.
double high_array[];
double low_array[];
long volume[];
ArrayResize(high_array,bars);
ArrayResize(low_array,bars);
ArrayResize(volume,bars);
if(CopyHigh(_Symbol,tf,time_begin,time_finish,high _array)==-1 ||
CopyLow(_Symbol,tf,time_begin,time_finish,low_arra y)==-1 ||
CopyRealVolume(_Symbol,tf,time_begin,time_finish,v olume)==-1)
return;
if(av==VOLUME_TICK || volume[0]==0)
if(CopyTickVolume(_Symbol,tf,time_begin,time_finis h,volume)==-1)
return;
//---Find the max-min price in the range & the height of VP bars based on the number of bars (precision input)
double max = high_array[ArrayMaximum(high_array,0,WHOLE_ARRAY)]; // highest price in the range
double min = low_array[ArrayMinimum(low_array,0,WHOLE_ARRAY)]; // lowest price in the range
double range = (max-min)/precision; // height of the VP bars
//---Create an array to store the VP data
double profile[];
ArrayResize(profile,precision);
//---Calculate VP array
//---Loop through all price bars in the range and cumulatively assign their volume to VPs.
for(int i=0; i<bars && !IsStopped(); i++)
{
int Floor = (int)MathFloor((low_array[i]-min)/range); // the first level of VP just below the low of the ith candle
int Ceil = (int)MathFloor((high_array[i]-min)/range); // the first level ov VP just above the high of the ith candle
double body = high_array[i]-low_array[i]; // the height of ith candle
//---When the lower part of the candle falls between two levels of VPs, we have to consider just that part, not the entire level height
double tail = min+(Floor+1)*range-low_array[i];
//---When the upper part of the candle falls between two levels of VPs, we have to consider just that part, not the entire level height
double wick = high_array[i]-(min+(Ceil)*range);
//---set the values of VPs to zero in the first step of the loop, because we are accumulating volumes to find VPs and they should be zero in the begining
if(i==0)
for(int n=0; n<precision; n++)
profile[n]=0.0;
for(int n=0; n<precision && !IsStopped(); n++)
{
if(n<Floor || n>Ceil) // when no part of the candle is in the nth level of VP, continue
continue;
if(Ceil-Floor==0) // when all of the candle is in the nth level of VP, add whole volume of the candle to that level of VP
profile[n]+=(double)volume[i];
else
if(n==Floor) // when the lower part of the candle falls in the nth level of VP, but it doesn't cover the whole height of the nth level
profile[n]+=(tail/body)*volume[i];
else
if(n==Ceil) // when the upper part of the candle falls in the nth level of VP, but it doesn't cover the entire height of the nth level
profile[n]+=(wick/body)*volume[i];
else
profile[n]+=(range/body)*volume[i]; // when a part of the candle covers the entire height of the nth level
}
}
//--- Point of Control is the maximum VP found in the volume profile array
double POC=profile[ArrayMaximum(profile,0,WHOLE_ARRAY)];
//---Define the maximum length of VP bars (which is for POC) by considering the width of the chart and ratio input
int BL=(int)(ratio*ChartGetInteger(0,CHART_WIDTH_IN_PI XELS));
//---Find an appropriate height for VP bars by considering the chart height and the number of VP bars
int ch = int(ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS) * ((max-min)/(ChartGetDouble(0,CHART_PRICE_MAX)-ChartGetDouble(0,CHART_PRICE_MIN)))/precision);
if(POC==0.0)
return;
//---delete all existing bars before drawing new ones
ObjectsDeleteAll(0,"VP prfl ",-1,-1);
//---Draw VP bars one by one from the lowest price in the range to the highest
for(int n=0; n<precision; n++)
{
//--- The length of each VP bar is calculated by its ratio to POC
int xd=(int)((profile[n]/POC)*BL);
int x_start=0;
int y_start=0;
//--- Finding the xy position for drawing VPs according to the end vline and min price in the range
ChartTimePriceToXY(0,0,time_finish,min+(n+1)*range ,x_start,y_start);
//--- In case the end of VPs go beyond the visible chart
if(x_start+xd>=ChartGetInteger(0,CHART_WIDTH_IN_PI XELS))
xd=(int)ChartGetInteger(0,CHART_WIDTH_IN_PIXELS)-x_start;
//---Draw rectangle lable to display VP bars, using RectLabelCreate function
RectLabelCreate("VP prfl "+IntegerToString(n),x_start,y_start,xd,ch,gc) ;
//---Change the color of POC
if(profile[n]==POC)
{
ObjectSetInteger(0,"VP prfl "+IntegerToString(n),OBJPROP_COLOR,pocc);
ObjectSetInteger(0,"VP prfl "+IntegerToString(n),OBJPROP_BGCOLOR,pocc);
}
}
//---
ChartRedraw(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| Create the vertical line |
//+------------------------------------------------------------------+
bool VLineCreate(const string name="VLine", // line name
datetime time=0, // line time
const color clr=clrRed, // line color
const ENUM_LINE_STYLE style=STYLE_DOT, // line style
const int width=1, // line width
const long chart_ID=0, // chart's ID
const int sub_window=0, // subwindow index
const bool back=true, // in the background
const bool selection=true, // highlight to move
const bool ray=true, // line's continuation down
const bool hidden=false, // hidden in the object list
const long z_order=0) // priority for mouse click
{
//--- if the line time is not set, draw it via the last bar
if(!time)
time=TimeCurrent();
//--- reset the error value
ResetLastError();
//--- create a vertical line
if(!ObjectCreate(chart_ID,name,OBJ_VLINE,sub_windo w,time,0))
{
Print(__FUNCTION__,
": failed to create a vertical line! Error code = ",GetLastError());
return(false);
}
//--- set line color
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set line display style
ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style );
//--- set line width
ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width );
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the line by mouse
//--- when creating a graphical object using ObjectCreate function, the object cannot be
//--- highlighted and moved by default. Inside this method, selection parameter
//--- is true by default making it possible to highlight and move the object
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,se lection);
//--- enable (true) or disable (false) the mode of displaying the line in the chart subwindows
ObjectSetInteger(chart_ID,name,OBJPROP_RAY,ray);
//--- hide (true) or display (false) graphical object name in the object list
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidd en);
//--- set the priority for receiving the event of a mouse click in the chart
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_or der);
//--- successful execution
return(true);
}
//+------------------------------------------------------------------+
//| Create rectangle label |
//+------------------------------------------------------------------+
bool RectLabelCreate(const string name="RectLabel", // label name
const int x=0, // X coordinate
const int y=0, // Y coordinate
const int width=50, // width
const int height=1, // height
const color clr=clrRed, // flat border color (Flat)
const color back_clr=clrNONE, // background color
const ENUM_BORDER_TYPE border=BORDER_FLAT, // border type
const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // chart corner for anchoring
const ENUM_LINE_STYLE style=STYLE_SOLID, // flat border style
const int line_width=1, // flat border width
const long chart_ID=0, // chart's ID
const int sub_window=0, // subwindow index
const bool back=true, // in the background
const bool selection=false, // highlight to move
const bool hidden=true, // hidden in the object list
const long z_order=0) // priority for mouse click
{
//--- reset the error value
ResetLastError();
//--- create a rectangle label
if(!ObjectCreate(chart_ID,name,OBJ_RECTANGLE_LABEL ,sub_window,0,0))
{
Print(__FUNCTION__,
": failed to create a rectangle label! Error code = ",GetLastError());
return(false);
}
//--- set label coordinates
ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x );
ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y );
//--- set label size
ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width );
ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,heigh t);
//--- set background color
ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,bac k_clr);
//--- set border type
ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_TYPE ,border);
//--- set the chart's corner, relative to which point coordinates are defined
ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corn er);
//--- set flat border color (in Flat mode)
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set flat border line style
ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style );
//--- set flat border width
ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,line_ width);
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the label by mouse
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,se lection);
//--- hide (true) or display (false) graphical object name in the object list
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidd en);
//--- set the priority for receiving the event of a mouse click in the chart
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_or der);
//--- successful execution
return(true);
}
//+------------------------------------------------------------------+
https://www.mql5.com/en/code/47784
Erol hocanın basit kademe robotu.....most al verdiğinde al sat a başlaması için most eklemeye çalıştım robot çalışmadı...nerede yanlış düşünüyorum....most u nasıl eklemem lazım.....
//Hisse Talimatlari burada girilecek.
var Sozluk = new Dictionary<string, List<double>>();
Sozluk["IMKBH'TEKTU"] = new List<double> { 0.02, 0.04, 1, 5, 3 };//Hisse - kademe_al_seviye / kademe_sat_seviye / kademe_lot / yuksek / dusuk
//Sozluk["CRP'ETHUSDT_BNC"] = new List<double> { 20, 20, 0.01, 6000, 2000 };//Hisse - kademe_al_seviye / kademe_sat_seviye / kademe_lot / yuksek / dusuk
// Sozluk["CRP'BNBUSDT_BNC"] = new List<double> { 5, 5, 0.1, 600, 200 };//Hisse - kademe_al_seviye / kademe_sat_seviye / kademe_lot / yuksek / dusuk
//Ana dongu kod yapisi
for (var No = 0; No < Sozluk.Count; No++)
{
var EmirSembol = Sozluk.ElementAt(No).Key;
var Anahtar = Sistem.Name + " , " + EmirSembol;
var IslemFiyat = 0.0;
DateTime IslemTarih;
var Rezerv = "";
var AlisFiyat = 0.0m;
var SatisFiyat = 0.0m;
var KademeFiyat = 0.0m;
var Pozisyon = Sistem.PozisyonKontrolOku(Anahtar, out IslemFiyat, out IslemTarih, out Rezerv);
var Lot = (double)Sozluk.ElementAt(No).Value[2];
var Yuksek = (double)Sozluk.ElementAt(No).Value[3];
var Dusuk = (double)Sozluk.ElementAt(No).Value[4];
var basicitem = Sistem.YuzeyselVeriOku(EmirSembol);
var sonfiyat = (decimal)basicitem.LastPrice;
var bidfiyat = (decimal)basicitem.BidPriceDec;
var askfiyat = (decimal)basicitem.AskPriceDec;
if (sonfiyat == 0) continue;
if (bidfiyat == 0) continue;
if (askfiyat == 0) continue;
//Ilk İslem Sarti (Mevcut fiyat yuksek/dusuk arasinda ise ve poz yoksa, Al/Sat seviyesi kademe kadar belirlenir)
string DosyaDir = "C:\\iDeal\\Kademe\" + EmirSembol.Split('\'')[1] + ".YapilanIslemler.txt"; // Dosya Adi
if (!System.IO.Directory.Exists("C:\\iDeal\\Kademe\") ) System.IO.Directory.CreateDirectory("C:\\iDeal\\Ka deme\");
if (!System.IO.File.Exists(DosyaDir)) System.IO.File.Create(DosyaDir);
var ReadLines = System.IO.File.ReadAllLines(DosyaDir);
if (ReadLines.Count() != 0)
{
KademeFiyat = (decimal)Convert.ToSingle(ReadLines.Last().Split(' \t')[1]);
AlisFiyat = (decimal)Convert.ToSingle(ReadLines.Last().Split(' \t')[2]);
SatisFiyat = (decimal)Convert.ToSingle(ReadLines.Last().Split(' \t')[3]);
}
else
{
AlisFiyat = (decimal)askfiyat;
}
var Islem = "";
var Miktar = 0.0;
///////////////////////////////////
var V = Sistem.GrafikVerileriniOku(Sistem.Sembol, "1");
var C = Sistem.GrafikFiyatSec("Kapanis");
var MA =Sistem.MA(C, "Exp", 10);
var TOMA = Sistem.TOMA(10, 0.25, "Exp");
var SonYon = "";
for (int i = 1; i < Sistem.BarSayisi; i++)
{
if(MA[i-1] < TOMA[i-1] && MA[i] > TOMA[i] && SonYon !="A")
{
SonYon = "A";
Sistem.Yon[i] = "A";
}
if(MA[i-1] > TOMA[i-1] && MA[i] < TOMA[i] && SonYon !="F")
{
SonYon = "F";
Sistem.Yon[i] = "F";
}
}
////////////////////////////////////////////
if (SonYon=="A" && bidfiyat <= AlisFiyat && Pozisyon >= 0 && bidfiyat >= (decimal)Dusuk && bidfiyat <= (decimal)Yuksek) // AL
{
Rezerv = "Alis : " + bidfiyat.ToString("0.00");
Miktar = Lot;
IslemFiyat = (double)bidfiyat;
}
else if (askfiyat >= SatisFiyat && Pozisyon > 0)
{
Rezerv = "Satis: " + askfiyat.ToString("0.00") + " Kar: " + (1 - Sistem.SayiYuvarla((decimal)IslemFiyat / SatisFiyat, 0.0001)).ToString("%0.00");
Miktar = -Lot;
IslemFiyat = (double)askfiyat;
}
if (Miktar > 0) Islem = "Alis";
if (Miktar < 0) Islem = "Satis";
if (Islem != "")
{
Sistem.PozisyonKontrolGuncelle(Anahtar, Miktar + Pozisyon, IslemFiyat, Rezerv);
Sistem.EmirSembol = EmirSembol;
Sistem.EmirIslem = Islem;
Sistem.EmirSuresi = "KIE"; //"GUN", "KIE", "IKG" //Kriptolar icin "GTC", Limit icin "GUN" ve "IKG"
Sistem.EmirTipi = "Piyasa"; //"Limit", "Piyasa"
Sistem.EmirMiktari = (double)Math.Abs(Miktar);
Sistem.EmirFiyati = IslemFiyat;
Sistem.EmirAciklama = Rezerv;
Sistem.EmirHesapAdi = "225524, Osmanlı Menkul"; //Portfoy peneceresinde gözüken ile aynı Hesap
Sistem.EmirAltHesap = "225524"; ////Portfoy peneceresinde gözüken ile aynı Alt Hesap
Sistem.EmirGonder();
//Alış Islemi Islemler dosyasına eklenir.
if (Islem == "Alis")
{
string Mesaj = EmirSembol + "\t" + IslemFiyat.ToString() + "\t" + ((decimal)IslemFiyat - (decimal)Sozluk.ElementAt(No).Value[0]).ToString() + "\t" + ((decimal)IslemFiyat + (decimal)Sozluk.ElementAt(No).Value[1]).ToString() + "\t" + Lot.ToString() + "\t" + System.DateTime.Now.ToString() + "\r\n";
System.IO.File.AppendAllText(DosyaDir, Mesaj);
}
//Son Islem Islemler dosyasından çıkarılır.
if (Islem == "Satis")
{
var ReadLines2 = System.IO.File.ReadAllLines(DosyaDir);
System.IO.File.WriteAllLines(DosyaDir, ReadLines2.Take(ReadLines2.Count() - 1));
}
}
}
Bu kodda nerde hata yapıyorum.
//stochFirst:=(c-llv(l,5))/(hhv(h,5)-llv(l,5));
//smoothingFirst:= mov( stochFirst,3,e)*100;
//stochSecond:=(smoothingFirst-llv(smoothingFirst,5))/(hhv(smoothingFirst,5)-llv(smoothingFirst,5));
//smoothingSecond:=mov( stochSecond,3,e)*100;
//smoothingSecond
var V = Sistem.GrafikVerileri;
var C = Sistem.GrafikFiyatSec("Kapanis");
var H = Sistem.GrafikFiyatSec("Yuksek");
var L = Sistem.GrafikFiyatSec("Dusuk");
var hhv = Sistem.HHV(5, H);
var llv = Sistem.LLV(5, L);
var stochFirst = Sistem.Liste(0);
for (int i = 1; i < V.Count; i++)
{
stochFirst[i] = ((C[i]-llv[i])/(hhv[i]-llv[i]));
}
var mov=Sistem.MA(stochFirst, "Exp", 3);
//smoothingFirst:= mov( stochFirst,3,e)*100;
var smoothingFirst = Sistem.Liste(0);
for (int i = 1; i < V.Count; i++)
{
smoothingFirst[i] = mov[i]*100;
}
var llvsm=Sistem.LLV(5,smoothingFirst);
var hhvsm=Sistem.HHV(5, smoothingFirst);
//stochSecond:=(smoothingFirst-llv(smoothingFirst,5))/(hhv(smoothingFirst,5)-llv(smoothingFirst,5));
var stochSecond = Sistem.Liste(0);
for (int i = 1; i < V.Count; i++)
{
stochSecond[i] = ((smoothingFirst[i]-llvsm[i])/(hhvsm[i]-llvsm[i]));
}
//smoothingSecond:=mov( stochSecond,3,e)*100;
var movd=Sistem.MA(stochSecond, "Exp", 3);
var smoothingSecond = Sistem.Liste(0);
for (int i = 1; i < V.Count; i++)
{
smoothingSecond[i] = movd[i]*100;
}
Sistem.Cizgiler[0].Deger = smoothingSecond;
Buralarda;
stochFirst[i] = (hhv[i] - llv[i]) == 0 ? 0 : ((C[i] - llv[i]) / (hhv[i] - llv[i]));
stochSecond[i] = (hhvsm[i] - llvsm[i]) == 0 ? 0 : ((smoothingFirst[i] - llvsm[i]) / (hhvsm[i] - llvsm[i]));
nerede yanlış düşünüyorum ....
//Hisse Talimatlari burada girilecek.
var Sozluk = new Dictionary<string, List<double>>();
Sozluk["IMKBH'KOZAL"] = new List<double> { 0.04, 0.08, 1, 30, 20 };//Hisse - kademe_al_seviye / kademe_sat_seviye / kademe_lot / yuksek / dusuk
//Sozluk["IMKBH'HALKB"] = new List<double> { 0.02, 0.07, 20, 16.80, 13 };//Hisse - kademe_al_seviye / kademe_sat_seviye / kademe_lot / yuksek / dusuk
//Sozluk["IMKBH'TSKB"] = new List<double> { 0.02, 0.07, 10, 10, 7 };//Hisse - kademe_al_seviye / kademe_sat_seviye / kademe_lot / yuksek / dusuk
//Ana dongu kod yapisi
for (var No = 0; No < Sozluk.Count; No++)
{
var EmirSembol = Sozluk.ElementAt(No).Key;
var Anahtar = Sistem.Name + " , " + EmirSembol;
var IslemFiyat = 0.0;
DateTime IslemTarih;
var Rezerv = "";
var AlisFiyat = 0.0m;
var SatisFiyat = 0.0m;
var KademeFiyat = 0.0m;
var Pozisyon = Sistem.PozisyonKontrolOku(Anahtar, out IslemFiyat, out IslemTarih, out Rezerv);
var Lot = (double)Sozluk.ElementAt(No).Value[2];
var Yuksek = (double)Sozluk.ElementAt(No).Value[3];
var Dusuk = (double)Sozluk.ElementAt(No).Value[4];
var basicitem = Sistem.YuzeyselVeriOku(EmirSembol);
var sonfiyat = (decimal)basicitem.LastPrice;
var bidfiyat = (decimal)basicitem.BidPriceDec;
var askfiyat = (decimal)basicitem.AskPriceDec;
if (sonfiyat == 0) continue;
if (bidfiyat == 0) continue;
if (askfiyat == 0) continue;
//Ilk İslem Sarti (Mevcut fiyat yuksek/dusuk arasinda ise ve poz yoksa, Al/Sat seviyesi kademe kadar belirlenir)
string DosyaDir = "C:\\iDeal\\Kademeler" + EmirSembol.Split('\'')[1] + ".YapilanIslemler.txt"; // Dosya Adi
if (!System.IO.Directory.Exists("C:\\iDeal\\Kademeler ")) System.IO.Directory.CreateDirectory("C:\\iDeal\\Ka demeler");
if (!System.IO.File.Exists(DosyaDir)) System.IO.File.Create(DosyaDir);
var ReadLines = System.IO.File.ReadAllLines(DosyaDir);
if (ReadLines.Count() != 0)
{
KademeFiyat = (decimal)Convert.ToSingle(ReadLines.Last().Split(' \t')[1]);
AlisFiyat = (decimal)Convert.ToSingle(ReadLines.Last().Split(' \t')[2]);
SatisFiyat = (decimal)Convert.ToSingle(ReadLines.Last().Split(' \t')[3]);
}
else
{
AlisFiyat = (decimal)askfiyat;
}
var Islem = "";
var Miktar = 0.0;
//EKLEDİĞİM YER BURASI.....
var V = Sistem.GrafikVerileriniOku(Sistem.Sembol, "G");
// var V = Sistem.GrafikFiyatOku(Sembol, "G", "Kapanis");
var TTI = Sistem.TOMA(V, 3, 1, "Variable");
var MA = Sistem.MA(V, "Variable", 3);
var START = MA[MA.Count - 1] > TOMA[TOMA.Count - 2];
if (START) //BU KOŞUL SAĞLANIRSA ALIŞ YAP
{
if (bidfiyat <= AlisFiyat && Pozisyon >= 0 && bidfiyat >= (decimal)Dusuk && bidfiyat <= (decimal)Yuksek) // AL
{
Rezerv = "Alis : " + bidfiyat.ToString("0.00");
Miktar = Lot;
IslemFiyat = (double)bidfiyat;
}
}
else if (askfiyat >= SatisFiyat && Pozisyon > 0)
{
Rezerv = "Satis: " + askfiyat.ToString("0.00") + " Kar: " + (1 - Sistem.SayiYuvarla((decimal)IslemFiyat / SatisFiyat, 0.0001)).ToString("%0.00");
Miktar = -Lot;
IslemFiyat = (double)askfiyat;
}
if (Miktar > 0) Islem = "Alis";
if (Miktar < 0) Islem = "Satis";
if (Islem != "")
{
Sistem.PozisyonKontrolGuncelle(Anahtar, Miktar + Pozisyon, IslemFiyat, Rezerv);
Sistem.EmirSembol = EmirSembol;
Sistem.EmirIslem = Islem;
Sistem.EmirSuresi = "KIE"; //"GUN", "KIE", "IKG" //Kriptolar icin "GTC", Limit icin "GUN" ve "IKG"
Sistem.EmirTipi = "Piyasa"; //"Limit", "Piyasa"
Sistem.EmirMiktari = (double)Math.Abs(Miktar);
Sistem.EmirFiyati = IslemFiyat;
Sistem.EmirAciklama = Rezerv;
Sistem.EmirHesapAdi = "255516, Osmanlı Menkul"; //Portfoy peneceresinde gözüken ile aynı Hesap
Sistem.EmirAltHesap = "255516"; ////Portfoy peneceresinde gözüken ile aynı Alt Hesap
Sistem.EmirGonder();
//Alış Islemi Islemler dosyasına eklenir.
if (Islem == "Alis")
{
string Mesaj = EmirSembol + "\t" + IslemFiyat.ToString() + "\t" + ((decimal)IslemFiyat - (decimal)Sozluk.ElementAt(No).Value[0]).ToString() + "\t" + ((decimal)IslemFiyat + (decimal)Sozluk.ElementAt(No).Value[1]).ToString() + "\t" + Lot.ToString() + "\t" + System.DateTime.Now.ToString() + "\r\n";
System.IO.File.AppendAllText(DosyaDir, Mesaj);
}
//Son Islem Islemler dosyasından çıkarılır.
if (Islem == "Satis")
{
var ReadLines2 = System.IO.File.ReadAllLines(DosyaDir);
System.IO.File.WriteAllLines(DosyaDir, ReadLines2.Take(ReadLines2.Count() - 1));
}
}
}