`//@version=5 strategy("4:4 S1", overlay=true) // Indicator Inputs fairValueGap = input(0.5, "Lux Algo Fair Value Gap") cciLevel = input(100, "CCI Level") cci = ta.cci(close, 20) regressionLength = input(20, "Regression Length") supertrendLength = input(10, "Supertrend Length") stopLoss = input(4, "Stop Loss (pips)") takeProfit = input(4, "Take Profit (pips)") // Calculate Indicators fairValue = ta.sma(close, 20) + fairValueGap supertrendUp = ta.sma(high, supertrendLength) + fairValueGap supertrendDown = ta.sma(low, supertrendLength) - fairValueGap regressionMA = ta.linreg(close, regressionLength, 0) // Define Long Entry Condition longEntry = close > (fairValue) and close > supertrendUp and (regressionMA) > 0 and ta.cci(close, 20) > -100 and ta.cci(close, 20) < 100 // Define Short Entry Condition shortEntry = close < (fairValue) and close < (supertrendDown) and (regressionMA) < 0 and ta.cci(close, 20) > -100 and ta.cci(close, 20) < 100 // Execute Trades if longEntry strategy.entry("Long", strategy.long) if shortEntry strategy.entry("Short", strategy.short) // Set Stop Loss and Take Profit stopLossPips = ta.valuewhen(longEntry, close, 0) - stopLoss * syminfo.mintick takeProfitPips = ta.valuewhen(longEntry, close, 0) + takeProfit * syminfo.mintick strategy.exit("Stop Loss/Take Profit", "Long", stop=stopLossPips, limit=takeProfitPips) strategy.exit("Stop Loss/Take Profit", "Short", stop=stopLossPips, limit=takeProfitPips) plotshape(longEntry, location=location.belowbar, size=size.normal, color=color.green, style=shape.triangleup) plotshape(shortEntry, location=location.abovebar, size=size.normal, color=color.red, style=shape.triangledown)``
1
There are 1 best solutions below
Related Questions in PINE-SCRIPT
- Calculation of volumes inside a candle
- How to get last_bar_index on bar_index == 0
- TradingView alerts are not being executed by strategy()
- the lowest low of some days
- How to sell at end of candle but buy at open on another in Trading View?
- is this User Defined Function using more memory/computing in PineScript v5?
- Pine Script: Loop Through Input Price levels & set Alerts for Each Price
- Pine v5 How to Delete Certain Labels?
- Working with various timeframe inside script irrespective of timeframe selected in charts
- Using Timeframe parameters Pinescript indicator
- How to plot horizontal lines for high and low of all weekly candles to be used on 1m and 5m charts
- Could not find function or function reference 'ta.adx'
- Want to extend FVG to certain time
- else if structure does not return true when it should
- how can I plot calculated dynamic levels?
Related Questions in TRADINGVIEW-API
- Pine- Script/ Trading View Not able to get the proper code for getting high + buffer value
- Pine (Tradingview) Showing different values in different timeframe
- get String length in Pine script
- How can I refresh the script on each new candle?
- Why won't this code run in Pine Script? “Undeclared identifier” error
- React js - Unhandled Rejection (TypeError): t._innerWindow(...).widgetReady is not a function
- Can't get TradingView alerts to pop up with my strategy
- How can I add a tradingview chart or its snapshot in google sheets using google apps script?
- Trading View Pine Script : How to Plot Single Character '❄' on Highest Yearly Candle and keep updating
- I just want to make my table even better but i couldnt
- How to get 1-minute price data into a 15-minute chart
- Change TradingView Indicator Daily Start Time
- How to add text to a custom plotted line?
- How do I enable these two gesture features in Trading View library like in their app?
- how to compare successive candles based on an accurate highs and lows
Related Questions in EXECUTE
- Path in instructions "CONCATE... PREPARE... EXECUTE... "
- Oracle: "missing or invalid option" when trying to create user
- SQL Server logic within EXECUTE statement ignoring transactions
- `EXECUTE` statement VS no `EXECUTE` statement in a function in PostgreSQL
- Escaping to return `TEXT[]` type with a `RETURN QUERY EXECUTE` and `VALUES` statement in PostgreSQL
- How to add a sum inside another sum under execute in cplex
- MySQL .execute TypeError: not all arguments converted during string formatting
- conn does not have an execute method
- Execute bash script on remote host
- pymssql cursor execute parameterized query errors
- Problem when trying to execute a java file after compiling with UTF8 encoding
- Find each table schema, name and column that doesn't contain a specific value in a PostgreSQL database
- whenever i am trying to build my react project with vite, in the browser it is showing me some icons
- Execute a batch on a remote computer with C# and show it on screen
- Why my strategy doss not execute in tradingview? it creates no trade? caution! this strategy did not generate any orders throughout the testing range
Related Questions in STRATEGY-PATTERN
- Code Snippet : Bridge Pattern or Strategy Pattern?
- esp32 rssi based tracking - Consultation
- Design approach for safely picking between multiple payment methods
- Type mismatch in Kotlin when using strategy pattern with generics
- How can I implement an object of strategies with same API but that only the provided argument options differ for each strategy?
- Pine script version change and stop reprint and repaint issue
- How to use mutable references as arguments for generic functions in rust
- Why my strategy doss not execute in tradingview? it creates no trade? caution! this strategy did not generate any orders throughout the testing range
- How do you implement the strategy pattern using Flutter and Riverpod?
- Is this Command Pattern or Strategy Pattern?
- How to conditionally select concrete implementation for strategy pattern using Dependency Injection C#
- The issue is that it should show the price values (coordinates) from which the line comes on a price scale, not on a graph! How to fix it?
- Implement Strategy pattern with Guice DI
- How to run different logic from Master page for different tab in TabContainer
- Java i can not initalize reference varibale in subclass because "VariableDeclaratorId expected after this token"
Related Questions in ENTRY-POINT
- "The procedure entry point XXXX could not be located in the dynamic link library YYYY" after migrating application from BDS 2006 to Delphi 2007
- How to set vite config to remove index file sunbfolder while mutlple entry point
- spaCy erroring out with I load en_core_web_sm/md/lg
- How to use entry_points to discover plugin in python with bazel in development?
- PineScript order entry at a horizontal line with a stop loss and take profit
- Doubts about Spring Boot microservice without entry point
- Why my strategy doss not execute in tradingview? it creates no trade? caution! this strategy did not generate any orders throughout the testing range
- Is there a way to specify per-feature project.scripts in pyproject.toml using hatch?
- How to import from a vue3 lib
- Android app crashes on load library, cannot find entry point getThreadLocalsEv, how to fix? [example added]
- Spring security is returning 401 for all exception
- The procedure entry point CreateAppContainerProfile could not be located in the dynamic link library USERENV.dll
- Docker-Compose: /entrypoint.sh: no such file or directory
- MSVC linker cannot find entry point in object files produced by NASM
- Re-locating App in FLASH not working, entry point unclear (STM32F072)
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
When I apply your strategy to a chart, it executes thousands of trades, so there doesn't seem to be any issue with the entry criteria.
What usually prevents the strategy from entering trades is your position sizing settings. For some instruments, TradingView's broker emulator would not fill an order unless you bought at least one contract.
To ensure that your strategy always buys at least one contract, set the
Order Sizeto1 Contract: