/--------------------------------------------------------// // 1224-kkTrendLines Breaker-1H //--------------------------------------------------------// DEFPARAM CUMULATEORDERS = False DEFPARAM PRELOADBARS = 1000 //////////////////// //Strategia: To do: until I hit TakeProfit if BUY, I close when Hyper turns red and reopen when it turns green /////// If I have reached Stop Loss I stop //--------------------------------------------------------// ExitTrailingStop=0 // Exit in Traling Stop EntrateHyperTrig=0 /// Green and yellow arrow entries Hyper Trig (crosses over avg in trend green) TooLateToEnter=1 // Too far from last change of HyperTrend TooLateToEnterMaxBar=60 /// 60 How many bar too far? Max Bar SeguiTPconHyper=1 // If change color of Trend Hyper close the position EntrataHyper=1 // Entry filter versus hyper trend by default UscitaHyper=1 /// and I go against Hyper timeframedefault and close EntrataHyperHTF=0 /// to do Filter with respect to Hyper High Time Frame, but within the same BUY if they are close to the lower ///////and SELL if they are close to upper CifraDaInvestire=1000 MinVol=50 takeProf=CifraDaInvestire/1.1 /// 1.1 SwingContrarioChiudoDaQuestoGain=CifraDaInvestire/2 ////////SET TARGET PROFIT takeProf volLastCand=volume[1] numc=round((CifraDaInvestire*20/close)*100)/100 //// 0224-kkHyperTrend--1Day timeframe(1 Day) // 1 hour 30 minute mult30m=5 slope30m=14 width30m=80 once avg30m = close once hold30m = 0 once os30m = 1 once rR30m = 220 once gR30m = 20 once bR30m = 60 once rV30m = 60 once gV30m = 179 once bV30m = 113 if barindex > 200 then atr30m = AverageTrueRange[200] * mult30m If abs(close - avg30m) > atr30m then avg30m = (close+avg30m)/2 //avg30m = avg30mN else avg30m = avg30m + os30m*(hold30m/mult30m/slope30m) //avg30m = avg30mN endif os30m = sgn(avg30m - avg30m[1]) If os30m <> os30m[1] then hold30m = atr30m else hold30m = hold30m[1] endif upper30m = avg30m + width30m*hold30m/100 lower30m = avg30m - width30m*hold30m/100 If os30m = 1 then r30m = rV30m g30m = gV30m b30m = bV30m TrendHypeColorDay=1 else r30m = rR30m g30m = gR30m b30m = bR30m TrendHypeColorDay=-1 endif If os30m = 1 then r30mA = 0 g30mA = 255 b30mA = 0 else r30mA = 255 g30mA = 0 b30mA = 0 endif endif LimituppavgDay=(avg30m+upper30m)/2 LimitDownavgDay=(avg30m+lower30m)/2 timeframe(default,updateonclose) //--------------------------------------------------------// // *** POSITION SIZE *** // //--------------------------------------------------------// // Capital to invest ONCE CapitalToInvest = 10000 // Minimum number of contracts ONCE NumberOfContractsMin = 1 // Position Size NumberOfContracts = MAX(ROUND(CapitalToInvest / Close, 2), NumberOfContractsMin) //--------------------------------------------------------// // *** SETTING BLOCK *** // //--------------------------------------------------------// // Type of lines ONCE FallingLines = 1 ONCE RisingLines =1 // Length ONCE LineLength = 5 ONCE LineExtension = 15 // Signals ONCE breakout = 1 ONCE ValidatedBreakout = 0 ONCE Retest = 0 ONCE ValidatedRetest = 0 // Trend filters ONCE intheTrend = 0 ONCE Reversal = 0 // Strength filters ONCE withVolumes = 0 ONCE withDivergence = 0 // Take profit ONCE TakeProfit = 1 ONCE TPLevel = 2 // Stop-loss ONCE StopLoss = 1 ONCE SLLevel = 1 // Display options ONCE FallingColor = 0 ONCE RisingColor = 0 ONCE LineThickness = 0 ONCE FontSize = 0 // Starting year ONCE StartingYear = 2010 //////////////////////////////////////////////////// ////////////////////////////////////////////////////// 1124-kkHyperTrend-SuppDem-Trig ////// mult=5 slope=14 width=80 once avg = close once hold = 0 once TrendHyperos1m = 1 once rR = 220 once gR = 20 once bR = 60 once rV = 60 once gV = 179 once bV = 113 if barindex > 200 then atr = AverageTrueRange[200] * mult If abs(close - avg) > atr then avg = (close+avg)/2 //avg = avgN else avg = avg + TrendHyperos1m*(hold/mult/slope) //avg = avgN endif TrendHyperos1m = sgn(avg - avg[1]) If TrendHyperos1m <> TrendHyperos1m[1] then hold = atr else hold = hold[1] endif upper = avg + width*hold/100 lower = avg - width*hold/100 If TrendHyperos1m = 1 then r = rV g = gV b = bV TrendHypeColor=1 else r = rR g = gR b = bR TrendHypeColor=-1 endif if TrendHyperos1m<>TrendHyperos1m[1] THEN avcandleH=(high-low) upperprec=upper[1] lowerprec=lower[1] SearchUp=0 SearchDn=0 CambioTrendHyperBar=BarIndex CambioTrendHyperVal=close SignalHyper=0 If TrendHyperos1m = 1 THEN ///drawarrowUp(barindex,close-avcandleH) coloured("blue") SignalHyper=1 ELSE ////drawarrowdown(barindex,close+avcandleH) coloured("magenta") SignalHyper=-1 endif endif ///////////// endif //////////////////////////////////////// if SearchUp=0 and TrendHypeColor=1 and avg crosses over upperprec THEN SearchUp=1 endif if SearchDn=0 and TrendHypeColor=-1 and avg crosses under lowerprec THEN SearchDn=1 endif SignalHyperBounce=0 if SearchUp=1 and close crosses over avg THEN //////drawarrowUp(barindex,close-avcandleH) coloured("green") SignalHyperBounce=1 SearchUp=0 endif if SearchDn=1 and close crosses under avg THEN /////drawarrowDown(barindex,close+avcandleH) coloured("yellow") SignalHyperBounce=-1 SearchDn=0 endif ///////Return upper as "upper" COLOURED(rR,gR,bR,100)style(line,1),lower as "lower" COLOURED(rV,gV,bV,100)style(line,1), upperprec as "upperprec", lowerprec as "lowerprec",avg as "avg" COLOURED(r,g,b,255)style(line,1) ////////////////////////////////////////////// /// myBreakout, myTakeProfit, myStopLoss = CALL "TrendLines Breaker(1)"[FallingLines, RisingLines, LineLength, LineExtension, breakout, ValidatedBreakout, Retest, ValidatedRetest, intheTrend, Reversal, withVolumes, withDivergence, TakeProfit, TPLevel, StopLoss, SLLevel, FallingColor, RisingColor, LineThickness, FontSize, StartingYear](close) // Conditions pour ouvrir une position acheteuse entrBuy=myBreakout entrSell=myBreakout /////////////////////////////////// if EntrateHyperTrig=1 then if entrBuy=0 and entrSell=0 and SignalHyperBounce=1 THEN entrBuy=1 endif if entrBuy=0 and entrSell=0 and SignalHyperBounce=-1 THEN entrSell=1 endif endif Entrato=0 //// if TrendHypeColorDay=1 and closeLimitDownavgDay THEN entrBuy=0 endif if EntrataHyper=0 THEN CheckTrendHypeColorBUY=1 CheckTrendHypeColorSELL=-1 ELSE CheckTrendHypeColorBUY=TrendHypeColor CheckTrendHypeColorSELL=-TrendHypeColor endif ///////////////////////////// if TooLateToEnter=1 then if TrendHyperos1m=1 and barindex-CambioTrendHyperBar >TooLateToEnterMaxBar THEN entrBuy=0 endif if TrendHyperos1m=-1 and barindex-CambioTrendHyperBar >TooLateToEnterMaxBar THEN entrSell =0 endif endif ///////////////////////////////////////// IF NOT LongOnMarket AND entrBuy=1 and CheckTrendHypeColorBUY=1 THEN // Target price ///Set Target Price myTakeProfit myTakeProfitBUY=myTakeProfit // Stop-Loss price Set Stop Price myStopLoss myStopLossBUY=myStopLoss // Buying order BUY numc CONTRACTS AT MARKET LastSignal=1 Entrato=1 ENDIF /////////////////////////////// // Conditions pour ouvrir une position en vente à découvert IF NOT ShortOnMarket AND entrSell = -1 and CheckTrendHypeColorSELL=-1 THEN // Target price ///Set Target Price myTakeProfit myTakeProfitSELL=myTakeProfit // Stop-Loss price Set Stop Price myStopLoss myStopLossSELL=myStopLoss // Buying order SELLSHORT numc CONTRACTS AT MARKET LastSignal=-1 Entrato=1 ENDIF /////////////////////////////////////////////// USCITE if UscitaHyper=1 then if ShortOnMarket and SignalHyper=1 and TrendHypeColorDay=1 and closeavg30m THEN SELL AT MARKET endif endif //////////////////////////// if SeguiTPconHyper=1 THEN //Strategy: To do until I reach TakeProfit if BUY, I close when Hyper turns red and reopen when it turns green /////// If I have reached Stop Loss I stop if LastSignal=1 then if LongOnMarket and SignalHyper=-1 THEN SELL AT MARKET endif if not LongOnMarket and SignalHyper=1 and SignalHyper[1]=-1 and closeLimitDownavgDay THEN /// Entrato=0 and SELLSHORT NumberOfContracts CONTRACTS AT MARKET endif endif endif ///////////////////////////////////////////////////// if ExitTrailingStop=1 then /////RETURN TrendLine coloured(r,g,0) style(line,2) as "BBands stop Trend" PriceDistance = 7 * pipsize //7 minimun distance from current price Moltav=1 SellPrice=avg-Moltav*avcandleH ExitPrice=avg+Moltav*avcandleH //SellPrice=TMA30 ///ExitPrice=TMA30+10 if LongOnMarket then IF abs(close - SellPrice) > PriceDistance THEN // // place either a LIMIT or STOP pending order according to current price positioning // if close>avg then IF close >= SellPrice THEN SELL AT SellPrice STOP ELSE SELL AT SellPrice LIMIT ENDIF endif ELSE // //sell AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price // ///SELL AT Market ENDIF endif if ShortOnMarket then // IF abs(close - ExitPrice) > PriceDistance THEN // // place either a LIMIT or STOP pending order according to current price positioning if close