|
|||||
|
|||||
Ïðîáîâàë ÿ è òàê. Ìîæåò ðóêè êðèâûå èëè ìîçãè, ñåé÷àñ âîîáùå íà ðàáîòå è íè÷åãî íå ñîîáðàæàþ. Äåëî â òîì, ÷òî åñëè ôóíêöèþ 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.