Fractals – Trend Lines.Convertir de MQ4 a PRT
Forums › ProRealTime foro Español › Soporte ProBuilder › Fractals – Trend Lines.Convertir de MQ4 a PRT
- This topic has 2 replies, 2 voices, and was last updated 6 years ago by Nicolas.
Viewing 3 posts - 1 through 3 (of 3 total)
-
-
11/27/2017 at 12:23 AM #54054
Hola Nicolás,a ver si puede pasar este indicador a PRT. Creo que es un indicador muy interesante,dibuja líneas de tendencia basadas en fractales. Gracias.
Fractals - Trend Lines123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230//+------------------------------------------------------------------+//| Fractals - adjustable period |//+------------------------------------------------------------------+#property link#property copyright#property indicator_chart_window#property indicator_buffers 2#property indicator_color1 DeepSkyBlue#property indicator_color2 PaleVioletRed#property indicator_width1 2#property indicator_width2 2//////////extern string TimeFrame = "Current time frame";extern int FractalPeriod = 25;extern double UpperArrowDisplacement = 0.2;extern double LowerArrowDisplacement = 0.2;extern color UpperCompletedColor = DeepSkyBlue;extern color UpperUnCompletedColor = Aqua;extern color LowerCompletedColor = PaleVioletRed;extern color LowerUnCompletedColor = HotPink;extern int CompletedWidth = 2;extern int UnCompletedWidth = 1;extern string UniqueID = "FractalTrendLines1";double UpperBuffer[];double LowerBuffer[];string indicatorFileName;int timeFrame;bool returnBars;//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+//////////int init(){if (MathMod(FractalPeriod,2)==0)FractalPeriod = FractalPeriod+1;SetIndexBuffer(0,UpperBuffer); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,159);SetIndexBuffer(1,LowerBuffer); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,159);indicatorFileName = WindowExpertName();returnBars = TimeFrame=="returnBars"; if (returnBars) { return(0); }timeFrame = stringToTimeFrame(TimeFrame);return(0);}int deinit(){ObjectDelete(UniqueID+"up1");ObjectDelete(UniqueID+"up2");ObjectDelete(UniqueID+"dn1");ObjectDelete(UniqueID+"dn2");return(0);}//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+//////////int start(){int half = FractalPeriod/2;int i,limit,counted_bars=IndicatorCounted();if(counted_bars<0) return(-1);if(counted_bars>0) counted_bars--;limit=MathMin(MathMax(Bars-counted_bars,FractalPeriod),Bars-1);if (returnBars) { UpperBuffer[0] = MathMin(limit+1,Bars-1); return(0); }if (timeFrame!=Period()){limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));for (i=limit; i>=0; i--){int y = iBarShift(NULL,timeFrame,Time[i]);int x = iBarShift(NULL,timeFrame,Time[i+1]);UpperBuffer[i] = EMPTY_VALUE;LowerBuffer[i] = EMPTY_VALUE;if (x!=y){UpperBuffer[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",FractalPeriod,UpperArrowDisplacement,LowerArrowDisplacement,UpperCompletedColor,UpperUnCompletedColor,LowerCompletedColor,LowerUnCompletedColor,CompletedWidth,UnCompletedWidth,UniqueID,0,y);LowerBuffer[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",FractalPeriod,UpperArrowDisplacement,LowerArrowDisplacement,UpperCompletedColor,UpperUnCompletedColor,LowerCompletedColor,LowerUnCompletedColor,CompletedWidth,UnCompletedWidth,UniqueID,1,y);}}return(0);}//////////for(i=limit; i>=0; i--){bool found = true;double compareTo = High[i];for (int k=1;k<=half;k++){if ((i+k)<Bars && High[i+k]> compareTo) { found=false; break; }if ((i-k)>=0 && High[i-k]>=compareTo) { found=false; break; }}if (found)UpperBuffer[i]=High[i]+iATR(NULL,0,20,i)*UpperArrowDisplacement;else UpperBuffer[i]=EMPTY_VALUE;//////////found = true;compareTo = Low[i];for (k=1;k<=half;k++){if ((i+k)<Bars && Low[i+k]< compareTo) { found=false; break; }if ((i-k)>=0 && Low[i-k]<=compareTo) { found=false; break; }}if (found)LowerBuffer[i]=Low[i]-iATR(NULL,0,20,i)*LowerArrowDisplacement;else LowerBuffer[i]=EMPTY_VALUE;}//////////int lastUp[3];int lastDn[3];int dnInd = -1;int upInd = -1;for (i=0; i<Bars; i++){if (upInd<2 && UpperBuffer[i] != EMPTY_VALUE) { upInd++; lastUp[upInd] = i; }if (dnInd<2 && LowerBuffer[i] != EMPTY_VALUE) { dnInd++; lastDn[dnInd] = i; }if (upInd==2 && dnInd==2) break;}createLine("up1",High[lastUp[1]],Time[lastUp[1]],High[lastUp[0]],Time[lastUp[0]],UpperUnCompletedColor,UnCompletedWidth);createLine("up2",High[lastUp[2]],Time[lastUp[2]],High[lastUp[1]],Time[lastUp[1]],UpperCompletedColor,CompletedWidth);createLine("dn1",Low[lastDn[1]] ,Time[lastDn[1]],Low[lastDn[0]] ,Time[lastDn[0]],LowerUnCompletedColor,UnCompletedWidth);createLine("dn2",Low[lastDn[2]] ,Time[lastDn[2]],Low[lastDn[1]] ,Time[lastDn[1]],LowerCompletedColor,CompletedWidth);return(0);}//////////void createLine(string add, double price1, datetime time1, double price2, datetime time2, color theColor, int width){string name = UniqueID+add;ObjectDelete(name);ObjectCreate(name,OBJ_TREND,0,time1,price1,time2,price2);ObjectSet(name,OBJPROP_COLOR,theColor);ObjectSet(name,OBJPROP_WIDTH,width);}//-------------------------------------------------------------------////-------------------------------------------------------------------//////////string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};//////////int stringToTimeFrame(string tfs){tfs = stringUpperCase(tfs);for (int i=ArraySize(iTfTable)-1; i>=0; i--)if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(MathMax(iTfTable[i],Period()));return(Period());}string timeFrameToString(int tf){for (int i=ArraySize(iTfTable)-1; i>=0; i--)if (tf==iTfTable[i]) return(sTfTable[i]);return("");}//////////string stringUpperCase(string str){string s = str;for (int length=StringLen(str)-1; length>=0; length--){int tchar = StringGetChar(s, length);if((tchar > 96 && tchar < 123) || (tchar > 223 && tchar < 256))s = StringSetChar(s, length, tchar - 32);else if(tchar > -33 && tchar < 0)s = StringSetChar(s, length, tchar + 224);}return(s);}11/27/2017 at 12:27 AM #5405511/28/2017 at 9:24 AM #54224Muy similar a este indicador https://www.prorealcode.com/topic/trendline-une-approche-du-trading/#post-12704
Por favor, avíseme si es suficiente reemplazar este (no creo que obtengamos un resultado diferente del hecho de que este MT4 trama dos conjuntos de tendencias, 1 con el período y otro con el medio punto, así que en este caso, ¡solo tiene que agregar el indicador que hice con diferentes períodos!) -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)