Download MetaTrader 5
To add comments, please log in or register
Unable to find the answer to your question? Use the search!
Forex Trader
114237
Forex Trader 2010.03.09 01:23 

I know I've posted this problem in here before, but please bear w/ me. Here's the code:

#property copyright "Copyright © 2010, Nondisclosure007"
#property link      "http://no.link.yet"
#property indicator_chart_window
#property indicator_buffers 2

double floor[];
double ceiling[];
int init()
  {
   IndicatorBuffers(2);
   IndicatorDigits(Digits);  
   SetIndexBuffer(0,floor);  
   SetIndexLabel(0,"Lower Angle");
   SetIndexBuffer(1,ceiling);
   SetIndexLabel(1,"Upper Angle");
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   ArraySetAsSeries(floor,true);
   ArraySetAsSeries(ceiling,true);
   return(0);
  }
int deinit()
  {
   ObjectDelete("LowerAngle");ObjectDelete("UpperAngle");
   return(0);
  }
int start()
  {
   int i, k, limit, counted_bars=IndicatorCounted();
   limit = Bars-counted_bars-1;
   double varLowMACurrent, varLowMALast, varHighMALast, varHighMACurrent;
   datetime varTime;
   for(i=limit; i>=0; i--)
   {
      varHighMALast=iMA(NULL,0,34,0,MODE_EMA,PRICE_HIGH,i+2);
      varLowMALast=iMA(NULL,0,34,0,MODE_EMA,PRICE_LOW,i+2);
      if (ObjectFind("LowerAngle")==-1)
         {ObjectCreate("LowerAngle",OBJ_TRENDBYANGLE,0,Time[i+2],varLowMALast);
          ObjectSet("LowerAngle",OBJPROP_ANGLE,330);}
      ObjectSet("LowerAngle",OBJPROP_ANGLE,330);
      ObjectSet("LowerAngle",OBJPROP_STYLE,STYLE_DOT);
      ObjectSet("LowerAngle",OBJPROP_COLOR,Magenta);
      ObjectSet("LowerAngle",OBJPROP_RAY,true);      
      floor[i]=ObjectGetValueByShift("LowerAngle",i);
      if (ObjectFind("UpperAngle")==-1)
         {ObjectCreate("UpperAngle",OBJ_TRENDBYANGLE,0,Time[i+2],varHighMALast);
          ObjectSet("UpperAngle",OBJPROP_ANGLE,30);}
      ObjectSet("UpperAngle",OBJPROP_ANGLE,30);
      ObjectSet("UpperAngle",OBJPROP_STYLE,STYLE_DOT);
      ObjectSet("UpperAngle",OBJPROP_COLOR,Magenta);
      ObjectSet("UpperAngle",OBJPROP_RAY,true);      
      ceiling[i]=ObjectGetValueByShift("UpperAngle",i);
      WindowRedraw();
   }
   return(0);
  }
//+------------------------------------------------------------------+

Here's the coordinates of the angles that get created:

Lower:

Upper:

So, why are my first coordinates so far off?
Forex Trader
114237
Forex Trader 2010.03.09 01:37  
I changed the for loop to this:
for(i=0; i<limit; i++)

Now, the first coordinate is correct, but when I go for the ObjectGetValueByShift(angle,i), I get the first coordinate value.

And the indicator won't update when a new candle is formed.

Pleeeaaaaase. Can anyone help?

Forex Trader
114237
Forex Trader 2010.03.09 04:54  
nondisclosure007 :
I changed the for loop to this:
for(i=0; i<limit; i++)

Now, the first coordinate is correct, but when I go for the ObjectGetValueByShift(angle,i), I get the first coordinate value.

And the indicator won't update when a new candle is formed.

Pleeeaaaaase. Can anyone help?

So, I've found out that I get an error when I call ObjectGetValueByShift(angle,i). Why? Error is 4205. Now, grant it one coordinate is at the 2nd bar in the chart and the second is off of the chart (like bar -12 or something). Could that be an issue?

Forex Trader
114237
Forex Trader 2010.03.29 12:45  
nice
/
To add comments, please log in or register