How to retrieve the OBJ_STDDEVCHANNEL upper and lower line value?

 
//+------------------------------------------------------------------+
//|                                               Trendline Indi.mq4 |
//|                                                       GoldlandFX |
//|                                        http://www.goldlandfx.com |
//+------------------------------------------------------------------+
#property copyright "GoldlandFX"
#property link      "http://www.goldlandfx.com"

datetime          x1,x2,x3;
double            y1,y2,y3;
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("T1");
   ObjectDelete("T2");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   x1 = Time[50];
   y1 = High[50];
   x2 = Time[0];
   y2 = High[0];
   x3 = Time[20];
   y3 = High[20];
   
   //ObjectCreate("T1", OBJ_TREND, 0, x1, y1, x2, y2);
   Comment("");
   ObjectDelete("T1");
   ObjectCreate("T1", OBJ_STDDEVCHANNEL, 0, x1, y1, x2, y2);
   ObjectSet("T1", OBJPROP_COLOR, Lime);
   ObjectSet("T1", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("T1", OBJPROP_RAY, 0);
   ObjectSet("T1", OBJPROP_FIBOLEVELS, 3);
   ObjectSet("T1", OBJPROP_DEVIATION, 2);
   ObjectSet("T1", OBJPROP_LEVELCOLOR, Red);
Print("TL1:"+ObjectGet("T1", OBJPROP_FIRSTLEVEL+1)); //prints 0
Print("TL2:"+ObjectGet("T1", OBJPROP_FIRSTLEVEL+2)); //prints 0
Print("TL3:"+ObjectGet("T1", OBJPROP_FIRSTLEVEL+3)); //prints 0
   
   ObjectDelete("T2");
   ObjectCreate("T2", OBJ_STDDEVCHANNEL, 0, x3, y3, x2, y2);
   ObjectSet("T2", OBJPROP_COLOR, Yellow);
   ObjectSet("T2", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("T2", OBJPROP_RAY, 0);
   Print ("Bar0: "+ObjectGetValueByShift("T2", 1));
   
   string str="";
   for( int n=0; n<21; n++ )
      str = str + "n= " + n + ": " + DoubleToStr( ObjectGetValueByShift("T1",n), Digits ) + "\n";
   
   Comment( str );

//----
   return(0);
  }
//+------------------------------------------------------------------+


Wonder how to retrieve value

Print("TL1:"+ObjectGet("T1", OBJPROP_FIRSTLEVEL+1)); //prints 0
Print("TL2:"+ObjectGet("T1", OBJPROP_FIRSTLEVEL+2)); //prints 0
Print("TL3:"+ObjectGet("T1", OBJPROP_FIRSTLEVEL+3)); //prints 0


Wonder how to retrieve value value of the upper and lower band value? Anyone can shade some lights on this? Possible work around?

 

i think you would have to calculate them.

Standard Deviation Channel is built on base of Linear Regression Trend representing a ussual trendline built between two points on the price chart using the method of least squares. Standard Deviation Channel consists of two parallel lines, equidistant up and down from the Linear Regression Trend. The distance between frame of the channel and regression line equals to the value of standard close price deviation from the regression line.

I guess that means you need to calculate the whole indicator starting with the least squares regression line of the close prices unless maybe objectGetValueByShift() returns the regression line value

 

I kind of find a solution here.

https://forum.mql4.com/47312/page2

Just combine the bottom 2 post.

Files:
Reason: