![Citazione](themecrate/debutant/misc/quote_icon.png)
Originariamente Scritto da
CIVT
Grazie Denis! Vedo che sei sempre sul pezzo!
Incollo anche il codice per chi vuole discutere eventuali modifiche
BUY SCRIPT
# REQUIRED_BARS is used to adjust how many periods will be used to initialize calculations. Default value is 50 periods.
# Un-comment and edit the line below to set your own value.
# SET REQUIRED_BARS = 50
INPUTS: @price(CLOSE), @fastPeriods(100), @slowPeriods(350), @matype(SIMPLE), @exitTemp(2500), @Amp(28), @entryBars(9)
INPUTS: @MaxStd(30), @LRSignalExit(600), @LRexitBars(10) @SlopeEntryPeriod(100), @SlopeExitPeriod(600), @STDperiods(60)
INPUTS: @STOP(600), @TAKE(200)
SET STOP_LOSS = @STOP
SET TAKE_PROFIT = @TAKE
SET REQUIRED_BARS = 600
SET fast = MovingAverage(@price, @fastPeriods, @matype)
SET slow = MovingAverage(@price, @slowPeriods, @matype)
SET STD = StandardDeviations(@price, @STDperiods, 1, @matype)
SET StdMod = IF(STD > @MaxStd, 10, STD)
SET TodayUP = TODAYOPEN() + @Amp + StdMod
SET TodayDown = TODAYOPEN() - @Amp - StdMod
SET LrSlope = LinearRegressionSlope(CLOSE, @SlopeEntryPeriod)
SET SlopeExit = LinearRegressionSlope(CLOSE, @SlopeExitPeriod)
SET CrossUP = CROSSOVER(CLOSE, TodayUP)
SET ContCrossUP = LASTIF(CrossUP)
SET BUY = ContCrossUP = @entryBars AND CLOSE > TodayUP AND fast > slow AND REF(LrSlope, 1) < LrSlope
# AND TIME > 200 AND TIME < 1030
BUY
SELL SCRIPT
SET fast = MovingAverage(@price, @fastPeriods, @matype)
SET slow = MovingAverage(@price, @slowPeriods, @matype)
SET STD = StandardDeviations(@price, @STDperiods, 1, @matype)
SET StdMod = IF(STD > @MaxStd, 10, STD)
SET TodayUP = TODAYOPEN() + @Amp + StdMod
SET TodayDown = TODAYOPEN() - @Amp - StdMod
SET LrSlope = LinearRegressionSlope(CLOSE, @SlopeEntryPeriod)
SET SlopeExit = LinearRegressionSlope(CLOSE, @SlopeExitPeriod)
SET CrossDown = CROSSOVER(TodayDown, CLOSE)
SET ContCrossDown = LASTIF(CrossDown)
SET SELL = ContCrossDown = @entryBars AND CLOSE < TodayDown AND slow > fast AND REF(LrSlope, 1) > LrSlope
# AND TIME > 200 AND TIME < 1030
SELL
EXIT BUY
SET fast = MovingAverage(@price, @fastPeriods, @matype)
SET slow = MovingAverage(@price, @slowPeriods, @matype)
SET STD = StandardDeviations(@price, @STDperiods, 1, @matype)
SET StdMod = IF(STD > @MaxStd, 10, STD)
SET TodayUP = TODAYOPEN() + @Amp + StdMod
SET TodayDown = TODAYOPEN() - @Amp - StdMod
SET LrSlope = LinearRegressionSlope(CLOSE, @SlopeEntryPeriod)
SET SlopeExit = LinearRegressionSlope(CLOSE, @SlopeExitPeriod)
SET CrossUP = CROSSOVER(CLOSE, TodayUP)
SET ContCrossUP = LASTIF(CrossUP)
SET BUY = ContCrossUP > @entryBars AND CLOSE > TodayUP AND fast > slow AND REF(LrSlope, 1) < LrSlope
# AND TIME > 200 AND TIME < 1030
SET ContaBUY = LASTIF(BUY)
SET SignalLine = LR(CLOSE, @LRSignalExit)
# Usiamo il LASTIF che misura il numero di barre da quando la SignalLine è verde
SET barre = LASTIF(SignalLine > REF(SignalLine, 1))
# barre > 3 significa che le ultime 2 barre la SignalLine e' stata verde ed anche
# la Slope della SignalLine corrente è negativa
SET ExitLong = barre = @LRexitBars AND SlopeExit < 0
ContaBUY > @exitTemp AND ExitLong
EXIT SHORT
SET fast = MovingAverage(@price, @fastPeriods, @matype)
SET slow = MovingAverage(@price, @slowPeriods, @matype)
SET STD = StandardDeviations(@price, @STDperiods, 1, @matype)
SET StdMod = IF(STD > @MaxStd, 10, STD)
SET TodayUP = TODAYOPEN() + @Amp + StdMod
SET TodayDown = TODAYOPEN() - @Amp - StdMod
SET LrSlope = LinearRegressionSlope(CLOSE, @SlopeEntryPeriod)
SET SlopeExit = LinearRegressionSlope(CLOSE, @SlopeExitPeriod)
SET CrossDown = CROSSOVER(TodayDown, CLOSE)
SET ContCrossDown = LASTIF(CrossDown)
SET SELL = ContCrossDown = @entryBars AND CLOSE < TodayDown AND slow > fast AND REF(LrSlope, 1) > LrSlope
# AND TIME > 200 AND TIME < 1030
SET ContaSELL = LASTIF(SELL)
SET SignalLine = LR(CLOSE, @LRSignalExit)
# Usiamo il LASTIF che misura il numero di barre da quando la SignalLine è verde
SET barre = LASTIF(SignalLine < REF(SignalLine, 1))
# barre > 3 significa che le ultime 2 barre la SignalLine e' stata verde ed anche
# la Slope della SignalLine corrente è negativa
SET ExitShort = barre > @LRexitBars AND SlopeExit > 0
ContaSELL > @exitTemp AND ExitShort