OPEN-SOURCE SCRIPT
업데이트됨 Martingale Range Breakout

# Martingale Range Breakout
**Martingale Range Breakout** is a session-based breakout and flip-tracking indicator designed to study range expansion behavior after a defined range.
This script builds a custom time-based range, tracks breakout direction, monitors flip attempts, and displays live trade-state data with rolling performance stats directly on the chart.
---
## Core Concept
The indicator creates a range from a selected session window.
By default, the range is built from:
**8:00 AM – 8:50 AM New York Time**
Once the range locks, the script watches for price to break above or below the range.
* Break above the range = **Long Active**
* Break below the range = **Short Active**
* If price reverses and breaks the opposite side, the script counts that as a **flip**
* If price reaches the full range extension before 4 flips, it marks the setup as a **WIN**
* If the setup reaches 4 flips, it marks the setup as a **LOSS**
---
## Martingale Flip Logic
This indicator is based on a Martingale-style flip model.
The idea is that when a breakout fails and price flips to the opposite side of the range, the next position size is increased to help recover the previous failed attempt.
Example position sequence:
* Flip 1: **1 contract**
* Flip 2: **2 contracts**
* Flip 3: **4 contracts**
* Flip 4: **Loss**
Each flip represents the market failing in one direction and then triggering the opposite side of the range.
The goal of the Martingale model is for the final successful breakout to recover the previous failed flips and still finish the sequence in profit.
The table tracks the current trade state and flip count, allowing traders to see what stage of the Martingale sequence the setup is currently in.
---
## Visual Range Boxes
The script draws two clean visual zones on the chart.
**Yellow Box**
Shows the original session range.
**Green Box**
Shows the full expansion zone based on the range size.
The final target levels are calculated as:
* Buy final target = **Range High + Full Range Distance**
* Sell final target = **Range Low - Full Range Distance**
This makes it easy to see both the breakout levels and the final expansion targets.
---
## Live Trade State Tracking
The table displays the current setup condition in real time.
Possible states include:
* **WAITING**
* **LONG ACTIVE**
* **SHORT ACTIVE**
* **WIN**
* **LOSS**
The table also shows the current flip count, helping traders quickly identify how many times the setup has reversed.
---
## Built-In Rolling Statistics
The indicator tracks the last selected number of completed setups and displays performance data inside the chart table.
Stats include:
* Last N trade count
* Wins and losses
* Rolling win rate
* Rolling R total
* Average winning range size
* Average losing range size
* Current range size
* Win sample count
* Loss sample count
* Average minutes to win
* Average minutes to loss
The rolling sample size can be adjusted in the settings.
---
## Breakeven Win Rate Requirement
This model uses a negative-risk-reward structure, meaning each win is smaller than each full loss.
The R Total calculation is based on:
* Win = **+0.14285R**
* Loss = **-1R**
Because each full loss is much larger than each win, the system needs a very high win rate to be profitable.
The approximate breakeven win rate is:
**87.5%**
That means the strategy must win more than **87.5%** of completed setups to show positive expectancy under this model.
* Below **87.5% win rate** = negative expectancy
* At **87.5% win rate** = around breakeven
* Above **87.5% win rate** = positive expectancy
This is why the rolling win-rate tracker is important. It helps traders quickly see whether the most recent sample is performing above or below the required profitability threshold.
Even though the Martingale flip model can create a high win rate, the full loss is much larger than the average win. Because of that, risk management is extremely important.
---
## R-Multiple Model
The R Total section helps estimate whether the recent rolling sample is profitable based on the script’s fixed reward-to-risk model.
Instead of only showing win rate, the script also calculates the overall R performance across the selected sample.
This helps traders avoid focusing only on a high win rate and instead evaluate whether the system is actually profitable after accounting for the larger full-loss event.
---
## Customizable Settings
You can adjust:
* Session start hour
* Session start minute
* Session end hour
* Session end minute
* Rolling trade sample size
* Show or hide the stats section
* Table position:
* Top Right
* Middle Right
* Bottom Right
---
## Best Use Case
This indicator is best used as a visual research tool for traders studying:
* Morning range breakouts
* Range expansion behavior
* Flip-based entry models
* Martingale-style recovery logic
* High-win-rate breakout systems
* Negative-risk-reward models
* Breakeven win-rate requirements
* Time-to-outcome behavior
* Rolling sample performance
---
## Important Risk Notice
This is an indicator only. It does not place trades automatically and should not be considered financial advice.
Martingale-style systems can increase risk quickly because each failed flip requires a larger position size. While the model may recover losses when the breakout eventually succeeds, the downside can become large when multiple flips fail.
A system like this does not only need to win often — it needs to win enough to overcome the size of its losses. Under this model, that means maintaining a win rate above approximately **87.5%**.
Always test thoroughly, use proper risk management, and understand the full risk before applying any strategy live.
**Martingale Range Breakout** is a session-based breakout and flip-tracking indicator designed to study range expansion behavior after a defined range.
This script builds a custom time-based range, tracks breakout direction, monitors flip attempts, and displays live trade-state data with rolling performance stats directly on the chart.
---
## Core Concept
The indicator creates a range from a selected session window.
By default, the range is built from:
**8:00 AM – 8:50 AM New York Time**
Once the range locks, the script watches for price to break above or below the range.
* Break above the range = **Long Active**
* Break below the range = **Short Active**
* If price reverses and breaks the opposite side, the script counts that as a **flip**
* If price reaches the full range extension before 4 flips, it marks the setup as a **WIN**
* If the setup reaches 4 flips, it marks the setup as a **LOSS**
---
## Martingale Flip Logic
This indicator is based on a Martingale-style flip model.
The idea is that when a breakout fails and price flips to the opposite side of the range, the next position size is increased to help recover the previous failed attempt.
Example position sequence:
* Flip 1: **1 contract**
* Flip 2: **2 contracts**
* Flip 3: **4 contracts**
* Flip 4: **Loss**
Each flip represents the market failing in one direction and then triggering the opposite side of the range.
The goal of the Martingale model is for the final successful breakout to recover the previous failed flips and still finish the sequence in profit.
The table tracks the current trade state and flip count, allowing traders to see what stage of the Martingale sequence the setup is currently in.
---
## Visual Range Boxes
The script draws two clean visual zones on the chart.
**Yellow Box**
Shows the original session range.
**Green Box**
Shows the full expansion zone based on the range size.
The final target levels are calculated as:
* Buy final target = **Range High + Full Range Distance**
* Sell final target = **Range Low - Full Range Distance**
This makes it easy to see both the breakout levels and the final expansion targets.
---
## Live Trade State Tracking
The table displays the current setup condition in real time.
Possible states include:
* **WAITING**
* **LONG ACTIVE**
* **SHORT ACTIVE**
* **WIN**
* **LOSS**
The table also shows the current flip count, helping traders quickly identify how many times the setup has reversed.
---
## Built-In Rolling Statistics
The indicator tracks the last selected number of completed setups and displays performance data inside the chart table.
Stats include:
* Last N trade count
* Wins and losses
* Rolling win rate
* Rolling R total
* Average winning range size
* Average losing range size
* Current range size
* Win sample count
* Loss sample count
* Average minutes to win
* Average minutes to loss
The rolling sample size can be adjusted in the settings.
---
## Breakeven Win Rate Requirement
This model uses a negative-risk-reward structure, meaning each win is smaller than each full loss.
The R Total calculation is based on:
* Win = **+0.14285R**
* Loss = **-1R**
Because each full loss is much larger than each win, the system needs a very high win rate to be profitable.
The approximate breakeven win rate is:
**87.5%**
That means the strategy must win more than **87.5%** of completed setups to show positive expectancy under this model.
* Below **87.5% win rate** = negative expectancy
* At **87.5% win rate** = around breakeven
* Above **87.5% win rate** = positive expectancy
This is why the rolling win-rate tracker is important. It helps traders quickly see whether the most recent sample is performing above or below the required profitability threshold.
Even though the Martingale flip model can create a high win rate, the full loss is much larger than the average win. Because of that, risk management is extremely important.
---
## R-Multiple Model
The R Total section helps estimate whether the recent rolling sample is profitable based on the script’s fixed reward-to-risk model.
Instead of only showing win rate, the script also calculates the overall R performance across the selected sample.
This helps traders avoid focusing only on a high win rate and instead evaluate whether the system is actually profitable after accounting for the larger full-loss event.
---
## Customizable Settings
You can adjust:
* Session start hour
* Session start minute
* Session end hour
* Session end minute
* Rolling trade sample size
* Show or hide the stats section
* Table position:
* Top Right
* Middle Right
* Bottom Right
---
## Best Use Case
This indicator is best used as a visual research tool for traders studying:
* Morning range breakouts
* Range expansion behavior
* Flip-based entry models
* Martingale-style recovery logic
* High-win-rate breakout systems
* Negative-risk-reward models
* Breakeven win-rate requirements
* Time-to-outcome behavior
* Rolling sample performance
---
## Important Risk Notice
This is an indicator only. It does not place trades automatically and should not be considered financial advice.
Martingale-style systems can increase risk quickly because each failed flip requires a larger position size. While the model may recover losses when the breakout eventually succeeds, the downside can become large when multiple flips fail.
A system like this does not only need to win often — it needs to win enough to overcome the size of its losses. Under this model, that means maintaining a win rate above approximately **87.5%**.
Always test thoroughly, use proper risk management, and understand the full risk before applying any strategy live.
릴리즈 노트
focus on the close오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.