Hi, I wrote an indicator with two different MACDs in the same window and at the same scale.
I now need to go through all of the SEEN bars again and find the time when the second indicator signal line (orange) on ZERO bar will be equal to the first signal line (red).
Can anyone help me figure it out?
Код 2
-----
#property indicator_separate_window#property indicator_buffers 6#property indicator_color1 Lime#property indicator_color2 Red#property indicator_color5 Aqua#property indicator_color6 DarkOrange#property indicator_width1 2#property indicator_width5 2//--- buffersdouble Macd1Buffer[];
double Signal1Buffer[];
double Macd2Buffer[];
double Signal2Buffer[];
double Macd3Buffer[];
double Signa13Buffer[];
//--- for one bardatetime last;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- indicatorsSetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(0,Macd1Buffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Signal1Buffer);
SetIndexStyle(2,DRAW_NONE);
SetIndexBuffer(2,Macd2Buffer);
SetIndexStyle(3,DRAW_NONE);
SetIndexBuffer(3,Signal2Buffer);
SetIndexStyle(4,DRAW_NONE);
SetIndexBuffer(4,Macd3Buffer);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,Signa13Buffer);
IndicatorDigits(Digits);
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int start()
{
if(last>=Time[0]) return;
double max_M1=-0.01,min_M1=0.01,
max_M2=-0.01,min_M2=0.01,
max_S1=-0.01,min_S1=0.01,
max_S2=-0.01,min_S2=0.01,
max1=-0.01,min1=0.01,
max2=-0.01,min2=0.01,
max3,
M,
Dmax_3,
D_sig,
D_sig_Last=1.0;
int j=0;
while(j<WindowBarsPerChart()-1)
{
//----for(int i=0;i<=j;i++)
{
Macd1Buffer[i]=iMACD(0,PERIOD_H1,6,12,5,PRICE_CLOSE,MODE_MAIN,i+1); // основная линия 1-ого MACD
Macd2Buffer[i]=iMACD(0,PERIOD_H1,12,26,9,PRICE_CLOSE,MODE_MAIN,i+1); // основная линия 2-ого MACD
max_M1=MathMax(Macd1Buffer[i],max_M1);
min_M1=MathMin(Macd1Buffer[i],min_M1);
max_M2=MathMax(Macd2Buffer[i],max_M2);
min_M2=MathMin(Macd2Buffer[i],min_M2);
Signal1Buffer[i]=iMACD(0,PERIOD_H1,6,12,5,PRICE_CLOSE,MODE_SIGNAL,i+1); // сигнальная линия 1-ого MACD
Signal2Buffer[i]=iMACD(0,PERIOD_H1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i+1); // сигнальная линия 2-ого MACD
max_S1=MathMax(Signal1Buffer[i],max_S1);
min_S1=MathMin(Signal1Buffer[i],min_S1);
max_S2=MathMax(Signal2Buffer[i],max_S2);
min_S2=MathMin(Signal2Buffer[i],min_S2);
max1=MathMax(max_M1,max_S1); // максимум 1-ого MACD
min1=MathMin(min_M1,min_S1); // минимум 1-ого MACD
max2=MathMax(max_M2,max_S2); // максимум 2-ого MACD
min2=MathMin(min_M2,min_S2); // минимум 2-ого MACD
}
M=(max1-min1)/(max2-min2); // соотношение диапазонов max-min 1-ого и 2-ого MACD
max3=max2*M; // max 3-его MACD,т.е."нового" 2-ого MACD
Dmax_3=max1-max3; // смещение 3-ого MACD относительно 1-ого MACDfor( i=0;i<=j;i++)
{
Macd3Buffer[0]=Macd2Buffer[0]*M+Dmax_3; // приведение диапазона max-min 2-ого MACD к диапазону 1-ого MACD,// т.е.подучаем 3-ий MACD и совмещаем max и min 3-его MACD с // max и min 1-ого MACD
Signa13Buffer[0]=Signal2Buffer[0]*M+Dmax_3; // max и min 1-ого MACD
}
D_sig=MathAbs(Signal1Buffer[0]-Signa13Buffer[0]); // разница между сигнальными линиями 1-ого и 3-ого MACD на// нулевом бареif(Signa13Buffer[0]==Signal1Buffer[0])
break;
D_sig_Last=D_sig;
j++;
}
Comment( "\n"," Баров = ",WindowBarsPerChart()-1,
"\n"," Macd1Buffer = ",DoubleToStr(Macd1Buffer[0],4),
"\n"," Signal1Buffer = ",DoubleToStr(Signal1Buffer[0],4),
"\n"," Macd3Buffer = ",DoubleToStr(Macd3Buffer[0],4),
"\n"," Signa13Buffer = ",DoubleToStr(Signa13Buffer[0],4),
"\n"," D_sig = ",DoubleToStr(D_sig,4));
//----
last=Time[0];
//----return(0);
}
//+------------------------------------------------------------------+
Hi, I wrote an indicator with two different MACDs in the same window and at the same scale.
I now need to go through all of the SEEN bars again and find the time when the second indicator signal line (orange) on ZERO bar will be equal to the first signal line (red).
Hi, I wrote an indicator with two different MACDs in the same window and at the same scale.
I now need to go through all of the SEEN bars again and find the time when the second indicator signal line (orange) on ZERO bar will be equal to the first signal line (red).
Can anyone help me figure it out?
And what does the stoplevel equal?
Aha!!! It's on the screen in the main EA): 30 pips............................((((((((((((((((((((
Still, what about if(....) can I run through this balalaika, my MT4 condition?):
Aha!!! It's on the screen in the main EA): 30 pips............................((((((((((((((((((((
Still, what with if(....) can I get through this balalaika, my MT4 condition?):
it is possible to do without a stopgap... not a fact, or rather a fact again in the condition of natural value comparison...
Aha!!! It's on the screen in the main EA): 30 pips............................((((((((((((((((((((
Still, what with if(....) can I get through this balalaika, my MT4 condition?):
Indicator and EA are completely different things
Hi, I wrote an indicator with two different MACDs in the same window and at the same scale.
I now need to go through all of the SEEN bars again and find the time when the second indicator signal line (orange) on ZERO bar will be equal to the first signal line (red).
Will someone help me figure it out?
D_sig=MathAbs(Signal1Buffer[0]-Signa13Buffer[0]);
Why MathAbs if you define 0
just have to subtract
//---------------------------------------------------------------------------------------
if(Signa13Buffer[0]==Signal1Buffer[0])
and here we should probably if(D_Sig==0) { command for signal ; }
Tried another way of comparing
if(highest-Cls1<=highest-50*Point) or add,
result is the same)))))........... MT4 does not see the conditions...(:
Give me your indicator
D_sig=MathAbs(Signal1Buffer[0]-Signa13Buffer[0]);
Why MathAbs if you define 0
we just need to subtract
//---------------------------------------------------------------------------------------
if(Signa13Buffer[0]==Signal1Buffer[0])
but here it must be if(D_Sig==0) { command for signal ; }
Thanks for wanting to help. I put if (D_sig==0) { command for the signal ; }. "Steps" became less, but still they are.
And MathAbs put for what was a "corridor" for comparison, because the probability that the signal lines will be absolutely equal, negligible.
Maybe someone else has thoughts on my problem?
The difficulty is that WITHOUT THIS.................... && highest-Cls1<=50*Point)..... EVERYTHING WORKS and this one doesn't!
Too strict conditions. Make it not 50, at least 250-500.
It should have been enough to do the priming from the start, but you didn't want to.
Thank you! Interesting you if() { ...split with brackets...))):
And how do you do shifts (indents) of program code in the form of snake C??? I can't find it in the MT4 settings.... ):
That's the way there seems to be a tab.
The simpler the condition, the easier to check, and it works faster