Conversion d'indicateurs vers ProBuilder
Forums › ProRealTime forum Français › Support ProBuilder › Conversion d'indicateurs vers ProBuilder
- This topic has 29 replies, 2 voices, and was last updated 7 years ago by Nicolas.
-
-
05/08/2017 at 3:27 PM #34835
Plutôt que d’ouvrir plein de topics pour la conversion d’indicateurs (comme j’ai déjà fait :o)), je préfère créer un thread ici pour centraliser les indicateurs que j’aimerais convertir sous PRT.
Merci d’avance à tous pour votre aide!
05/08/2017 at 3:29 PM #34836Du code MT4 pour un filtre Kalman de Jurik
1234567891011121314151617181920212223242526double jkalman(int index,double price,int len,int bar){double alpha = (Phase*Order)/(len + Phase*Order-1);double beta = 1 - alpha;if(jk_prevtime[index] != Time[bar]){for(int k=0;k<2*Order;k++) jk_tmp[k][index][1] = jk_tmp[k][index][0];jk_prevtime[index] = Time[bar];}if(bar==Bars-2){ArrayInitialize(jk_tmp,price);}for(k=0;k<Order;k++){int j=2*k;jk_tmp[j][index][0] = beta*jk_tmp[j][index][1] + alpha*price;jk_tmp[j+1][index][0] = beta*jk_tmp[j+1][index][1] + alpha*jk_tmp[j][index][0];price = jk_tmp[j][index][0] + Amplitude *(jk_tmp[j][index][0] - jk_tmp[j+1][index][0]);}return(price);}05/08/2017 at 3:30 PM #34837Du code MultiCharts (pareil que Tradestation) pour un Filtre Médian
12345678// MF - Median Filter by John Ehlers// Series// LenMF = Median(Series, 2 * Len + 1);RETURN MFEt un autre filtre Median d’Ehlers
12345678910111213141516171819202122232425262728293031323334353637// MMADF - Median-MA Difference Filter by John EhlersInputs:Series ( NumericSeries ),Len ( NumericSimple ),Threshold ( NumericSimple );Variables:Alpha ( 0 ),Length ( 0 ),Smooth ( 0 );Length = Len;Smooth = (Series + 2 * Series[1] + 2 * Series[2] + Series[3]) / 6;Value3 = 1;while Value3 > ThresholdbeginAlpha = 2 / (Length + 1);Value1 = Median(Smooth, Length);Value2 = Alpha * Smooth + (1 - Alpha) * Value2[1];if Value1 <> 0 thenValue3 = AbsValue(Value1 - Value2) / Value1;Length = Length - 2;end;if Length < 3 thenLength = 3;Alpha = 2 / (Length + 1);if CurrentBar < 4 thenMMADF = SerieselseMMADF = Alpha * Smooth + (1 - Alpha) * MMADF[1];05/08/2017 at 3:34 PM #34838Un autre filtre d’Ehlers!
123456789101112131415161718192021222324252627282930313233343536373839404142// DCEF - Distance Coefficient Ehlers Filter by John EhlersInputs:Series ( NumericSeries ),Len ( NumericSimple );Variables:j ( 0 ),Smooth ( 0 ),LookBack ( 0 ),Num ( 0 ),SumCoef ( 0 );Array:Coef[50](0),Distance2[50](0);Smooth = (Series + 2 * Series[1] + 2 * Series[2] + Series[3]) / 6;for j = 0 to Len - 1beginDistance2[j] = 0;for Lookback = 1 to Len-1beginDistance2[j] = Distance2[j] + (Smooth[j] - Smooth[j + Lookback]) * (Smooth[j] - Smooth[j + Lookback]);end;Coef[j] = Distance2[j];end;Num = 0;SumCoef = 0;for j = 0 to Len - 1beginNum = Num + Coef[j] * Smooth[j];SumCoef = Sumcoef + Coef[j];end;if SumCoef <> 0 thenDCEF = Num / SumCoefelseDCEF = Series;05/08/2017 at 3:35 PM #3483905/08/2017 at 3:42 PM #3484005/08/2017 at 4:41 PM #34843jkalman = Un filtre Kalman fait par Jurik. Tu peux t’en servir comme filtre sur les prix et ça te fait une moyenne mobile super réactive et lisse. C’est sûrement un des meilleurs filtres (un peu comme jsmooth).
Le filtre médian, c’est pas trop utile en tant que tel, mais c’est utilisé par d’autres filtres comme le Median-MA Difference Filter de John Ehlers. Un lien pour avoir une idée d’à quoi ça ressemble http://www.stockspotter.com/Files/whatsthedifference.pdf
Ca peut servir de filtre encore une fois, de moyenne mobile et de STOP 😉Même genre pour DCEF, https://www.mesasoftware.com/papers/EhlersFilters.pdf
05/09/2017 at 1:54 PM #34943Dans le genre sexy de chez sexy qui peut s’utiliser pour lisser des prix, des filtres Butterworth, Bessel, Critically Damped de 1 à 5 pôles :
http://unicorn.us.com/trading/src/_filter2pole.txt
A traduire de TradeStation. A mon avis ça doit être vraiment sympa 🙂
05/09/2017 at 4:03 PM #34955J’ai trouvé 2 versions du filtre Kalman sur le blog de HK-Lisse, les voici:
1234567891011///////////// Kalman Filter ///////////////////pr=medianpriceonce pred=prif barindex>0 thendk=pr-predsmooth=pred+dk*SQRT((gain/10000)*2)velo=velo+((gain/10000)*dk)pred=smooth+velokf=predendifreturn kf1234567////////////// Kalman version Ehlers ///////////////////prix=totalpriceonce kil=prixif barindex>4 thenkil=.33*(prix+.5*(prix-prix[3]))+.67*kil[1]endifreturn kil1 user thanked author for this post.
05/10/2017 at 12:11 PM #35050Quelques indicateurs du jour 😀
Double smoothed EMA
Je suppose que ça doit être une DEMA plus lisse.
12345678910111213double workDsema[][_maWorkBufferx2];#define _ema1 0#define _ema2 1double iDsema(double price, double period, int r, int instanceNo=0){if (ArraySize(workDsema)!= Bars) ArrayResize(workDsema,Bars); instanceNo*=2;double alpha = 2.0 /(1.0+MathSqrt(period));workDsema[r][_ema1+instanceNo] = workDsema[r-1][_ema1+instanceNo]+alpha*(price -workDsema[r-1][_ema1+instanceNo]);workDsema[r][_ema2+instanceNo] = workDsema[r-1][_ema2+instanceNo]+alpha*(workDsema[r][_ema1+instanceNo]-workDsema[r-1][_ema2+instanceNo]);return(workDsema[r][_ema2+instanceNo]);}Smoothed MA
Une simple MA plus lisse?
12345678910double workSmma[][_maWorkBufferx1];double iSmma(double price, double period, int r, int instanceNo=0){if (ArrayRange(workSmma,0)!= Bars) ArrayResize(workSmma,Bars);if (r<period)workSmma[r][instanceNo] = price;else workSmma[r][instanceNo] = workSmma[r-1][instanceNo]+(price-workSmma[r-1][instanceNo])/period;return(workSmma[r][instanceNo]);}Parabolic weighted MA
12345678910111213141516171819/double workLwmp[][_maWorkBufferx1];double iLwmp(double price, double period, int r, int instanceNo=0){if (ArraySize(workLwmp)!= Bars) ArrayResize(workLwmp,Bars);workLwmp[r][instanceNo] = price;double sumw = period*period;double sum = sumw*price;for(int k=1; k<period && (r-k)>=0; k++){double weight = (period-k)*(period-k);sumw += weight;sum += weight*workLwmp[r-k][instanceNo];}return(sum/sumw);}05/10/2017 at 12:19 PM #35051Une zéro lag que je ne connais pas!
1234567891011121314151617181920212223double workZl[][_maWorkBufferx2];#define _price 0#define _zlema 1double iZeroLag(double price, double length, int r, int instanceNo=0){if (ArrayRange(workZl,0)!=Bars) ArrayResize(workZl,Bars); instanceNo *= 2;//////////double alpha = 2.0/(1.0+length);int per = (length-1.0)/2.0;workZl[r][_price+instanceNo] = price;if (r<per)workZl[r][_zlema+instanceNo] = price;else workZl[r][_zlema+instanceNo] = workZl[r-1][_zlema+instanceNo]+alpha*(2.0*price-workZl[r-per][_price+instanceNo]-workZl[r-1][_zlema+instanceNo]);return(workZl[r][_zlema+instanceNo]);}05/10/2017 at 12:47 PM #35054Moyenne Mobile Leader
double workLeader[][_maWorkBufferx2];
double iLeader(double price, double period, int r, int instanceNo=0)
{
if (ArrayRange(workLeader,0)!= Bars) ArrayResize(workLeader,Bars); instanceNo*=2;period = MathMax(period,1);
double alpha = 2.0/(period+1.0);
workLeader[r][instanceNo ] = workLeader[r-1][instanceNo ]+alpha*(price -workLeader[r-1][instanceNo ]);
workLeader[r][instanceNo+1] = workLeader[r-1][instanceNo+1]+alpha*(price-workLeader[r][instanceNo]-workLeader[r-1][instanceNo+1]);return(workLeader[r][instanceNo]+workLeader[r][instanceNo+1]);
}Comment on traduirait instanceNo+instanceNo+1? C’est le temps? le prix? Une autre variable?
J’ai du mal à voir.
05/10/2017 at 1:13 PM #3505605/10/2017 at 1:33 PM #35060Smoothed Simple Moving Average
Voilà j’ai tenté la conversion 😉
123456789101112// --- parametersSeries = CustomClose// Period = 20// ---IF BarIndex < Period THENSMMA = SeriesELSESMMA = SMMA[1] + (Series - SMMA[1]) / PeriodENDIFRETURN SMMA05/10/2017 at 1:42 PM #35065Leader Exponential Moving Average
J’ai tenté la conversion 😉
1234567891011121314151617181920212223//-----------------------------------//// Leader Exponential Moving Average ////-----------------------------------//// --- parametersSeries = CustomClose// Period = 20// ---Period = MAX(Period, 1)IF BarIndex <= Period THENp1 = Seriesp2 = SeriesELSEalpha = 2 / (Period + 1)p1 = p1[1] + alpha * (Series - p1[1])p2 = p2[1] + alpha * (Series - p1 - p2[1])ENDIFLEMA = p1 + p2RETURN LEMA -
AuthorPosts
Find exclusive trading pro-tools on