Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GuntharDeNiro/82ead6af058233752ff931f8f1eb9e26 to your computer and use it in GitHub Desktop.
Save GuntharDeNiro/82ead6af058233752ff931f8f1eb9e26 to your computer and use it in GitHub Desktop.
//@version=4
study("MM_Trend_Test", overlay=true)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2)
psar = sar(start, increment, maximum)
conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),
basePeriods = input(26, minval=1, title="Base Line Periods")
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),
displacement = input(1, minval=1, title="Displacement")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
lookback = input(2,minval=1)
cciLong = cci(close,14) > 100
cciShort = cci(close,14) < -100
longCondition = leadLine1 > leadLine2 and low > leadLine1 and psar < low and cciLong
shortCondition = leadLine1 < leadLine2 and high < leadLine1 and psar > high and cciShort
inLongPosition = false
inLongPosition := longCondition[1] ? true : shortCondition[1] ? false : inLongPosition[1]
inShortPosition = false
inShortPosition:= shortCondition[1] ? true : shortCondition[1] ? false : inShortPosition[1]
flat = false
flat := not inLongPosition and not inShortPosition
alertcondition(longCondition and flat, "Long", "LONG")
alertcondition(shortCondition and flat, "Short", "SHORT")
alertcondition(inLongPosition and psar > high, "ROE close LONG", "ROE close LONG")
alertcondition(inShortPosition and psar < low, "ROE close SHORT", "ROE close SHORT")
@truitaman
Copy link

// Here it's crypto version for ichi commonly used in the trading scene. Displacement should b 30 but boss said leave at 0

//@Version=4
study("MM_Trend_Test", overlay=true)

start = input(0.02)
increment = input(0.02)
maximum = input(0.2)

psar = sar(start, increment, maximum)

conversionPeriods = input(20, minval=1, title="Conversion Line Periods"),
basePeriods = input(60, minval=1, title="Base Line Periods")
laggingSpan2Periods = input(120, minval=1, title="Lagging Span 2 Periods"),
displacement = input(1, minval=1, title="Displacement")

donchian(len) => avg(lowest(len), highest(len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)

lookback = input(2,minval=1)

cciLong = cci(close,14) > 100
cciShort = cci(close,14) < -100

longCondition = leadLine1 > leadLine2 and low > leadLine1 and psar < low and cciLong

shortCondition = leadLine1 < leadLine2 and high < leadLine1 and psar > high and cciShort

inLongPosition = false
inLongPosition := longCondition[1] ? true : shortCondition[1] ? false : inLongPosition[1]
inShortPosition = false
inShortPosition:= shortCondition[1] ? true : shortCondition[1] ? false : inShortPosition[1]
flat = false
flat := not inLongPosition and not inShortPosition

alertcondition(longCondition and flat, "Long", "LONG")
alertcondition(shortCondition and flat, "Short", "SHORT")
alertcondition(inLongPosition and psar > high, "ROE close LONG", "ROE close LONG")
alertcondition(inShortPosition and psar < low, "ROE close SHORT", "ROE close SHORT")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment