ExtMapBuffer1[shift] = wt[shift];} //close bracket //Print(" Buffer #1 = " + ExtMapBuffer1[shift] + " Buffer #2 = " + ExtMapBuffer2[shift]); { //open bracket following a closing bracket, that shouldnt even compile .... if (ExtMapBuffer2[shift] != EMPTY_VALUE && AU == 0 && AD == 0)are you sure that this code has compiled without errors ?
Yes, the code compiles without errors.
if (wt[shift] < wt[shift+1]) //----- Red
{ExtMapBuffer2[shift] = EMPTY_VALUE;
ExtMapBuffer1[shift] = wt[shift];}
//Print(" Buffer #1 = " + ExtMapBuffer1[shift] + " Buffer #2 = " + ExtMapBuffer2[shift]);
} { is no valid code in all the languages i know ...
or i have missed something in the last years.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have been trying to figure out how the indicator below is able to draw a line in one color, Continuosly, and then a line in the next.
The values for wt[shift] and wt[shift+1] are constantly changing as well as the values of ExtMapBuffer1[shift] and ExtMapBuffer2[shift].
There has to be something more that I'm missing. Some sort of constant which determines why the indicator should keep painting one color, then the other.
I've tried to place arrows where the color starts, but with no luck; especially with the changing values.
Can anyone help? Or at least show me what I'm not seeing?
Thanks!
//+------------------------------------------------------------------+
//| |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, FX Sniper "
#property link "https://www.metaquotes.net//"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Lime
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
extern int Rperiod = 13;
extern int Draw4HowLongg = 1500;
extern int Type = 3;
int Draw4HowLong,shift,i,loopbegin,width,length,c,AD,AU;
double sum[];
double lengthvar;
double tmp ;
double wt[];
string ArrowUpA, ArrowDownA;
ObjectsDeleteAll();
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(4);
//---- drawing settings
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,sum);
SetIndexBuffer(3,wt);
SetIndexStyle(0,DRAW_LINE,0,5);
SetIndexStyle(1,DRAW_LINE,0,5);
//---- initialization done
return(0);
}
int start()
{
Draw4HowLong = Bars-Rperiod - 5;
length = Rperiod;
loopbegin = Draw4HowLong - length - 1;
double vH=iHigh(NULL,1,0); // 1 Minute Highest
double vL=iLow(NULL,1,0); // 1 Minute Lowest
double HL = (vH+vL)/2; // Average High - Low
for(shift = loopbegin; shift >= 0; shift--) //----- Begin Shift Loop
{
sum[1] = 0;
for(i = length; i >= 1 ; i--) //----- Begin i Loop
{
lengthvar = length + 1;
lengthvar /= 3;
tmp = 0;
if (Type==1)
tmp = ( i - lengthvar)*High[length-i+shift];
if (Type==2)
tmp = ( i - lengthvar)*Low[length-i+shift];
if (Type==3)
tmp = ( i - lengthvar)*Close[length-i+shift];
sum[1]+=tmp;
} //----- End i Loop
wt[shift] = sum[1]*6/(length*(length+1));
//========== COLOR CODING ===========================================
ExtMapBuffer1[shift] = wt[shift]; //----- Red
ExtMapBuffer2[shift] = wt[shift]; //----- Lime
if (wt[shift] > wt[shift+1]) //----- Lime
{ExtMapBuffer1[shift] = EMPTY_VALUE;
ExtMapBuffer2[shift] = wt[shift];}
if (wt[shift] < wt[shift+1]) //----- Red
{ExtMapBuffer2[shift] = EMPTY_VALUE;
ExtMapBuffer1[shift] = wt[shift];}
//Print(" Buffer #1 = " + ExtMapBuffer1[shift] + " Buffer #2 = " + ExtMapBuffer2[shift]);
{
if (ExtMapBuffer2[shift] != EMPTY_VALUE && AU == 0 && AD == 0)
{ObjectCreate(StringConcatenate("ArrowUpA",TimeCurrent()),OBJ_ARROW,0,Time[0],HL);
ObjectSet(StringConcatenate("ArrowUpA",TimeCurrent()), OBJPROP_COLOR, Lime);AU = AU + 1; AD = 0;}
}
{
if (ExtMapBuffer1[shift] != EMPTY_VALUE && AU == 0 && AD == 0)
{ObjectCreate(StringConcatenate("ArrowDownA",TimeCurrent()),OBJ_ARROW,0,Time[0],HL);
ObjectSet(StringConcatenate("ArrowDownA",TimeCurrent()), OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
ObjectSet(StringConcatenate("ArrowDownA",TimeCurrent()), OBJPROP_COLOR, Red); AD = AD + 1; AU = 0;}
//Print("AD = " + AD + " : AU = " + AU);
} //----- End Shift Loop
}
return(0);
}
//+------------------------------------------------------------------+