|
Help adding OBJ_TREND to indicator
//+------------------------------------------------------------------+
//| S_R trendline.mq4 |
//| Copyright © 2005, nicugh |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, nicugh"
#property link ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- buffers
double v1[];
double v2[];
double val1;
double val2;
int i;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexDrawBegin(0,i-1);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Resistance");
ObjectCreate("Resistance", OBJ_TREND, 0, 0,v1[i],CurTime(),v1[i]);
//my problem is I can not create OBJ_TREND automaticaly
//it is created by the buffer's values only if it is compiled
//else (price 1=0, price2=0)
// and it is moved on the last line only when compiled
//I am not a programmer, can you help me, thank you
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,i-1);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"Support");
ObjectCreate("Support", OBJ_TREND, 0, 0,v2[i],CurTime(),v2[i]);
//my problem is I can not create OBJ_TREND automaticaly
//it is created by the buffer's values only if it is compiled
//else (price 1=0, price2=0)
// and it is moved on the last line only when compiled
//I am not a programmer, can you help me, thank you
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("Resistance");
ObjectDelete("Support");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// int counted_bars=IndicatorCounted();
i=Bars;
while(i>=0)
{
val1 = iFractals(NULL, 0, MODE_UPPER,i);
if (val1 > 0)
v1[i]=High[i];
else
v1[i] = v1[i+1];
val2 = iFractals(NULL, 0, MODE_LOWER,i);
if (val2 > 0)
v2[i]=Low[i];
else
v2[i] = v2[i+1];
i--;
}
}
//+------------------------------------------------------------------+
//my problem is I can not create OBJ_TREND automaticaly
//it is created by the buffer's values only if it is compiled
//else (price 1=0, price2=0)
// and it is moved on the last line only when compiled
//I am not a programmer, can you help me, thank you
|