Trailing Stop Loss — Strategy by jason5480

By fgo943

Performance Metrics

Description

May 3, 2021This script demonstrate how to make a Training Stop Loss to "ride the wave". In comparison to classic Stop Loss this strategy follows the price upwards (for long positions) and when price drops by a fixed percentage then you exit your position.May 3, 2021Release Notes Minor typosMay 4, 2021Release NotesAdd the ability to disable trailing for demonstration reasonsClose open orders on trend reversalAdd sell labels on cross-underMay 4, 2021Release NotesFix a bug that made Stop Loss to not trigger appropriately when it was reached at the very first candle end enable trailing was un-checkedMay 4, 2021Release NotesRefactor stopValue calculation to be more readableMay 4, 2021Release NotesFix longIsActive logicMay 24, 2021Release NotesCheck if time is within backtest period in order to set the price to prevent unnecessary calculations and drawing outside the area of interestReplace deprecated trasp argument with color.newJul 17, 2021Release Notes Set calc on every tick to false by default, as fgo943 suggestedJul 21, 2021Release Notes Minor Update the chart for a better overview and understanding of the trailing stop lossAug 7, 2021Release NotesFix a bug that were causing stop loss to be calculated wrong when there was new entry back to back with the end of the previous oneUse strategy.percent_of_equityAug 7, 2021Release NotesDraw lines with width 1Oct 11, 2021Release NotesUpdate to pinescript V5Stop Loss step is now 0.05Nov 28, 2021Release NotesLet's face it a Green-Red color model is more intuitive!Jan 1, 2022Release NotesHappy New Year!Many code refactorings and optimizations to better use this script as a template and plug your own strategy at easeJan 6, 2022Release NotesBug fix: (rare/minor) Remove 'strategy.position_size == 0' condition in stop loss calculation that made the very first stop loss price target to be calculated based on previous 'strategy.position_avg_price' instead of 'close' if the previous position closed exactly one bar before! Jan 12, 2022Release Notes(minor) refactoringJul 3, 2022Release NotesUse time_filters libraryJul 3, 2022Release NotesMinor revision updateJul 9, 2022Release NotesReplace deprecated "when=" with if statements in strategy callsJul 13, 2022Release NotesChange fastMA default color to yellowJul 29, 2022Release NotesIncrease max labels to 300Minor refactoringAug 9, 2022Release NotesUpdate time_filters librarySep 2, 2022Release NotesSome minor label/color changesJan 10, 2023Release Notessmall refactoringJan 17, 2023Release NotesUpdate time_filters library versionMar 19, 2023Release Notes Update time_filters library versionDec 1, 2023Release NotesUse the 'chrono_utils' library for the date-time window filterSep 17, 2024Release Notes Add different alert messages per event Update 'chrono_utils' libraryMar 1Release Notes Update to pinescript version 6

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView