Navigation´╝ÜHome > Content >

MTH_Renko_Chart_Builder_Indi_Ver_01.mq4

Time: 2017-12-22 | Download file:MTH_Renko_Chart_Builder_Indi_Ver_01.mq4

#property copyright "mth depok"
#property link      "do your homework mate..."

#property indicator_chart_window

#include 
#import "stdlib.ex4"
   string ErrorDescription(int a0); // DA69CBAFF4D38B87377667EEC549DE5A
   bool CompareDoubles(double a0, double a1); // 3AD21CD8C006FF1571E191BE69ADAC49
#import "user32.dll"
   int RegisterWindowMessageA(string a0);
#import

extern double StartingPrice = 131.0;
extern double RenkoBoxSize1 = 5.0;
extern double BoxShiftPercent1 = 25.0;
extern int RenkoTimeFrame1 = 2;
extern int RenkoBoxOffset1 = 0;
extern bool ShowWicks1 = TRUE;
extern int MaxBars1 = 20000;
extern bool Use2ndRenkoChart = FALSE;
extern double RenkoBoxSize2 = 10.0;
extern double BoxShiftPercent2 = 50.0;
extern int RenkoTimeFrame2 = 3;
extern int RenkoBoxOffset2 = 0;
extern bool ShowWicks2 = TRUE;
extern int MaxBars2 = 10000;
extern bool EmulateOnLineChart = TRUE;
extern bool StrangeSymbolName = FALSE;
int G_file_160 = -1;
int Gi_164 = 0;
int Gi_168 = WM_NULL;
int G_file_172 = -1;
int Gi_176 = 0;
int Gi_180 = WM_NULL;
string Gs_184;
int Gi_192 = 0;
int Gi_196 = 0;
double Gd_200;
double Gd_208;
double Gd_216;
double Gd_224;
double Gd_232;
double Gd_240;
double Gd_248;
double Gd_256;
double Gd_264;
double Gd_272;
double Gd_280;
double Gd_288;
int Gi_296;
double Gd_300;
double Gd_308;
double Gd_316;
double Gd_324;
double Gd_332;
double Gd_340;
double Gd_348;
double Gd_356;
double Gd_364;
double Gd_372;
double Gd_380;
double Gd_388;
int Gi_396;

// D27976E8A89302260DF2848BFF6FEBFC
void f0_0() {
   if (Gi_192 == 0) {
      Gi_192 = WindowHandle(Gs_184, RenkoTimeFrame1);
      if (Gi_192 != 0) Print("Chart window detected");
   }
   if (EmulateOnLineChart && Gi_168 == 0) Gi_168 = RegisterWindowMessageA("MetaTrader4_Internal_Message");
   if (Gi_192 != 0)
      if (PostMessageA(Gi_192, WM_COMMAND, 33324, 0) == 0) Gi_192 = 0;
   if (Gi_192 != 0 && Gi_168 != 0) PostMessageA(Gi_192, Gi_168, 2, 1);
   if (Gi_196 == 0) {
      Gi_196 = WindowHandle(Gs_184, RenkoTimeFrame2);
      if (Gi_196 != 0) Print("Chart window detected");
   }
   if (EmulateOnLineChart && Gi_180 == 0) Gi_180 = RegisterWindowMessageA("MetaTrader4_Internal_Message");
   if (Gi_196 != 0)
      if (PostMessageA(Gi_196, WM_COMMAND, 33324, 0) == 0) Gi_196 = 0;
   if (Gi_196 != 0 && Gi_180 != 0) PostMessageA(Gi_196, Gi_180, 2, 1);
}
	 	 						    	 		  	  	 			   				 		 	 			   	   	 	 				  			  			   		  	  	          	   	  			  		 	 					    			   	 	 	 	   	  					 		  
// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_0;
   int Li_4;
   int Lia_8[13];
   int Li_12;
   int Li_16;
   int Li_20;
   int Li_24;
   int Lia_28[13];
   int Li_32;
   int Li_36;
   if (G_file_160 < 0) {
      if (!IsDllsAllowed()) {
         Print("Error: Dll calls must be allowed!");
         return (-1);
      }
      if (MathAbs(RenkoBoxOffset1) >= RenkoBoxSize1) {
         Print("Error: |RenkoBoxOffset| should be less then RenkoBoxSize1!");
         return (-1);
      }
      Li_0 = RenkoBoxSize1;
      Li_4 = RenkoBoxOffset1;
      if (Digits == 5 || (Digits == 3 && StringFind(Symbol(), "JPY") != -1)) {
         Li_0 = 10 * Li_0;
         Li_4 = 10 * Li_4;
      }
      if (Digits == 6 || (Digits == 4 && StringFind(Symbol(), "JPY") != -1)) {
         Li_0 = 100 * Li_0;
         Li_4 = 100 * Li_4;
      }
      if (StrangeSymbolName) Gs_184 = StringSubstr(Symbol(), 0, 6);
      else Gs_184 = Symbol();
      Gd_200 = NormalizeDouble(Li_0 * Point, Digits);
      if (Close[Bars - 1] >= StartingPrice) Gd_224 = NormalizeDouble(Li_4 * Point + MathFloor((Close[Bars - 1] - StartingPrice) / Gd_200) * Gd_200 + StartingPrice, Digits);
      if (Close[Bars - 1] < StartingPrice) Gd_224 = NormalizeDouble(Li_4 * Point + StartingPrice - MathCeil((StartingPrice - (Close[Bars - 1])) / Gd_200) * Gd_200 - Point, Digits);
      Gd_216 = Gd_224;
      Gd_232 = Gd_224 + Gd_200;
      Gd_208 = Gd_232;
      Gd_240 = Gd_224;
      Gd_248 = Gd_232;
      Gd_256 = 1;
      Gi_296 = Time[Bars - 1];
      G_file_160 = FileOpenHistory(Gs_184 + RenkoTimeFrame1 + ".hst", FILE_BIN|FILE_WRITE);
      if (G_file_160 < 0) {
         Print("Error: can\'t create / open history file: " + ErrorDescription(GetLastError()) + ": " + Gs_184 + RenkoTimeFrame1 + ".hst");
         return (-1);
      }
      FileWriteInteger(G_file_160, 400, LONG_VALUE);
      FileWriteString(G_file_160, "", 64);
      FileWriteString(G_file_160, Gs_184, 12);
      FileWriteInteger(G_file_160, RenkoTimeFrame1, LONG_VALUE);
      FileWriteInteger(G_file_160, Digits, LONG_VALUE);
      FileWriteInteger(G_file_160, 0, LONG_VALUE);
      FileWriteInteger(G_file_160, 0, LONG_VALUE);
      FileWriteArray(G_file_160, Lia_8, 0, 13);
      Li_12 = Bars - 2;
      if (Li_12 > MaxBars1) Li_12 = MaxBars1;
      while (Li_12 >= 0) {
         Gd_256 += Volume[Li_12];
         Gd_208 = MathMax(Gd_208, High[Li_12]);
         Gd_216 = MathMin(Gd_216, Low[Li_12]);
         Li_16 = High[Li_12] + Low[Li_12] > High[Li_12 + 1] + (Low[Li_12 + 1]);
         while (!Li_16 && Low[Li_12] < Gd_224 - BoxShiftPercent1 / 100.0 * Gd_200 || CompareDoubles(Low[Li_12], Gd_224 - BoxShiftPercent1 / 100.0 * Gd_200)) {
            Gd_232 -= BoxShiftPercent1 / 100.0 * Gd_200;
            Gd_224 -= BoxShiftPercent1 / 100.0 * Gd_200;
            Gd_240 = Gd_232;
            Gd_248 = Gd_224;
            FileWriteInteger(G_file_160, Gi_296, LONG_VALUE);
            FileWriteDouble(G_file_160, Gd_240, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_224, DOUBLE_VALUE);
            if (ShowWicks1 && Gd_208 > Gd_232) FileWriteDouble(G_file_160, Gd_208, DOUBLE_VALUE);
            else FileWriteDouble(G_file_160, Gd_232, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_248, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_256, DOUBLE_VALUE);
            Gd_208 = 0;
            Gd_216 = EMPTY_VALUE;
            Gd_256 = 0;
            Gd_272 = Gd_224;
            Gd_264 = Gd_224;
            if (Gi_296 < Time[Li_12]) Gi_296 = Time[Li_12];
            else Gi_296++;
         }
         while (High[Li_12] > Gd_232 + BoxShiftPercent1 / 100.0 * Gd_200 || CompareDoubles(High[Li_12], Gd_232 + BoxShiftPercent1 / 100.0 * Gd_200)) {
            Gd_232 += BoxShiftPercent1 / 100.0 * Gd_200;
            Gd_224 += BoxShiftPercent1 / 100.0 * Gd_200;
            Gd_240 = Gd_224;
            Gd_248 = Gd_232;
            FileWriteInteger(G_file_160, Gi_296, LONG_VALUE);
            FileWriteDouble(G_file_160, Gd_240, DOUBLE_VALUE);
            if (ShowWicks1 && Gd_216 < Gd_224) FileWriteDouble(G_file_160, Gd_216, DOUBLE_VALUE);
            else FileWriteDouble(G_file_160, Gd_224, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_232, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_248, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_256, DOUBLE_VALUE);
            Gd_208 = 0;
            Gd_216 = EMPTY_VALUE;
            Gd_256 = 0;
            Gd_272 = Gd_232;
            Gd_264 = Gd_232;
            if (Gi_296 < Time[Li_12]) Gi_296 = Time[Li_12];
            else Gi_296++;
         }
         while (Li_16 && Low[Li_12] < Gd_224 - BoxShiftPercent1 / 100.0 * Gd_200 || CompareDoubles(Low[Li_12], Gd_224 - BoxShiftPercent1 / 100.0 * Gd_200)) {
            Gd_232 -= BoxShiftPercent1 / 100.0 * Gd_200;
            Gd_224 -= BoxShiftPercent1 / 100.0 * Gd_200;
            Gd_240 = Gd_232;
            Gd_248 = Gd_224;
            FileWriteInteger(G_file_160, Gi_296, LONG_VALUE);
            FileWriteDouble(G_file_160, Gd_240, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_224, DOUBLE_VALUE);
            if (ShowWicks1 && Gd_208 > Gd_232) FileWriteDouble(G_file_160, Gd_208, DOUBLE_VALUE);
            else FileWriteDouble(G_file_160, Gd_232, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_248, DOUBLE_VALUE);
            FileWriteDouble(G_file_160, Gd_256, DOUBLE_VALUE);
            Gd_208 = 0;
            Gd_216 = EMPTY_VALUE;
            Gd_256 = 0;
            Gd_272 = Gd_224;
            Gd_264 = Gd_224;
            if (Gi_296 < Time[Li_12]) Gi_296 = Time[Li_12];
            else Gi_296++;
         }
         Li_12--;
      }
      Gi_164 = FileTell(G_file_160);
      if (Close[0] > MathMax(Gd_248, Gd_240)) Gd_280 = MathMax(Gd_248, Gd_240);
      else {
         if (Close[0] < MathMin(Gd_248, Gd_240)) Gd_280 = MathMin(Gd_248, Gd_240);
         else Gd_280 = Close[0];
      }
      Gd_288 = Close[0];
      if (Gd_208 > Gd_232) Gd_272 = Gd_208;
      if (Gd_216 < Gd_224) Gd_264 = Gd_216;
      FileWriteInteger(G_file_160, Gi_296, LONG_VALUE);
      FileWriteDouble(G_file_160, Gd_280, DOUBLE_VALUE);
      FileWriteDouble(G_file_160, Gd_264, DOUBLE_VALUE);
      FileWriteDouble(G_file_160, Gd_272, DOUBLE_VALUE);
      FileWriteDouble(G_file_160, Gd_288, DOUBLE_VALUE);
      FileWriteDouble(G_file_160, Gd_256, DOUBLE_VALUE);
      FileFlush(G_file_160);
      f0_0();
      return (0);
   }
   Gd_208 = MathMax(Gd_208, Bid);
   Gd_216 = MathMin(Gd_216, Bid);
   Gd_256++;
   FileSeek(G_file_160, Gi_164, SEEK_SET);
   if (Bid > Gd_232 + BoxShiftPercent1 / 100.0 * Gd_200 || CompareDoubles(Bid, Gd_232 + BoxShiftPercent1 / 100.0 * Gd_200)) {
      Gd_232 += BoxShiftPercent1 / 100.0 * Gd_200;
      Gd_224 += BoxShiftPercent1 / 100.0 * Gd_200;
      Gd_240 = Gd_224;
      Gd_248 = Gd_232;
      FileWriteInteger(G_file_160, Gi_296, LONG_VALUE);
      FileWriteDouble(G_file_160, Gd_240, DOUBLE_VALUE);
      if (ShowWicks1 && Gd_216 < Gd_224) FileWriteDouble(G_file_160, Gd_216, DOUBLE_VALUE);
      else FileWriteDouble(G_file_160, Gd_224, DOUBLE_VALUE);
      FileWriteDouble(G_file_160, Gd_232, DOUBLE_VALUE);
      FileWriteDouble(G_file_160, Gd_248, DOUBLE_VALUE);
      FileWriteDouble(G_file_160, Gd_256, DOUBLE_VALUE);
      FileFlush(G_file_160);
      Gi_164 = FileTell(G_file_160);
      if (Gi_296 < TimeCurrent()) Gi_296 = TimeCurrent();
      else Gi_296++;
      Gd_256 = 0;
      Gd_272 = Gd_232;
      Gd_264 = Gd_232;
      Gd_208 = 0;
      Gd_216 = EMPTY_VALUE;
      f0_0();
   } else {
      if (Bid < Gd_224 - BoxShiftPercent1 / 100.0 * Gd_200 || CompareDoubles(Bid, Gd_224 - BoxShiftPercent1 / 100.0 * Gd_200)) {
         Gd_232 -= BoxShiftPercent1 / 100.0 * Gd_200;
         Gd_224 -= BoxShiftPercent1 / 100.0 * Gd_200;
         Gd_240 = Gd_232;
         Gd_248 = Gd_224;
         FileWriteInteger(G_file_160, Gi_296, LONG_VALUE);
         FileWriteDouble(G_file_160, Gd_240, DOUBLE_VALUE);
         FileWriteDouble(G_file_160, Gd_224, DOUBLE_VALUE);
         if (ShowWicks1 && Gd_208 > Gd_232) FileWriteDouble(G_file_160, Gd_208, DOUBLE_VALUE);
         else FileWriteDouble(G_file_160, Gd_232, DOUBLE_VALUE);
         FileWriteDouble(G_file_160, Gd_248, DOUBLE_VALUE);
         FileWriteDouble(G_file_160, Gd_256, DOUBLE_VALUE);
         FileFlush(G_file_160);
         Gi_164 = FileTell(G_file_160);
         if (Gi_296 < TimeCurrent()) Gi_296 = TimeCurrent();
         else Gi_296++;
         Gd_256 = 0;
         Gd_272 = Gd_224;
         Gd_264 = Gd_224;
         Gd_208 = 0;
         Gd_216 = EMPTY_VALUE;
         f0_0();
      } else {
         if (Bid > Gd_272) Gd_272 = Bid;
         if (Bid < Gd_264) Gd_264 = Bid;
         Gd_280 = Gd_248;
         Gd_288 = Bid;
         FileWriteInteger(G_file_160, Gi_296, LONG_VALUE);
         FileWriteDouble(G_file_160, Gd_280, DOUBLE_VALUE);
         FileWriteDouble(G_file_160, Gd_264, DOUBLE_VALUE);
         FileWriteDouble(G_file_160, Gd_272, DOUBLE_VALUE);
         FileWriteDouble(G_file_160, Gd_288, DOUBLE_VALUE);
         FileWriteDouble(G_file_160, Gd_256, DOUBLE_VALUE);
         FileFlush(G_file_160);
         f0_0();
      }
   }
   if (!Use2ndRenkoChart) Comment("MTH Renko Chart Builder Indi Ver 01 (" + DoubleToStr(RenkoBoxSize1, 1) + ") point: Open Offline ", Gs_184, ",M", RenkoTimeFrame1, " to view chart");
   if (Use2ndRenkoChart) {
      if (G_file_172 < 0) {
         if (!IsDllsAllowed()) {
            Print("Error: Dll calls must be allowed!");
            return (-1);
         }
         if (MathAbs(RenkoBoxOffset2) >= RenkoBoxSize2) {
            Print("Error: |RenkoBoxOffset| should be less then RenkoBoxSize2!");
            return (-1);
         }
         Li_20 = RenkoBoxSize2;
         Li_24 = RenkoBoxOffset2;
         if (Digits == 5 || (Digits == 3 && StringFind(Symbol(), "JPY") != -1)) {
            Li_20 = 10 * Li_20;
            Li_24 = 10 * Li_24;
         }
         if (Digits == 6 || (Digits == 4 && StringFind(Symbol(), "JPY") != -1)) {
            Li_20 = 100 * Li_20;
            Li_24 = 100 * Li_24;
         }
         if (StrangeSymbolName) Gs_184 = StringSubstr(Symbol(), 0, 6);
         else Gs_184 = Symbol();
         Gd_300 = NormalizeDouble(Li_20 * Point, Digits);
         if (Close[Bars - 1] >= StartingPrice) Gd_324 = NormalizeDouble(Li_24 * Point + MathFloor((Close[Bars - 1] - StartingPrice) / Gd_300) * Gd_300 + StartingPrice, Digits);
         if (Close[Bars - 1] < StartingPrice) Gd_324 = NormalizeDouble(Li_24 * Point + StartingPrice - MathCeil((StartingPrice - (Close[Bars - 1])) / Gd_300) * Gd_300 - Point, Digits);
         Gd_316 = Gd_324;
         Gd_332 = Gd_324 + Gd_300;
         Gd_308 = Gd_332;
         Gd_340 = Gd_324;
         Gd_348 = Gd_332;
         Gd_356 = 1;
         Gi_396 = Time[Bars - 1];
         G_file_172 = FileOpenHistory(Gs_184 + RenkoTimeFrame2 + ".hst", FILE_BIN|FILE_WRITE);
         if (G_file_172 < 0) {
            Print("Error: can\'t create / open history file: " + ErrorDescription(GetLastError()) + ": " + Gs_184 + RenkoTimeFrame2 + ".hst");
            return (-1);
         }
         FileWriteInteger(G_file_172, 400, LONG_VALUE);
         FileWriteString(G_file_172, "", 64);
         FileWriteString(G_file_172, Gs_184, 12);
         FileWriteInteger(G_file_172, RenkoTimeFrame2, LONG_VALUE);
         FileWriteInteger(G_file_172, Digits, LONG_VALUE);
         FileWriteInteger(G_file_172, 0, LONG_VALUE);
         FileWriteInteger(G_file_172, 0, LONG_VALUE);
         FileWriteArray(G_file_172, Lia_28, 0, 13);
         Li_32 = Bars - 2;
         if (Li_32 > MaxBars2) Li_32 = MaxBars2;
         while (Li_32 >= 0) {
            Gd_356 += Volume[Li_32];
            Gd_308 = MathMax(Gd_308, High[Li_32]);
            Gd_316 = MathMin(Gd_316, Low[Li_32]);
            Li_36 = High[Li_32] + Low[Li_32] > High[Li_32 + 1] + (Low[Li_32 + 1]);
            while (!Li_36 && Low[Li_32] < Gd_324 - BoxShiftPercent2 / 100.0 * Gd_300 || CompareDoubles(Low[Li_32], Gd_324 - BoxShiftPercent2 / 100.0 * Gd_300)) {
               Gd_332 -= BoxShiftPercent2 / 100.0 * Gd_300;
               Gd_324 -= BoxShiftPercent2 / 100.0 * Gd_300;
               Gd_340 = Gd_332;
               Gd_348 = Gd_324;
               FileWriteInteger(G_file_172, Gi_396, LONG_VALUE);
               FileWriteDouble(G_file_172, Gd_340, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_324, DOUBLE_VALUE);
               if (ShowWicks2 && Gd_308 > Gd_332) FileWriteDouble(G_file_172, Gd_308, DOUBLE_VALUE);
               else FileWriteDouble(G_file_172, Gd_332, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_348, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_356, DOUBLE_VALUE);
               Gd_308 = 0;
               Gd_316 = EMPTY_VALUE;
               Gd_356 = 0;
               Gd_372 = Gd_324;
               Gd_364 = Gd_324;
               if (Gi_396 < Time[Li_32]) Gi_396 = Time[Li_32];
               else Gi_396++;
            }
            while (High[Li_32] > Gd_332 + BoxShiftPercent2 / 100.0 * Gd_300 || CompareDoubles(High[Li_32], Gd_332 + BoxShiftPercent2 / 100.0 * Gd_300)) {
               Gd_332 += BoxShiftPercent2 / 100.0 * Gd_300;
               Gd_324 += BoxShiftPercent2 / 100.0 * Gd_300;
               Gd_340 = Gd_324;
               Gd_348 = Gd_332;
               FileWriteInteger(G_file_172, Gi_396, LONG_VALUE);
               FileWriteDouble(G_file_172, Gd_340, DOUBLE_VALUE);
               if (ShowWicks2 && Gd_316 < Gd_324) FileWriteDouble(G_file_172, Gd_316, DOUBLE_VALUE);
               else FileWriteDouble(G_file_172, Gd_324, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_332, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_348, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_356, DOUBLE_VALUE);
               Gd_308 = 0;
               Gd_316 = EMPTY_VALUE;
               Gd_356 = 0;
               Gd_372 = Gd_332;
               Gd_364 = Gd_332;
               if (Gi_396 < Time[Li_32]) Gi_396 = Time[Li_32];
               else Gi_396++;
            }
            while (Li_36 && Low[Li_32] < Gd_324 - BoxShiftPercent2 / 100.0 * Gd_300 || CompareDoubles(Low[Li_32], Gd_324 - BoxShiftPercent2 / 100.0 * Gd_300)) {
               Gd_332 -= BoxShiftPercent2 / 100.0 * Gd_300;
               Gd_324 -= BoxShiftPercent2 / 100.0 * Gd_300;
               Gd_340 = Gd_332;
               Gd_348 = Gd_324;
               FileWriteInteger(G_file_172, Gi_396, LONG_VALUE);
               FileWriteDouble(G_file_172, Gd_340, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_324, DOUBLE_VALUE);
               if (ShowWicks2 && Gd_308 > Gd_332) FileWriteDouble(G_file_172, Gd_308, DOUBLE_VALUE);
               else FileWriteDouble(G_file_172, Gd_332, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_348, DOUBLE_VALUE);
               FileWriteDouble(G_file_172, Gd_356, DOUBLE_VALUE);
               Gd_308 = 0;
               Gd_316 = EMPTY_VALUE;
               Gd_356 = 0;
               Gd_372 = Gd_324;
               Gd_364 = Gd_324;
               if (Gi_396 < Time[Li_32]) Gi_396 = Time[Li_32];
               else Gi_396++;
            }
            Li_32--;
         }
         Gi_176 = FileTell(G_file_172);
         Comment("MTH Renko Chart Builder Indi Ver 01 (" + DoubleToStr(RenkoBoxSize1, 1) + ") point: Open Offline ", Gs_184, ",M", RenkoTimeFrame1, " to view chart", 
         "\n", "MTH Renko Chart Builder Indi Ver 01 (" + DoubleToStr(RenkoBoxSize2, 1) + ") point: Open Offline ", Gs_184, ",M", RenkoTimeFrame2, " to view chart");
         if (Close[0] > MathMax(Gd_348, Gd_340)) Gd_380 = MathMax(Gd_348, Gd_340);
         else {
            if (Close[0] < MathMin(Gd_348, Gd_340)) Gd_380 = MathMin(Gd_348, Gd_340);
            else Gd_380 = Close[0];
         }
         Gd_388 = Close[0];
         if (Gd_308 > Gd_332) Gd_372 = Gd_308;
         if (Gd_316 < Gd_324) Gd_364 = Gd_316;
         FileWriteInteger(G_file_172, Gi_396, LONG_VALUE);
         FileWriteDouble(G_file_172, Gd_380, DOUBLE_VALUE);
         FileWriteDouble(G_file_172, Gd_364, DOUBLE_VALUE);
         FileWriteDouble(G_file_172, Gd_372, DOUBLE_VALUE);
         FileWriteDouble(G_file_172, Gd_388, DOUBLE_VALUE);
         FileWriteDouble(G_file_172, Gd_356, DOUBLE_VALUE);
         FileFlush(G_file_172);
         f0_0();
         return (0);
      }
      Gd_308 = MathMax(Gd_308, Bid);
      Gd_316 = MathMin(Gd_316, Bid);
      Gd_356++;
      FileSeek(G_file_172, Gi_176, SEEK_SET);
      if (Bid > Gd_332 + BoxShiftPercent2 / 100.0 * Gd_300 || CompareDoubles(Bid, Gd_332 + BoxShiftPercent2 / 100.0 * Gd_300)) {
         Gd_332 += BoxShiftPercent2 / 100.0 * Gd_300;
         Gd_324 += BoxShiftPercent2 / 100.0 * Gd_300;
         Gd_340 = Gd_324;
         Gd_348 = Gd_332;
         FileWriteInteger(G_file_172, Gi_396, LONG_VALUE);
         FileWriteDouble(G_file_172, Gd_340, DOUBLE_VALUE);
         if (ShowWicks2 && Gd_316 < Gd_324) FileWriteDouble(G_file_172, Gd_316, DOUBLE_VALUE);
         else FileWriteDouble(G_file_172, Gd_324, DOUBLE_VALUE);
         FileWriteDouble(G_file_172, Gd_332, DOUBLE_VALUE);
         FileWriteDouble(G_file_172, Gd_348, DOUBLE_VALUE);
         FileWriteDouble(G_file_172, Gd_356, DOUBLE_VALUE);
         FileFlush(G_file_172);
         Gi_176 = FileTell(G_file_172);
         if (Gi_396 < TimeCurrent()) Gi_396 = TimeCurrent();
         else Gi_396++;
         Gd_356 = 0;
         Gd_372 = Gd_332;
         Gd_364 = Gd_332;
         Gd_308 = 0;
         Gd_316 = EMPTY_VALUE;
         f0_0();
      } else {
         if (Bid < Gd_324 - BoxShiftPercent2 / 100.0 * Gd_300 || CompareDoubles(Bid, Gd_324 - BoxShiftPercent2 / 100.0 * Gd_300)) {
            Gd_332 -= BoxShiftPercent2 / 100.0 * Gd_300;
            Gd_324 -= BoxShiftPercent2 / 100.0 * Gd_300;
            Gd_340 = Gd_332;
            Gd_348 = Gd_324;
            FileWriteInteger(G_file_172, Gi_396, LONG_VALUE);
            FileWriteDouble(G_file_172, Gd_340, DOUBLE_VALUE);
            FileWriteDouble(G_file_172, Gd_324, DOUBLE_VALUE);
            if (ShowWicks2 && Gd_308 > Gd_332) FileWriteDouble(G_file_172, Gd_308, DOUBLE_VALUE);
            else FileWriteDouble(G_file_172, Gd_332, DOUBLE_VALUE);
            FileWriteDouble(G_file_172, Gd_348, DOUBLE_VALUE);
            FileWriteDouble(G_file_172, Gd_356, DOUBLE_VALUE);
            FileFlush(G_file_172);
            Gi_176 = FileTell(G_file_172);
            if (Gi_396 < TimeCurrent()) Gi_396 = TimeCurrent();
            else Gi_396++;
            Gd_356 = 0;
            Gd_372 = Gd_324;
            Gd_364 = Gd_324;
            Gd_308 = 0;
            Gd_316 = EMPTY_VALUE;
            f0_0();
         } else {
            if (Bid > Gd_372) Gd_372 = Bid;
            if (Bid < Gd_364) Gd_364 = Bid;
            Gd_380 = Gd_348;
            Gd_388 = Bid;
            FileWriteInteger(G_file_172, Gi_396, LONG_VALUE);
            FileWriteDouble(G_file_172, Gd_380, DOUBLE_VALUE);
            FileWriteDouble(G_file_172, Gd_364, DOUBLE_VALUE);
            FileWriteDouble(G_file_172, Gd_372, DOUBLE_VALUE);
            FileWriteDouble(G_file_172, Gd_388, DOUBLE_VALUE);
            FileWriteDouble(G_file_172, Gd_356, DOUBLE_VALUE);
            FileFlush(G_file_172);
            f0_0();
         }
      }
      Comment("MTH Renko Chart Builder Indi Ver 01 (" + DoubleToStr(RenkoBoxSize1, 1) + ") point: Open Offline ", Gs_184, ",M", RenkoTimeFrame1, " to view chart", 
      "\n", "MTH Renko Chart Builder Indi Ver 01 (" + DoubleToStr(RenkoBoxSize2, 1) + ") point: Open Offline ", Gs_184, ",M", RenkoTimeFrame2, " to view chart");
   }
   return (0);
}
	 	  		  	  	 		 	      					    		  	  					   	  			   		 			 	 		   	 	      	   	  		 	 	 							 	 		 	 		 	    				 	   		         								
// 52D46093050F38C27267BCE42543EF60
int deinit() {
   if (G_file_160 >= 0) {
      FileClose(G_file_160);
      G_file_160 = -1;
   }
   if (G_file_172 >= 0) {
      FileClose(G_file_172);
      G_file_172 = -1;
   }
   Comment("");
   return (0);
}

Recommend