OPEN-SOURCE SCRIPT
Third eye • Strategy

Third eye • Strategy – User Guide
1. Idea & Concept
Third eye • Strategy combines three things into one system:
Ichimoku Cloud – to define market regime and support/resistance.
Moving Average (trend filter) – to trade only in the dominant direction.
CCI (Commodity Channel Index) – to generate precise entry signals on momentum breakouts.
The script is a strategy, not an indicator: it can backtest entries, exits, SL, TP and BreakEven logic automatically.
2. Indicators Used
2.1 Ichimoku
Standard Ichimoku settings (by default 9/26/52/26) are used:
Conversion Line (Tenkan-sen)
Base Line (Kijun-sen)
Leading Span A & B (Kumo Cloud)
Lagging Span is calculated but hidden from the chart (for visual simplicity).
From the cloud we derive:
kumoTop – top of the cloud under current price.
kumoBottom – bottom of the cloud under current price.
Flags:
is_above_kumo – price above the cloud.
is_below_kumo – price below the cloud.
is_in_kumo – price inside the cloud.
These conditions are used as trend / regime filters and for stop-loss & trailing stops.
2.2 Moving Average
You can optionally display and use a trend MA:
Types: SMA, EMA, DEMA, WMA
Length: configurable (default 200)
Source: default close
Filter idea:
If MA Direction Filter is ON:
When Close > MA → strategy allows only Long signals.
When Close < MA → strategy allows only Short signals.
The MA is plotted on the chart (if enabled).
2.3 CCI & Panel
The CCI (Commodity Channel Index) is used for entry timing:
CCI length and source are configurable (default length 20, source hlc3).
Two thresholds:
CCI Upper Threshold (Long) – default +100
CCI Lower Threshold (Short) – default –100
Signals:
Long signal:
CCI crosses up through the upper threshold
cci_val[1] < upper_threshold and cci_val > upper_threshold
Short signal:
CCI crosses down through the lower threshold
cci_val[1] > lower_threshold and cci_val < lower_threshold
There is a panel (table) in the bottom-right corner:
Shows current CCI value.
Shows filter status as colored dots:
Green = filter enabled and passed.
Red = filter enabled and blocking trades.
Gray = filter is disabled.
Filters shown in the panel:
Ichimoku Cloud filter (Long/Short)
Ichimoku Lines filter (Conversion/Base vs Cloud)
MA Direction filter
3. Filters & Trade Direction
All filters can be turned ON/OFF independently.
3.1 Ichimoku Cloud Filter
Purpose: trade only when price is clearly above or below the Kumo.
Long Cloud Filter (Use Ichimoku Cloud Filter) – when enabled:
Long trades only if close > cloud top.
Short Cloud Filter – when enabled:
Short trades only if close < cloud bottom.
If the cloud filter is disabled, this condition is ignored.
3.2 Ichimoku Lines Above/Below Cloud
Purpose: stronger trend confirmation: Ichimoku lines should also be on the “correct” side of the cloud.
Long Lines Filter:
Long allowed only if Conversion Line and Base Line are both above the cloud.
Short Lines Filter:
Short allowed only if both lines are below the cloud.
If this filter is OFF, the conditions are not checked.
3.3 MA Direction Filter
As described above:
When ON:
Close > MA → only Longs.
Close < MA → only Shorts.
4. Anti-Re-Entry Logic (Cloud Touch Reset)
The strategy uses internal flags to avoid continuous re-entries in the same direction without a reset.
Two flags:
allowLong
allowShort
After a Long entry, allowLong is set to false, allowShort to true.
After a Short entry, allowShort is set to false, allowLong to true.
Flags are reset when price touches the Kumo:
If Low goes into the cloud → allowLong = true
If High goes into the cloud → allowShort = true
If Close is inside the cloud → both allowLong and allowShort are set to true
There is a key option:
Wait Position Close Before Flag Reset
If ON: cloud touch will reset flags only when there is no open position.
If OFF: flags can be reset even while a trade is open.
This gives a kind of regime-based re-entry control: after a trend leg, you wait for a “cloud interaction” to allow new signals.
5. Risk Management
All risk management is handled inside the strategy.
5.1 Position Sizing
Order Size % of Equity – default 10%
The strategy calculates:
position_value = equity * (Order Size % / 100)
position_qty = position_value / close
So position size automatically adapts to your current equity.
5.2 Take Profit Modes
You can choose one of two TP modes:
Percent
Fibonacci
5.2.1 Percent Mode
Single Take Profit at X% from entry (default 2%).
For Long:
TP = entry_price * (1 + tp_pct / 100)
For Short:
TP = entry_price * (1 - tp_pct / 100)
One strategy.exit per side is used: "Long TP/SL" and "Short TP/SL".
5.2.2 Fibonacci Mode (2 partial TPs)
In this mode, TP levels are based on a virtual Fib-style extension between entry and stop-loss.
Inputs:
Fib TP1 Level (default 1.618)
Fib TP2 Level (default 2.5)
TP1 Share % (Fib) (default 50%)
TP2 share is automatically 100% - TP1 share.
Process for Long:
Compute a reference Stop (see SL section below) → sl_for_fib.
Compute distance: dist = entry_price - sl_for_fib.
TP levels:
TP1 = entry_price + dist * (Fib TP1 Level - 1)
TP2 = entry_price + dist * (Fib TP2 Level - 1)
For Short, the logic is mirrored.
Two exits are used:
TP1 – closes TP1 share % of position.
TP2 – closes remaining TP2 share %.
Same stop is used for both partial exits.
5.3 Stop-Loss Modes
You can choose one of three Stop Loss modes:
Stable – fixed % from entry.
Ichimoku – fixed level derived from the Kumo.
Ichimoku Trailing – dynamic SL following the cloud.
5.3.1 Stable SL
For Long:
SL = entry_price * (1 - Stable SL % / 100)
For Short:
SL = entry_price * (1 + Stable SL % / 100)
Used both for Percent TP mode and as reference for Fib TP if Kumo is not available.
5.3.2 Ichimoku SL (fixed, non-trailing)
At the time of a new trade:
For Long:
Base SL = cloud bottom minus small offset (%)
For Short:
Base SL = cloud top plus small offset (%)
The offset is configurable: Ichimoku SL Offset %.
Once computed, that SL level is fixed for this trade.
5.3.3 Ichimoku Trailing SL
Similar to Ichimoku SL, but recomputed each bar:
For Long:
SL = cloud bottom – offset
For Short:
SL = cloud top + offset
A red trailing SL line is drawn on the chart to visualize current stop level.
This trailing SL is also used as reference for BreakEven and for Fib TP distance.
6. BreakEven Logic (with BE Lines)
BreakEven is optional and supports two modes:
Percent
Fibonacci
Inputs:
Percent mode:
BE Trigger % (from entry) – move SL to BE when price goes this % in profit.
BE Offset % from entry – SL will be set to entry ± this offset.
Fibonacci mode:
BE Fib Level – Fib level at which BE will be activated (default 1.618, same style as TP).
BE Offset % from entry – how far from entry to place BE stop.
The logic:
Before BE is triggered, SL follows its normal mode (Stable/Ichimoku/Ichimoku Trailing).
When BE triggers:
For Long:
New SL = max(current SL, BE SL).
For Short:
New SL = min(current SL, BE SL).
This means BE will never loosen the stop – only tighten it.
When BE is activated, the strategy draws a violet horizontal line at the BreakEven level (once per trade).
BE state is cleared when the position is closed or when a new position is opened.
7. Entry & Exit Logic (Summary)
7.1 Long Entry
Conditions for a Long:
CCI signal:
CCI crosses up through the upper threshold.
Ichimoku Cloud Filter (optional):
If enabled → price must be above the Kumo.
Ichimoku Lines Filter (optional):
If enabled → Conversion Line and Base Line must be above the Kumo.
MA Direction Filter (optional):
If enabled → Close must be above the chosen MA.
Anti-re-entry flag:
allowLong must be true (cloud-based reset).
Position check:
Long entries are allowed when current position size ≤ 0 (so it can also reverse from short to long).
If all these conditions are true, the strategy sends:
strategy.entry("Long", strategy.long, qty = calculated_qty)
After entry:
allowLong = false
allowShort = true
7.2 Short Entry
Same structure, mirrored:
CCI signal:
CCI crosses down through the lower threshold.
Cloud filter: price must be below cloud (if enabled).
Lines filter: conversion & base must be below cloud (if enabled).
MA filter: Close must be below MA (if enabled).
allowShort must be true.
Position check: position size ≥ 0 (allows reversal from long to short).
Then:
strategy.entry("Short", strategy.short, qty = calculated_qty)
Flags update:
allowShort = false
allowLong = true
7.3 Exits
While in a position:
The strategy continuously recalculates SL (depending on chosen mode) and, in Percent mode, TP.
In Fib mode, fixed TP levels are computed at entry.
BreakEven may raise/tighten the SL if its conditions are met.
Exits are executed via strategy.exit:
Percent mode: one TP+SL exit per side.
Fib mode: two partial exits (TP1 and TP2) sharing the same SL.
At position open, the script also draws visual lines:
White line — entry price.
Green line(s) — TP level(s).
Red line — SL (if not using Ichimoku Trailing; with trailing, the red line is updated dynamically).
Maximum of 30 lines are kept to avoid clutter.
8. How to Use the Strategy
Choose market & timeframe
Works well on trending instruments. Try crypto, FX or indices on H1–H4, or intraday if you prefer more trades.
Adjust Ichimoku settings
Keep defaults (9/26/52/26) or adapt to your timeframe.
Configure Moving Average
Typical: EMA 200 as a trend filter.
Turn MA Direction Filter ON if you want to trade only with the main trend.
Set CCI thresholds
Default ±100 is classic.
Lower thresholds → more signals, higher noise.
Higher thresholds → fewer but stronger signals.
Enable/disable filters
Turn on Ichimoku Cloud and Ichimoku Lines if you want only “clean” trend trades.
Use Wait Position Close Before Flag Reset to control how often re-entries are allowed.
Choose TP & SL mode
Percent mode is simpler and easier to understand.
Fibonacci mode is more advanced: it aligns TP levels with the distance to stop, giving asymmetric RR setups (two partial TPs).
Choose Stable SL for fixed-risk trades, or Ichimoku / Ichimoku Trailing to tie stops to the cloud structure.
Set BreakEven
Enable BE if you want to lock in risk-free trades after a certain move.
Percent mode is straightforward; Fib mode keeps BreakEven in harmony with your Fib TP setup.
Run Backtest & Optimize
Press “Add to chart” → go to Strategy Tester.
Adjust parameters to your market and timeframe.
Look at equity curve, PF, drawdown, average trade, etc.
Live / Paper Trading
After you’re satisfied with backtest results, use the strategy to generate signals.
You can mirror entries/exits manually or connect them to alerts (if you build an alert-based execution layer).
1. Idea & Concept
Third eye • Strategy combines three things into one system:
Ichimoku Cloud – to define market regime and support/resistance.
Moving Average (trend filter) – to trade only in the dominant direction.
CCI (Commodity Channel Index) – to generate precise entry signals on momentum breakouts.
The script is a strategy, not an indicator: it can backtest entries, exits, SL, TP and BreakEven logic automatically.
2. Indicators Used
2.1 Ichimoku
Standard Ichimoku settings (by default 9/26/52/26) are used:
Conversion Line (Tenkan-sen)
Base Line (Kijun-sen)
Leading Span A & B (Kumo Cloud)
Lagging Span is calculated but hidden from the chart (for visual simplicity).
From the cloud we derive:
kumoTop – top of the cloud under current price.
kumoBottom – bottom of the cloud under current price.
Flags:
is_above_kumo – price above the cloud.
is_below_kumo – price below the cloud.
is_in_kumo – price inside the cloud.
These conditions are used as trend / regime filters and for stop-loss & trailing stops.
2.2 Moving Average
You can optionally display and use a trend MA:
Types: SMA, EMA, DEMA, WMA
Length: configurable (default 200)
Source: default close
Filter idea:
If MA Direction Filter is ON:
When Close > MA → strategy allows only Long signals.
When Close < MA → strategy allows only Short signals.
The MA is plotted on the chart (if enabled).
2.3 CCI & Panel
The CCI (Commodity Channel Index) is used for entry timing:
CCI length and source are configurable (default length 20, source hlc3).
Two thresholds:
CCI Upper Threshold (Long) – default +100
CCI Lower Threshold (Short) – default –100
Signals:
Long signal:
CCI crosses up through the upper threshold
cci_val[1] < upper_threshold and cci_val > upper_threshold
Short signal:
CCI crosses down through the lower threshold
cci_val[1] > lower_threshold and cci_val < lower_threshold
There is a panel (table) in the bottom-right corner:
Shows current CCI value.
Shows filter status as colored dots:
Green = filter enabled and passed.
Red = filter enabled and blocking trades.
Gray = filter is disabled.
Filters shown in the panel:
Ichimoku Cloud filter (Long/Short)
Ichimoku Lines filter (Conversion/Base vs Cloud)
MA Direction filter
3. Filters & Trade Direction
All filters can be turned ON/OFF independently.
3.1 Ichimoku Cloud Filter
Purpose: trade only when price is clearly above or below the Kumo.
Long Cloud Filter (Use Ichimoku Cloud Filter) – when enabled:
Long trades only if close > cloud top.
Short Cloud Filter – when enabled:
Short trades only if close < cloud bottom.
If the cloud filter is disabled, this condition is ignored.
3.2 Ichimoku Lines Above/Below Cloud
Purpose: stronger trend confirmation: Ichimoku lines should also be on the “correct” side of the cloud.
Long Lines Filter:
Long allowed only if Conversion Line and Base Line are both above the cloud.
Short Lines Filter:
Short allowed only if both lines are below the cloud.
If this filter is OFF, the conditions are not checked.
3.3 MA Direction Filter
As described above:
When ON:
Close > MA → only Longs.
Close < MA → only Shorts.
4. Anti-Re-Entry Logic (Cloud Touch Reset)
The strategy uses internal flags to avoid continuous re-entries in the same direction without a reset.
Two flags:
allowLong
allowShort
After a Long entry, allowLong is set to false, allowShort to true.
After a Short entry, allowShort is set to false, allowLong to true.
Flags are reset when price touches the Kumo:
If Low goes into the cloud → allowLong = true
If High goes into the cloud → allowShort = true
If Close is inside the cloud → both allowLong and allowShort are set to true
There is a key option:
Wait Position Close Before Flag Reset
If ON: cloud touch will reset flags only when there is no open position.
If OFF: flags can be reset even while a trade is open.
This gives a kind of regime-based re-entry control: after a trend leg, you wait for a “cloud interaction” to allow new signals.
5. Risk Management
All risk management is handled inside the strategy.
5.1 Position Sizing
Order Size % of Equity – default 10%
The strategy calculates:
position_value = equity * (Order Size % / 100)
position_qty = position_value / close
So position size automatically adapts to your current equity.
5.2 Take Profit Modes
You can choose one of two TP modes:
Percent
Fibonacci
5.2.1 Percent Mode
Single Take Profit at X% from entry (default 2%).
For Long:
TP = entry_price * (1 + tp_pct / 100)
For Short:
TP = entry_price * (1 - tp_pct / 100)
One strategy.exit per side is used: "Long TP/SL" and "Short TP/SL".
5.2.2 Fibonacci Mode (2 partial TPs)
In this mode, TP levels are based on a virtual Fib-style extension between entry and stop-loss.
Inputs:
Fib TP1 Level (default 1.618)
Fib TP2 Level (default 2.5)
TP1 Share % (Fib) (default 50%)
TP2 share is automatically 100% - TP1 share.
Process for Long:
Compute a reference Stop (see SL section below) → sl_for_fib.
Compute distance: dist = entry_price - sl_for_fib.
TP levels:
TP1 = entry_price + dist * (Fib TP1 Level - 1)
TP2 = entry_price + dist * (Fib TP2 Level - 1)
For Short, the logic is mirrored.
Two exits are used:
TP1 – closes TP1 share % of position.
TP2 – closes remaining TP2 share %.
Same stop is used for both partial exits.
5.3 Stop-Loss Modes
You can choose one of three Stop Loss modes:
Stable – fixed % from entry.
Ichimoku – fixed level derived from the Kumo.
Ichimoku Trailing – dynamic SL following the cloud.
5.3.1 Stable SL
For Long:
SL = entry_price * (1 - Stable SL % / 100)
For Short:
SL = entry_price * (1 + Stable SL % / 100)
Used both for Percent TP mode and as reference for Fib TP if Kumo is not available.
5.3.2 Ichimoku SL (fixed, non-trailing)
At the time of a new trade:
For Long:
Base SL = cloud bottom minus small offset (%)
For Short:
Base SL = cloud top plus small offset (%)
The offset is configurable: Ichimoku SL Offset %.
Once computed, that SL level is fixed for this trade.
5.3.3 Ichimoku Trailing SL
Similar to Ichimoku SL, but recomputed each bar:
For Long:
SL = cloud bottom – offset
For Short:
SL = cloud top + offset
A red trailing SL line is drawn on the chart to visualize current stop level.
This trailing SL is also used as reference for BreakEven and for Fib TP distance.
6. BreakEven Logic (with BE Lines)
BreakEven is optional and supports two modes:
Percent
Fibonacci
Inputs:
Percent mode:
BE Trigger % (from entry) – move SL to BE when price goes this % in profit.
BE Offset % from entry – SL will be set to entry ± this offset.
Fibonacci mode:
BE Fib Level – Fib level at which BE will be activated (default 1.618, same style as TP).
BE Offset % from entry – how far from entry to place BE stop.
The logic:
Before BE is triggered, SL follows its normal mode (Stable/Ichimoku/Ichimoku Trailing).
When BE triggers:
For Long:
New SL = max(current SL, BE SL).
For Short:
New SL = min(current SL, BE SL).
This means BE will never loosen the stop – only tighten it.
When BE is activated, the strategy draws a violet horizontal line at the BreakEven level (once per trade).
BE state is cleared when the position is closed or when a new position is opened.
7. Entry & Exit Logic (Summary)
7.1 Long Entry
Conditions for a Long:
CCI signal:
CCI crosses up through the upper threshold.
Ichimoku Cloud Filter (optional):
If enabled → price must be above the Kumo.
Ichimoku Lines Filter (optional):
If enabled → Conversion Line and Base Line must be above the Kumo.
MA Direction Filter (optional):
If enabled → Close must be above the chosen MA.
Anti-re-entry flag:
allowLong must be true (cloud-based reset).
Position check:
Long entries are allowed when current position size ≤ 0 (so it can also reverse from short to long).
If all these conditions are true, the strategy sends:
strategy.entry("Long", strategy.long, qty = calculated_qty)
After entry:
allowLong = false
allowShort = true
7.2 Short Entry
Same structure, mirrored:
CCI signal:
CCI crosses down through the lower threshold.
Cloud filter: price must be below cloud (if enabled).
Lines filter: conversion & base must be below cloud (if enabled).
MA filter: Close must be below MA (if enabled).
allowShort must be true.
Position check: position size ≥ 0 (allows reversal from long to short).
Then:
strategy.entry("Short", strategy.short, qty = calculated_qty)
Flags update:
allowShort = false
allowLong = true
7.3 Exits
While in a position:
The strategy continuously recalculates SL (depending on chosen mode) and, in Percent mode, TP.
In Fib mode, fixed TP levels are computed at entry.
BreakEven may raise/tighten the SL if its conditions are met.
Exits are executed via strategy.exit:
Percent mode: one TP+SL exit per side.
Fib mode: two partial exits (TP1 and TP2) sharing the same SL.
At position open, the script also draws visual lines:
White line — entry price.
Green line(s) — TP level(s).
Red line — SL (if not using Ichimoku Trailing; with trailing, the red line is updated dynamically).
Maximum of 30 lines are kept to avoid clutter.
8. How to Use the Strategy
Choose market & timeframe
Works well on trending instruments. Try crypto, FX or indices on H1–H4, or intraday if you prefer more trades.
Adjust Ichimoku settings
Keep defaults (9/26/52/26) or adapt to your timeframe.
Configure Moving Average
Typical: EMA 200 as a trend filter.
Turn MA Direction Filter ON if you want to trade only with the main trend.
Set CCI thresholds
Default ±100 is classic.
Lower thresholds → more signals, higher noise.
Higher thresholds → fewer but stronger signals.
Enable/disable filters
Turn on Ichimoku Cloud and Ichimoku Lines if you want only “clean” trend trades.
Use Wait Position Close Before Flag Reset to control how often re-entries are allowed.
Choose TP & SL mode
Percent mode is simpler and easier to understand.
Fibonacci mode is more advanced: it aligns TP levels with the distance to stop, giving asymmetric RR setups (two partial TPs).
Choose Stable SL for fixed-risk trades, or Ichimoku / Ichimoku Trailing to tie stops to the cloud structure.
Set BreakEven
Enable BE if you want to lock in risk-free trades after a certain move.
Percent mode is straightforward; Fib mode keeps BreakEven in harmony with your Fib TP setup.
Run Backtest & Optimize
Press “Add to chart” → go to Strategy Tester.
Adjust parameters to your market and timeframe.
Look at equity curve, PF, drawdown, average trade, etc.
Live / Paper Trading
After you’re satisfied with backtest results, use the strategy to generate signals.
You can mirror entries/exits manually or connect them to alerts (if you build an alert-based execution layer).
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.