Navigation:Home > Content >

LFL-ATRprojections.mq4

Time: 2013-12-25 | Download file:LFL-ATRprojections.mq4

#property copyright "Copyright © 2009, Learn Forex Live"
#property link      "http://www.LearnForexLive.com"
#property indicator_chart_window

extern int ATR_Period = 7;
double Gd_80 = 70.0;
double Gd_88 = 50.0;
int    Gi_96 = 0;
int    Gi_100 = 11119017;
int    Gi_104 = 13882323;
int    Gi_108 = 0;
int    G_width_112 = 1;

int init() {
   return (0);
}

int deinit() {
   DrawLevel("High1", 0, Gi_108, Gi_96);
   DrawLevel("Low1", 0, Gi_108, Gi_96);
   DrawLevel("High2", 0, Gi_108, Gi_100);
   DrawLevel("Low2", 0, Gi_108, Gi_100);
   DrawLevel("High3", 0, Gi_108, Gi_104);
   DrawLevel("Low3", 0, Gi_108, Gi_104);
   return (0);
}

int start() {
   double Lda_68[2][6];
   int ind_counted_0 = IndicatorCounted();
   double iatr_4 = iATR(NULL, PERIOD_D1, ATR_Period, 0);
   double iatr_12 = iATR(NULL, PERIOD_D1, 7, 0);
   double Ld_20 = Ask - Bid;
   double Ld_28 = 0;
   double Ld_36 = 0;
   double Ld_unused_44 = Close[0];
   double Ld_52 = 0;
   double Ld_60 = 0;
   double Ld_72 = 0;
   double Ld_80 = 0;
   double tickvalue_88 = MarketInfo(Symbol(), MODE_TICKVALUE);
   double Ld_96 = iLow(NULL, PERIOD_D1, 0) + iatr_12;
   double Ld_104 = iHigh(NULL, PERIOD_D1, 0) - iatr_12;
   if (iatr_12 < 0.1) Ld_28 = 10000.0 * iatr_12;
   else Ld_28 = 100.0 * iatr_12;
   if (Ld_20 < 0.1) Ld_36 = 10000.0 * Ld_20;
   else Ld_36 = 100.0 * Ld_20;
   if (Ld_36 > 99.0) Ld_36 /= 100.0;
   else Ld_36 = Ld_36;
   ArrayCopyRates(Lda_68, Symbol(), PERIOD_D1);
   Ld_72 = Lda_68[0][3];
   Ld_80 = Lda_68[0][2];
   Ld_60 = Ld_72 - Ld_80;
   if (Ld_60 < 0.1) Ld_52 = 10000.0 * Ld_60;
   else Ld_52 = 100.0 * Ld_60;
   if (iLow(NULL, PERIOD_D1, 0) < 10.0) {
      Comment("Today = ", Ld_52, "   |   ATR = ", NormalizeDouble(Ld_28, 0), "   |   ATR Projection Up = ", NormalizeDouble(Ld_96, 4), "   |   ATR Projection Down = ",
         NormalizeDouble(Ld_104, 4));
   } else {
      Comment("Today = ", Ld_52, "   |   ATR = ", NormalizeDouble(Ld_28, 0), "   |   ATR Projection Up = ", NormalizeDouble(Ld_96, 2), "   |   ATR Projection Down = ",
         NormalizeDouble(Ld_104, 2));
   }
   double Ld_112 = iatr_4 / 2.0;
   double Ld_120 = (iHigh(NULL, PERIOD_D1, 0) - iLow(NULL, PERIOD_D1, 0)) / 2.0 + iLow(NULL, PERIOD_D1, 0);
   Ld_120 = NormalizeDouble(Ld_120, Digits);
   double Ld_128 = Ld_120 + Ld_112;
   Ld_128 = NormalizeDouble(Ld_128, Digits);
   double Ld_136 = Ld_120 + Ld_112 * (Gd_80 / 100.0);
   Ld_136 = NormalizeDouble(Ld_136, Digits);
   double Ld_144 = Ld_120 + Ld_112 * (Gd_88 / 100.0);
   Ld_144 = NormalizeDouble(Ld_144, Digits);
   double Ld_152 = Ld_120 - Ld_112;
   Ld_152 = NormalizeDouble(Ld_152, Digits);
   double Ld_160 = Ld_120 - Ld_112 * (Gd_80 / 100.0);
   Ld_160 = NormalizeDouble(Ld_160, Digits);
   double Ld_168 = Ld_120 - Ld_112 * (Gd_88 / 100.0);
   Ld_168 = NormalizeDouble(Ld_168, Digits);
   return (0);
}

void DrawLevel(string A_name_0, double A_price_8, int A_style_16, color A_color_20) {
   double price_24 = A_price_8;
   double price_32 = A_price_8;
   int time_40 = Time[iBarShift(NULL, 0, StrToTime(Year() + "." + Month() + "." + Day() + " " + 0 + ":" + 0))];
   int datetime_44 = Time[0];
   if (A_price_8 > 0.0) {
      if (ObjectFind(A_name_0) != 0) {
         ObjectCreate(A_name_0, OBJ_TREND, 0, time_40, price_24, datetime_44, price_32);
         ObjectSet(A_name_0, OBJPROP_RAY, FALSE);
         ObjectSet(A_name_0, OBJPROP_COLOR, A_color_20);
         ObjectSet(A_name_0, OBJPROP_WIDTH, G_width_112);
         ObjectSet(A_name_0, OBJPROP_STYLE, A_style_16);
         return;
      }
      ObjectSet(A_name_0, OBJPROP_RAY, FALSE);
      ObjectMove(A_name_0, 0, time_40, price_24);
      ObjectMove(A_name_0, 1, datetime_44, price_32);
      ObjectSet(A_name_0, OBJPROP_COLOR, A_color_20);
      ObjectSet(A_name_0, OBJPROP_WIDTH, G_width_112);
      ObjectSet(A_name_0, OBJPROP_STYLE, A_style_16);
      return;
   }
   if (ObjectFind(A_name_0) >= 0) ObjectDelete(A_name_0);
}

Recommend