Différence : visu graphique // prise de position auto
Forums › ProRealTime forum Français › Support ProOrder › Différence : visu graphique // prise de position auto
- This topic has 0 replies, 1 voice, and was last updated 1 year ago by NathanC.
-
-
04/02/2023 at 2:34 PM #212663
Bonjour, j’ai plusieurs code d’indicateurs que je display pour vérifier les prises de positions avec l’automatique.
Et j’ai des problèmes ca ne prend pas les positions aux bons endroits (je réintègre le code de mes indicateurs dans mon code de trade)Indicateur 1
12345678910111213141516171819202122232425262728293031323334353637// Humble LinReg Candles// InputsSignalSmoothing = 7SimpleMASignalLine = 1 // Set to 1 for True, 0 for FalseLinReg = 1 // Set to 1 for True, 0 for FalseLinearRegressionLength = 11// Calculate Linear Regression valuesIF LinReg THENbOpen = LinearRegression[LinearRegressionLength](open)bHigh = LinearRegression[LinearRegressionLength](high)bLow = LinearRegression[LinearRegressionLength](low)bClose = LinearRegression[LinearRegressionLength](close)ELSEbOpen = openbHigh = highbLow = lowbClose = closeENDIF// Calculate SignalIF SimpleMASignalLine THENsignal = Average[SignalSmoothing](bClose)ELSEsignal = ExponentialAverage[SignalSmoothing](bClose)ENDIF// Plot candlesr = bOpen < bCloseIF r THENDRAWCANDLE(bOpen, bHigh, bLow, bClose) COLOURED ("green")ELSEDRAWCANDLE(bOpen, bHigh, bLow, bClose) COLOURED ("red")ENDIFRETURN signalIndicateur 2 :
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657// UT Bot Alerts// InputsKeyVaule = 2ATRPeriod = 11UseHeikinAshi = 0// Calculate ATRxATR = AverageTrueRange[ATRPeriod]// Calculate nLossnLoss = KeyVaule * xATR// Use Heikin Ashi Candles if enabledIF UseHeikinAshi = 1 THENsrc = Close //HeikinAshiELSEsrc = CloseENDIF// Calculate xATRTrailingStopxATRTrailingStop = 0IF src > xATRTrailingStop[1] AND src[1] > xATRTrailingStop[1] THENxATRTrailingStop = Max(xATRTrailingStop[1], src - nLoss)ELSIF src < xATRTrailingStop[1] AND src[1] < xATRTrailingStop[1] THENxATRTrailingStop = Min(xATRTrailingStop[1], src + nLoss)ELSIF src > xATRTrailingStop[1] THENxATRTrailingStop = src - nLossELSExATRTrailingStop = src + nLossENDIF// Calculate positionpos = 0IF src[1] < xATRTrailingStop[1] AND src > xATRTrailingStop[1] THENpos = 1ELSIF src[1] > xATRTrailingStop[1] AND src < xATRTrailingStop[1] THENpos = -1ELSEpos = pos[1]ENDIF// EMA Calculationema = ExponentialAverage[1](src)// Buy and Sell Conditionsabove = ema > xATRTrailingStop AND ema[1] <= xATRTrailingStop[1]below = ema < xATRTrailingStop AND ema[1] >= xATRTrailingStop[1]// Draw ArrowsIF src > xATRTrailingStop AND above THENDRAWARROWUP(barindex, src - xATR) COLOURED (255, 255, 0)endifIF src < xATRTrailingStop AND below THENDRAWARROWDOWN(barindex, src + xATR) COLOURED (127, 0,255)endifreturnIndicateur 3
1234567891011121314151617181920212223242526272829303132333435363738394041//input parametersTCLen = 12MA1 = 26MA2 = 50Once Factor = 0.5if barindex>MA2 then//{Calculate a MACD Line}XMAC = ExponentialAverage[MA1](Close) - ExponentialAverage[MA2](Close)//{1st Stochastic: Calculate Stochastic of a MACD}Value1 = Lowest[TCLen](XMAC)Value2 = Highest[TCLen](XMAC) - Value1//{%Fast K of MACD}if Value2 > 0 thenFrac1 = ((XMAC - Value1)/Value2) * 100elseFrac1 = Frac1[1]endif//{Smoothed Calculation for % Fast D of MACD}PF = PF[1] + (Factor * (Frac1 - PF[1]))//{2nd Stochastic: DCalculate Stochastic of smoothed Percent Fast D, 'PF', above}Value3 = Lowest[TCLen](PF)Value4 = Highest[TCLen](PF) - Value3//{% of Fast K of PF}if Value4 > 0 thenFrac2 = ((PF - Value3)/Value4) * 100elseFrac2 = Frac2[1]endif//{Smoothed Calculation for %Fast D of PF}PFF = PFF[1] + (Factor * (Frac2 - PFF[1]))endifRETURN PFF, 75 coloured(0,0,255) as "level 75", 25 coloured(0,0,255) as "level 25"Code du trading automatique:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156//https://www.youtube.com/watch?v=dgALZfsFhow// Humble LinReg Candles// InputsSignalSmoothing = 7SimpleMASignalLine = 1 // Set to 1 for True, 0 for FalseLinReg = 1 // Set to 1 for True, 0 for FalseLinearRegressionLength = 11// Calculate Linear Regression valuesIF LinReg THENbOpen = LinearRegression[LinearRegressionLength](open)bHigh = LinearRegression[LinearRegressionLength](high)bLow = LinearRegression[LinearRegressionLength](low)bClose = LinearRegression[LinearRegressionLength](close)ELSEbOpen = openbHigh = highbLow = lowbClose = closeENDIF// Calculate SignalIF SimpleMASignalLine THENsignal = Average[SignalSmoothing](bClose)ELSEsignal = ExponentialAverage[SignalSmoothing](bClose)ENDIF// Plot candlesr = bOpen < bClose//STC better MACD//input parametersTCLen = 12MA1 = 26MA2 = 50Once Factor = 0.5if barindex>MA2 then//{Calculate a MACD Line}XMAC = ExponentialAverage[MA1](Close) - ExponentialAverage[MA2](Close)//{1st Stochastic: Calculate Stochastic of a MACD}Value1 = Lowest[TCLen](XMAC)Value2 = Highest[TCLen](XMAC) - Value1//{%Fast K of MACD}if Value2 > 0 thenFrac1 = ((XMAC - Value1)/Value2) * 100elseFrac1 = Frac1[1]endif//{Smoothed Calculation for % Fast D of MACD}PF = PF[1] + (Factor * (Frac1 - PF[1]))//{2nd Stochastic: DCalculate Stochastic of smoothed Percent Fast D, 'PF', above}Value3 = Lowest[TCLen](PF)Value4 = Highest[TCLen](PF) - Value3//{% of Fast K of PF}if Value4 > 0 thenFrac2 = ((PF - Value3)/Value4) * 100elseFrac2 = Frac2[1]endif//{Smoothed Calculation for %Fast D of PF}PFF = PFF[1] + (Factor * (Frac2 - PFF[1]))endifSTCRising = PFF => PFF[1]STCFalling = PFF =< PFF[1]// UT Bot Alerts// InputsKeyVaule = 2ATRPeriod = 11UseHeikinAshi = 0// Calculate ATRxATR = AverageTrueRange[ATRPeriod](bOpen)// Calculate nLossnLoss = KeyVaule * xATR// Use Heikin Ashi Candles if enabledIF UseHeikinAshi = 1 THENsrc = bClose //HeikinAshiELSEsrc = bCloseENDIF// Calculate xATRTrailingStopxATRTrailingStop = 0IF src > xATRTrailingStop[1] AND src[1] > xATRTrailingStop[1] THENxATRTrailingStop = Max(xATRTrailingStop[1], src - nLoss)ELSIF src < xATRTrailingStop[1] AND src[1] < xATRTrailingStop[1] THENxATRTrailingStop = Min(xATRTrailingStop[1], src + nLoss)ELSIF src > xATRTrailingStop[1] THENxATRTrailingStop = src - nLossELSExATRTrailingStop = src + nLossENDIF// Calculate positionpos = 0IF src[1] < xATRTrailingStop[1] AND src > xATRTrailingStop[1] THENpos = 1ELSIF src[1] > xATRTrailingStop[1] AND src < xATRTrailingStop[1] THENpos = -1ELSEpos = pos[1]ENDIF// EMA Calculationema = ExponentialAverage[1](src)// Buy and Sell Conditionsabove = ema > xATRTrailingStop AND ema[1] <= xATRTrailingStop[1]below = ema < xATRTrailingStop AND ema[1] >= xATRTrailingStop[1]// Draw Arrows//IF src > xATRTrailingStop AND above THEN//DRAWARROWUP(barindex, src - xATR) COLOURED (0, 255, 0)//endif//IF src < xATRTrailingStop AND below THEN//DRAWARROWDOWN(barindex, src + xATR) COLOURED (255, 0, 0)// Conditions d'achatBuyCondition1 = src > xATRTrailingStop AND above // UT bot alerts draw arrow upBuyCondition2 = bClose > signal AND bClose > bOpen// Green linear candle close above the white lineBuyCondition3 = STCRising// STC is green (rising)// Conditions de venteSellCondition1 = src < xATRTrailingStop AND below // UT bot alerts draw arrow downSellCondition2 = bClose < signal AND bClose < bOpen// Red linear candle close below the white lineSellCondition3 = STCFalling// STC is red (falling)IF BuyCondition1 AND BuyCondition2 AND BuyCondition3 THENBUY 1 SHARES AT MARKETSET STOP LOSS signal - xATREndifIF SellCondition1 AND SellCondition2 AND SellCondition3 THENSELLSHORT 1 SHARES AT MARKETSET STOP LOSS signal + xATRendifIF longonmarket AND bOpen > bClose THENsell at marketENDIFIF shortonmarket AND bOpen < bClose THENEXITSHORT AT MARKETENDIFDans ma viz j’enlève les bougie classique, j’ai donc mes bougies linreg + ema, sur lequel j’applique l’indicateur UT bot.
Quand je compare avec les prises de positions il y’en a 70 % sur les bon signaux et d’autres sont soit “inventés” soit décalés de 3-4 unités.
J’ai creusé longtemps et changé sur l’xATR par bOpen, car c’est ce qui faisait correspondre le plus (bClose ou close en invente d’autant plus)
Un détails doit m’échapper :/
-
AuthorPosts