|
|||||
|
|||||
Пробовал я и так. Может руки кривые или мозги, сейчас вообще на работе и ничего не соображаю. Дело в том, что если функцию iBarShift задать так: iBarShift(NULL, 0, D'2012.11.27 15:00') то она вернет индекс 15-ти часового бара за 27-е число. Если же поставить просто дату, то возвращается пятизначное число, неизвестно что означающее. А может я чего-то не понимаю.
Спасибо, попробуем. Только я не могу задавать явно дату и время. Это была попытка получить дату и время через переменную относительно текущей даты. Почему-то не сработало. Видимо придется через открытие текущего дня определять индекс бара с open дня и потом уже дальше вглубь. Будем дальше пытать остатки мозгов. Я не силен в MQL4 и если кто-то сделает что-то подобное быстрее меня, буду рад. Для чего это? Собственно для того, что бы создать массив определенной размеренности, начиная с какого-то бара и получить из него цены для анализа.
Кто поможет чайнику!
Хочу создать простенький индикатор на mql4. Прямой отрезок между двумя заданными точками на графике. Сам не смог разобраться как это сделать, по этому пишу сюда.
ну вроде так:
ObjectCreate(rec_name,OBJ_TREND,0,время1,цена1,вре мя2,цена2);
ObjectSet(rec_name,OBJPROP_RAY, false);
ObjectSet(rec_name,OBJPROP_COLOR,цвет);
Огромное спасибо. Еще вопрос, это в каком месте написать нужно, после int init() {, после int deinit() {, или после int start() { -?
повторно
ищу человека который согласиться значительно улучшить индикатор
combo_bars_daily
есть исходники
для мт4 есть индикаторы
combo_bars_daily_1.7.ex4
combo_bars_daily_1.7.zip
но над ними можно еще поработать
улучшить
очень сильно
у нас вообще в инете столько полезных полусырых индюков валяется
а если такие для нинзи сделать
должно выйти еще лучше
напишу подробное ТЗ
кто будет браться пишите в личку
Александр
установка индикаторов видео https://www.youtube.com/channel/UCax...KqtnrtnrHnOccg
Твиттер
Telegram
Возможно у кого-нибудь есть индикатор дивергенций CumDelta для МТ4?
Если нет может, кто подскажет как оптимизировать ЭТОТ:
//+------------------------------------------------------------------+
//| ClusterDelta_CumDelta_Div.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//----
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_width1 1
#property indicator_width2 2
#property indicator_width3 2
//---- input parameters
extern string separator3 = "*** Indicator Settings ***";
extern bool drawDivergenceLines = true;
extern bool displayAlert = false;
//---- buffers
double Momentum[];
double bullishDivergence[];
double bearishDivergence[];
double MomDiv[];
//----
static datetime lastAlertTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 0);
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 0);
SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 0);
SetIndexStyle(3, DRAW_NONE);
//----
SetIndexBuffer(0, Momentum);
SetIndexBuffer(1, bullishDivergence);
SetIndexBuffer(2, bearishDivergence);
SetIndexBuffer(3, MomDiv);
//----
SetIndexArrow(1, 233);
SetIndexArrow(2, 234);
//----
IndicatorDigits(Digits + 2);
IndicatorShortName("ClusterDelta_Div");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
for(int i = ObjectsTotal() - 1; i >= 0; i--)
{
string label = ObjectName(i);
if(StringSubstr(label, 0, 14) != "DivergenceLine")
continue;
ObjectDelete(label);
}
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int countedBars = IndicatorCounted();
if(countedBars < 0)
countedBars = 0;
CalculateIndicator(countedBars);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CalculateIndicator(int countedBars)
{
for(int i = 300; i >= 0; i--)
{
CalculateMomDiv(i);
CatchBullishDivergence(i + 2);
CatchBearishDivergence(i + 2);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CalculateMomDiv(int i)
{
Momentum[i] = iCustom(NULL, 0, "ClusterDelta_CumDelta", 0, i);
MomDiv[i] = Momentum[i];
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CatchBullishDivergence(int shift)
{
if(IsIndicatorTrough(shift) == false)
return;
int currentTrough = shift;
int lastTrough = GetIndicatorLastTrough(shift);
if(MomDiv[currentTrough] > MomDiv[lastTrough] && Low[currentTrough] < Low[lastTrough])
{
bullishDivergence[currentTrough] = MomDiv[currentTrough];
if(drawDivergenceLines == true)
{
DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], Low[currentTrough],
Low[lastTrough], Green, STYLE_SOLID);
DrawIndicatorTrendLine(Time[currentTrough], Time[lastTrough], MomDiv[currentTrough],
MomDiv[lastTrough], Green, STYLE_SOLID);
}
if(displayAlert == true)
DisplayAlert("Classical bullish divergence on: ", currentTrough);
}
if(MomDiv[currentTrough] < MomDiv[lastTrough] && Low[currentTrough] > Low[lastTrough])
{
bullishDivergence[currentTrough] = MomDiv[currentTrough];
if(drawDivergenceLines == true)
{
DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], Low[currentTrough],
Low[lastTrough], Green, STYLE_DOT);
DrawIndicatorTrendLine(Time[currentTrough], Time[lastTrough], MomDiv[currentTrough],
MomDiv[lastTrough], Green, STYLE_DOT);
}
if(displayAlert == true)
DisplayAlert("Reverse bullish divergence on: ", currentTrough);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CatchBearishDivergence(int shift)
{
if(IsIndicatorPeak(shift) == false)
return;
int currentPeak = shift;
int lastPeak = GetIndicatorLastPeak(shift);
if(MomDiv[currentPeak] < MomDiv[lastPeak] && High[currentPeak] > High[lastPeak])
{
bearishDivergence[currentPeak] = MomDiv[currentPeak];
if(drawDivergenceLines == true)
{
DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], High[currentPeak],
High[lastPeak], Red, STYLE_SOLID);
DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], MomDiv[currentPeak],
MomDiv[lastPeak], Red, STYLE_SOLID);
}
if(displayAlert == true)
DisplayAlert("Classical bearish divergence on: ", currentPeak);
}
if(MomDiv[currentPeak] > MomDiv[lastPeak] && High[currentPeak] < High[lastPeak])
{
bearishDivergence[currentPeak] = MomDiv[currentPeak];
if(drawDivergenceLines == true)
{
DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], High[currentPeak],
High[lastPeak], Red, STYLE_DOT);
DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], MomDiv[currentPeak],
MomDiv[lastPeak], Red, STYLE_DOT);
}
if(displayAlert == true)
DisplayAlert("Reverse bearish divergence on: ", currentPeak);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool IsIndicatorPeak(int shift)
{
if(MomDiv[shift] >= MomDiv[shift+1] && MomDiv[shift] > MomDiv[shift+2] &&
MomDiv[shift] > MomDiv[shift-1])
return(true);
else
return(false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool IsIndicatorTrough(int shift)
{
if(MomDiv[shift] <= MomDiv[shift+1] && MomDiv[shift] < MomDiv[shift+2] &&
MomDiv[shift] < MomDiv[shift-1])
return(true);
else
return(false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int GetIndicatorLastPeak(int shift)
{
for(int i = shift + 5; i < Bars; i++)
{
if(Momentum[i] >= Momentum[i+1] && Momentum[i] >= Momentum[i+2] &&
Momentum[i] >= Momentum[i-1] && Momentum[i] >= Momentum[i-2])
{
for(int j = i; j < Bars; j++)
{
if(MomDiv[j] >= MomDiv[j+1] && MomDiv[j] > MomDiv[j+2] &&
MomDiv[j] >= MomDiv[j-1] && MomDiv[j] > Momentum[j-2])
return(j);
}
}
}
return(-1); }
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int GetIndicatorLastTrough(int shift)
{
for(int i = shift + 5; i < Bars; i++)
{
if(Momentum[i] <= Momentum[i+1] && Momentum[i] <= Momentum[i+2] &&
Momentum[i] <= Momentum[i-1] && Momentum[i] <= Momentum[i-2])
{
for (int j = i; j < Bars; j++)
{
if(MomDiv[j] <= MomDiv[j+1] && MomDiv[j] < MomDiv[j+2] &&
MomDiv[j] <= MomDiv[j-1] && MomDiv[j] < MomDiv[j-2])
return(j);
}
}
}
return(-1); }
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DisplayAlert(string message, int shift)
{
if(shift <= 2 && Time[shift] != lastAlertTime)
{
lastAlertTime = Time[shift];
Alert(message, Symbol(), " , ", Period(), " minutes chart");
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DrawPriceTrendLine(datetime x1, datetime x2, double y1,
double y2, color lineColor, double style)
{
string label = "DivergenceLine2.1# " + DoubleToStr(x1, 0);
ObjectDelete(label);
ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);
ObjectSet(label, OBJPROP_RAY, 0);
ObjectSet(label, OBJPROP_COLOR, lineColor);
ObjectSet(label, OBJPROP_STYLE, style);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DrawIndicatorTrendLine(datetime x1, datetime x2, double y1,
double y2, color lineColor, double style)
{
int indicatorWindow = WindowFind("ClusterDelta_Div");
if(indicatorWindow < 0)
return;
string label = "DivergenceLine2.1$# " + DoubleToStr(x1, 0);
ObjectDelete(label);
ObjectCreate(label, OBJ_TREND, indicatorWindow, x1, y1, x2, y2, 0, 0);
ObjectSet(label, OBJPROP_RAY, 0);
ObjectSet(label, OBJPROP_COLOR, lineColor);
ObjectSet(label, OBJPROP_STYLE, style);
}
//+------------------------------------------------------------------+
Жутко вешает терминал. Индикатор на базе дивергенции Momentuma.
Заранее спасибо.
ни у кого нет предложений?
(C) 2009-2023 ClusterDelta.com.