Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is an example configuration for setting a long condition using PineScript Ichimoku:

//@version=4
study(title="Ichimoku Cloud", overlay=true)

conversionPeriods = input(9, title="Conversion Line Periods")
basePeriods = input(26, title="Base Line Periods")
laggingSpan2Periods = input(52, title="Lagging Span 2 Periods")
displacement = input(26, title="Displacement")

conversionLine = avg(highest(high, conversionPeriods), lowest(low, conversionPeriods))
baseLine = avg(highest(high, basePeriods), lowest(low, basePeriods))
spanA = avg(conversionLine, baseLine)

laggingSpan1 = close[displacement]
laggingSpan2 = avg(highest(high, laggingSpan2Periods), lowest(low, laggingSpan2Periods))[displacement]

colorCloud = spanA > spanB ? color.green : color.red
fill(spanA, spanB, color=colorCloud, transp=80)

longCondition = crossover(price, spanA) and crossover(price, spanB)

plot(laggingSpan1, linewidth=3, color=color.purple, title="Lagging Span 1")
plot(laggingSpan2, linewidth=3, color=color.orange, title="Lagging Span 2")

plot(conversionLine, color=color.blue, title="Conversion Line")
plot(baseLine, color=color.red, title="Base Line")

This code sets the conditions for a long position, which is when the price crosses above the Ichimoku Cloud (formed by Span A and Span B). The long condition is set using the crossover function to check for when the price crosses over both Span A and Span B.

Note that this is just an example configuration, and you may need to adjust the settings to match your trading strategy and preferences.