Traducir de mq4 a PRT:"Quantile based signed volume analysis"
Forums › ProRealTime foro Español › Soporte ProBuilder › Traducir de mq4 a PRT:"Quantile based signed volume analysis"
- This topic has 7 replies, 2 voices, and was last updated 4 years ago by Nicolas.
Viewing 8 posts - 1 through 8 (of 8 total)
-
-
11/15/2019 at 11:53 PM #112904
Hola Nicolás,
A ver si es tan amable de traducir este código de mq4 a PRT.
Se basa en el indicador ATR y el volumen.
Creo que sería un indicador de gran utilidad.
Un saludo y gracias.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177//+------------------------------------------------------------------+//| Quantile based signed volume analysis |//+------------------------------------------------------------------+#property copyright#property link#property indicator_separate_window#property indicator_buffers 2#property indicator_color1 DeepSkyBlue#property indicator_color2 PaleVioletRed#property indicator_width1 2#property indicator_width2 2//////////extern int Periods = 20;extern ENUM_APPLIED_PRICE Price = PRICE_CLOSE;extern double UpQuantilePercent = 90;extern double DownQuantilePercent = 10;extern double AtrUpperPercent = 75;extern double AtrLowerPercent = 25;extern bool LimitToZeroes = true;extern bool UseRealVolume = false;//////////double bufferUp[];double bufferDn[];double quantUp[];double quantDn[];double prices[];double trend[];//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+//////////int init(){IndicatorBuffers(6);SetIndexBuffer(0,bufferUp); SetIndexStyle(0,DRAW_HISTOGRAM);SetIndexBuffer(1,bufferDn); SetIndexStyle(1,DRAW_HISTOGRAM);SetIndexBuffer(2,quantUp);SetIndexBuffer(3,quantDn);SetIndexBuffer(4,prices);//////////Periods = MathMax(Periods,1);UpQuantilePercent = MathMax(MathMin(UpQuantilePercent,100),0);DownQuantilePercent = MathMax(MathMin(DownQuantilePercent,100),0);IndicatorShortName("Quantile based signed volume analysis 1 ("+Periods+","+DoubleToStr(UpQuantilePercent,2)+","+DoubleToStr(DownQuantilePercent,2)+")");return(0);}int deinit() { return(0); }//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+//////////int OnCalculate (const int rates_total, // size of input time seriesconst int prev_calculated, // bars handled in previous callconst datetime& time[], // Timeconst double& open[], // Openconst double& high[], // Highconst double& low[], // Lowconst double& close[], // Closeconst long& tick_volume[], // Tick Volumeconst long& volume[], // Real Volumeconst int& spread[] // Spread){int counted_bars=IndicatorCounted();int i,limit;if(counted_bars<0) return(-1);if(counted_bars>0) counted_bars--;limit=MathMin(Bars-counted_bars,Bars-1);//////////for(i=limit; i>=0; i--){prices[i] = iMA(NULL,0,1,0,MODE_SMA,Price,i);quantUp[i] = iQuantile(Periods,UpQuantilePercent ,i);quantDn[i] = iQuantile(Periods,DownQuantilePercent,i);//////////bufferUp[i] = 0;bufferDn[i] = 0;for (int k=0; k<Periods; k++){double atr = iATR(NULL,0,1,i+k);double sign = 0;if (prices[i+k] > Low[i+k]+atr*AtrUpperPercent/100.0 && prices[i+k]>prices[i+k+1]) sign = 1;if (prices[i+k] < Low[i+k]+atr*AtrLowerPercent/100.0 && prices[i+k]<prices[i+k+1]) sign = -1;if (!UseRealVolume){if (prices[i+k] > quantUp[i+k]) bufferUp[i]+= sign*tick_volume[i+k]*prices[i+k]*atr;if (prices[i+k] < quantDn[i+k]) bufferDn[i]+= sign*tick_volume[i+k]*prices[i+k]*atr;}else{if (prices[i+k] > quantUp[i+k]) bufferUp[i]+= sign*volume[i+k]*prices[i+k]*atr;if (prices[i+k] < quantDn[i+k]) bufferDn[i]+= sign*volume[i+k]*prices[i+k]*atr;}}if (LimitToZeroes){bufferUp[i] = MathMax(bufferUp[i],0);bufferDn[i] = MathMin(bufferDn[i],0);}}return(0);}//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+//////////double quantileArray[];double iQuantile(int period, double qp, int i){if (ArraySize(quantileArray)!=period) ArrayResize(quantileArray,period);for(int k=0; k<period && (i+k)<Bars; k++) quantileArray[k] = prices[i+k];ArraySort(quantileArray);//////////double index = (period-1)*qp/100.00;int ind = index;double delta = index - ind;if (ind == NormalizeDouble(index,5))return( quantileArray[ind]);else return((1.0-delta)*quantileArray[ind]+delta*quantileArray[ind+1]);}11/16/2019 at 6:12 PM #11293811/21/2019 at 2:35 PM #11332112/07/2019 at 5:23 PM #11438402/05/2020 at 11:36 AM #11871502/05/2020 at 12:54 PM #118726En realidad, hay 2 limitaciones principales que podrían resolverse con PRT v11:
- un cálculo más fácil se haría con el soporte de matrices de variables
- tick_volume que no conocemos con códigos pero que posiblemente podría calcularse aproximadamente en gráficos de ticks y con el nuevo soporte de matrices con la versión 11 (tenga en cuenta que no pudimos obtener el historial y solo en la vela actual)
08/31/2020 at 8:59 PM #14309809/01/2020 at 8:47 AM #143113Sí, pero el problema principal es la clasificación de matrices, que no es posible fácilmente. En los próximos meses se agregarán muchas instrucciones nuevas a ProBuilder, y con una funcionalidad ArraySort.
1 user thanked author for this post.
-
AuthorPosts
Viewing 8 posts - 1 through 8 (of 8 total)
Find exclusive trading pro-tools on
Similar topics: