Re: FractalsMTF - отображение фракталов старшего таймфрейма на младшем
Добавлено: 30 ноя 2017, 22:31
так нагляднее - пересечения с М5 отсутствуют на Н1 и наоборот - пересечения с Н1 отсутствуют на М5
Неофициальный форум клиентского терминала Альфа-Инвестиции (Альфа-Директ 4). Обсуждение терминала, обмен опытом, разработка скриптов индикаторов и стратегий.
https://www.alfadirect4.ru/
Код: Выделить всё
function Initialize()
{
IndicatorName = "WriteData_II";
PriceStudy = true;
AddInput("I", Inputs.Candle);
AddParameter("DataSlot", 0);
AddSeries("A");
}
function Evaluate()
{
var lastLVal = MY.индикатор(Input, 0, 0, 2).GetLastValues ("L", 1)[0];
var lastHVal = MY.индикатор(Input, 0, 0, 2).GetLastValues ("H", 1)[0];
if (DataSlot == 0) return;
string Path = @"DataSlot" + (int)DataSlot + "\\";
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(Path);
if (!dirInfo.Exists) dirInfo.Create();
string Ticker = Input.VirtualSecurity.Split('=')[0];
string FileName = String.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}",
Ticker, BarDate().Year, BarDate().Month, BarDate().Day, BarTime().Hours, BarTime().Minutes, BarTime().Seconds);
string URL = Path + FileName;
// данная проверка необходима т.к. не будет перезаписи данных, но при смене параметров придётся вручную удалять папку данных
if (System.IO.File.Exists(URL) && CurrentIndex != MaxIndex) return;
ClearFile(URL);
WriteLine(URL, String.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9}", I.Open[0], I.High[0], I.Low[0], I.Close[0], I.Volume[0], I.VolumeBid[0], I.VolumeAsk[0], I.OpenInterest[0], lastLVal, lastHVal ));
}
Код: Выделить всё
function Initialize()
{
IndicatorName = "ReadData_II";
PriceStudy = true;
AddInput("I", Inputs.Candle);
AddParameter("DataSlot", 0);
AddSeries("H", DrawAs.Custom, Color.Blue);
AddSeries("L", DrawAs.Custom, Color.Red);
}
function Evaluate()
{
// evge 17.11.2017 http://alfadirect4.ru
if (DataSlot == 0) return;
string Path = @"DataSlot" + (int)DataSlot + "\\";
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(Path);
if (!dirInfo.Exists) dirInfo.Create();
// т.к. наш таймфрейм рабочий меньше чем минуты, то передавать в поиск данных мы будем всё до минут, секунды отбросим, так мы найдем данные от минутного таймфрейма
string Ticker = Input.VirtualSecurity.Split('=')[0];
string FileName = String.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}",
Ticker, BarDate().Year, BarDate().Month, BarDate().Day, BarTime().Hours, BarTime().Minutes, 0, 0);
var URL = Path + FileName;
string S = "";
if (System.IO.File.Exists(URL))
{
System.IO.StreamReader output = new System.IO.StreamReader(URL);
while (!output.EndOfStream) S += output.ReadLine();
output.Close();
}
string[] Bar = S.Split(';');
// бар найден
if (Bar.Count() > 3)
{
// необходимо считать с вышестоящего таймфрейма только H и L
H[0] = double.Parse(Bar[8]); //H это 8-ой элемент в списке
L[0] = double.Parse(Bar[9]); //L это 9-ой элемент в списке
H.DrawArrowDown(Color.HotPink, LineStyles.Solid, 5, Color.HotPink, 10);
L.DrawArrowUp(Color.Cyan, LineStyles.Solid, 5, Color.Cyan, 10);
} // count > 3
}
Ум, однажды открывший новую идею, уже никогда не вернется в прежнее состояние.
А.Эйнштейн