Download MetaTrader 5

Drawing Angles w/ MQL4, Rosh

To add comments, please log in or register
How to buy a product in MetaTrader AppStore? Read the article!
Forex Trader
114257
Forex Trader 2010.03.15 06:24 

Hi all (espicially Rosh),

I'm attaching a couple of image of what happens when I put my indicator on a chart. It draws angles on the chart and I get the right vaules, for a while. Then the indicator starts drawing my angles "backwards".

I'll add the code here. The images that file, are when the angles are drawn correctly, and then when they aren't.


#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(1,floor);  
   SetIndexLabel(1,"Lower Angle");
   SetIndexBuffer(0,ceiling);
   SetIndexLabel(0,"Upper Angle");
   return(0);
  }
int deinit()
  {
   ObjectDelete("LowerAngle");ObjectDelete("UpperAngle");
   return(0);
  }
int start()
  {
   int i, k, limit, floorError, ceilingError, counted_bars=IndicatorCounted();
   limit = Bars-counted_bars-1;
   double varLowMALast, varHighMALast;
   string thedate;
   for(i=limit; i>=0; i--)
   {
      varLowMALast=iMA(NULL,0,34,0,MODE_EMA,PRICE_LOW,i+2);
      varHighMALast=iMA(NULL,0,34,0,MODE_EMA,PRICE_HIGH,i+2);
      if (ObjectFind("LowerAngle")==-1)
         {ObjectCreate("LowerAngle",OBJ_TRENDBYANGLE,0,Time[i+2],varLowMALast);
          ObjectSet("LowerAngle",OBJPROP_ANGLE,330);
          ObjectSet("LowerAngle",OBJPROP_STYLE,STYLE_DOT);
          ObjectSet("LowerAngle",OBJPROP_COLOR,Magenta);
          ObjectSet("LowerAngle",OBJPROP_RAY,true);
         }
      ObjectMove("LowerAngle",0,Time[i+2],varLowMALast);
      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_STYLE,STYLE_DOT);
          ObjectSet("UpperAngle",OBJPROP_COLOR,Magenta);
          ObjectSet("UpperAngle",OBJPROP_RAY,true);
         }
      ObjectMove("UpperAngle",0,Time[i+2],varHighMALast);
      ceiling[i]=ObjectGetValueByShift("UpperAngle",i);
      WindowRedraw();
   }
   return(0);
  }
//+------------------------------------------------------------------+

To add comments, please log in or register