Dragon-Bot - Default ScriptDragon-Script is a framework to make it as easy as possible to test your own strategies and set alerts for external execution bots. This is the alerts version of the script.
The script has many features build in, like:
1) A ping/pong mechanism between longs and shorts
2) A stop-loss
3) Trailing Stops with several ways to calculate them.
4) 2 different ways to flip from long to short.
The script is divided into several parts.
The first part of the script is used to set all the variables. You should normally never change the first part except for the comments at the top.
The second part of the script is the part where you initialise all your indicators. Several indicators can be found on Tradingview and on other sites. Please keep in mind that all the variable names used in the indicator should be unique. (all the … = … parts)
The third part of the script, is the most important part of the script. Here you can create the entry and exit points.
Let’s look at the OPENLONG function to explain this part: The first variables are all the possible entries; These are longentry1 till longentry5. You can add many more if you like.
The variables are all initialised as being false. This way the script can set a value to true if an entry happens.
The if function is the actual logic: You could say “if this is true” then (the line below the if function) longentry1 := (becomes) true.
In this case we have said: “if this is true” then (the line below the if function) longentry1 := (becomes) true when the current close is larger than the close that is 1 back.
The last part is the makelong_funct. This part says that if any of the entries are true, the whole function is true.
The last part of the script is the actual execution. Here the alerts are plotted and the back test strategies are opened and closed.
We hope you guys like it and all feedback is welcome!
Pinescript
Dragon Bot - Default ScriptDragon Script is a framework to make it as easy as possible to test your own strategies and set alerts for external execution bots.
The script has many features build in, like:
1) A ping/pong mechanism between longs and shorts
2) A stop-loss
3) Trailing Stops with several ways to calculate them.
4) 2 different ways to flip from long to short.
The script is divided into several parts.
The first part of the script is used to set all the variables. You should normally never change the first part except for the comments at the top.
The second part of the script is the part where you initialise all your indicators. Several indicators can be found on Tradingview and on other sites. Please keep in mind that all the variable names used in the indicator should be unique. (all the … = … parts)
The third part of the script, is the most important part of the script. Here you can create the entry and exit points.
Let’s look at the OPENLONG function to explain this part: The first variables are all the possible entries; These are longentry1 till longentry5. You can add many more if you like.
The variables are all initialised as being false. This way the script can set a value to true if an entry happens.
The if function is the actual logic: You could say “if this is true” then (the line below the if function) longentry1 := (becomes) true.
In this case we have said: “if this is true” then (the line below the if function) longentry1 := (becomes) true when the current close is larger than the close that is 1 back.
The last part is the makelong_funct. This part says that if any of the entries are true, the whole function is true.
The last part of the script is the actual execution. Here the alerts are plotted and the back test strategies are opened and closed.
We hope you guys like it and all feedback is welcome!
50/100/200 Moving Averages (Pine Script For Copy)by fresca
SCRIPT LANGUAGE
Copy script below and adjust based on your preferences.
-function (change function from "sma" to "ema", "wma" and more)
-length (25 Day, 150 Day or add more averages to the three in this script.)
-color, (red, yellow, etc. or use color hex codes i.e. #FEDA15, #FFAD8F, etc.)
-transparency (set to desired level 1-100)
Or add more options.
RESOURCES
Color hex codes site: www.canva.com
Trading View Pine Script Editor Reference Guide: www.tradingview.com
TRADING VIEW INDICATOR - PINE TUTORIAL 5After a long gap, I have written the 5th tutorial for the pine script. You can find the others below, if you read through all of these you should be good to do your own writing.
This script mimics the Trading View Indicator . For example this one below.
www.tradingview.com
It shows the net result of the 28 indicator, either as buy or sell. I have worked hard to make sure it matches the trading view results but I am not in hundred percent agreement with tradingView on SMA, EMA and Ichimoku indicator.
There are many commented plots because I needed to check separately if each indicator is working correctly.
Someone else wrote this code but they did not make it public. It took me about 3 weeks to write this and to be honest it could be cleaner and better commented.
If you find any mistake please let me know. I hope it will be useful in your learning.
Christmas Tree Theme With Open Code To See Pine ScriptI had been trying to code a predictive algorithm working with sine waves, but I got distracted and made some snow and Christmas trees lol. I'm uploading this with the source code because I'm sure someone will be able to learn from it to create something useful.
Please follow me for some actual useful pine scripts and merry Christmas! :)
CryptoSnaxAllinOne > 5 Scripts in 1 > Saving Time and Efficiency5 Scripts in 1 > Saving Time and Efficiency in My Daily Life
Tired of doing those repetivie tasks with Trading View?
- Spending Hours finding Support or Resistance?, Looking for Entry or Exit Signals? Looking for Pivot High/Low?
- Only to do it all again, when changing timeframes or asset!
- Fear Not > My All in One script should help.
Please find an overview of the All in One Script I have been building.
- This is purely for educational purposes.
- This script is not financial advice.
- I hold no responsibility for anyone using this script.
- I do not guarantee lifetime support for this script (if TV update version from 3 to 4, code will need to be updated)
- If you would like to use the script, please message me on TradingView.
- Script One > Give overall direction of trend with
- Script Two > Much Easier to see the Highs and the Lows of the Candles. Easier to Spot Resistance & Support. [Highest High / Lowest Low of Candle/Wick > 20Bars Eitherside)
- Script Three > 1st Confirmation of Pivot High and Low Plot > My 1st Confirmation of High or Low. [Pivot High/Low 20Bars Eitherside > 1st Confirm)
- Script Four > 2nd Confirmation of Pivot High and Low Plot > Entry and Exit > My 2nd Confirmation of High or Low. [Pivot High/Low 10Bars Eitherside > 2nd Confirm)
- Script Five > Plot in the Main Chart Red IF OverBought / Green if OverSold
NOTE > White Support Lines were Manually Drawn. I Drew them from the Script Data. I.e. Looking for Strong Support / Resistance Zones + Possible Fib = Manually Draw and Much Quicker to Make Qualified Decisions on the Probability.
Help Requested - "Time-Slot" Delay for Crossover StrategyHello Tradingview Community,
I've been playing around with some various volume-based indicators, and recently have been experiencing a delay in the entries for my strategy for 2 minutes in this scenario. If the time is adjusted, it also is delayed 2 bars.
In this example, the "Short" position should enter when the blue line Crosses under the upper green line, and visa vera for the "Long" position. A simplified Pine Script is available below as well.
I have Googled this issue and attempted to modify the code with => criteria instead, but too no avail. Would appreciate any help or anyone who could point me in the right direction on this Time Delay Issue. Thanks!
BarstateThe TradingView system has two types of bars. Bars that are historical and bars that are real-time.
When programming complex scripts and strategies that use higher timeframe data there can be difficult programming conditions due to these two bar states.
Especially in the case of after-hours, end of day, low volume trading and thinly traded stocks the bar state status can sometimes be historical and sometimes be real-time in different timeframes or even the same timeframe.
This script displays what state a bar is in by shading the background of the chart.
The script is being made publicly available to help my script users know about and understand 'barstate'. The script allows users to see the 'barstate' in order to help report bugs and conduct their own workarounds.
My testing has indicated that the 'barstate' status is sometimes spurious especially on thinly traded symbols. Additionally, the Tradingview back-end calls the script only after price changes to reduce system load. As a result, these two characteristics can cause unexpected Pine Script results.
Crinkebine
November 2018
Librehash Reversion Ribbon V2Out of all the indicators created by this brand, this is probably the grandest of them all.
Known as the ‘ZN Reversion Ribbon V2’, for short, this indicator is designed to:
1. Create multiple buy and sell signals
2. Help users gauge the momentum of the price movement.
3. Re-color candles to give users a better understanding of price direction as well as plotting entries and exits.
4. Serve as an enhanced version of the MACD indicator.
5. Effectively gauge buy and sell pressure at any given point in time by using former price data.
There are a lot of moving parts to this indicator, so this guide will be dedicated to dissecting these moving parts, piece by piece.
#1 — Histogram
Perhaps the simplest part of the indicator to dissect at the start is the Histogram. This is also the part of the indicator that can be the most important complement to any other readings that are being made.
You read the histogram in the same manner that you would read the Histogram for the MACD.
The bars in the background are the histogram. Reading this portion of the indicator is fairly simple though.
1. As the green bars get darker, the buy pressure is increasing.
2. As the red bars get darker, the sell pressure is increasing.
3. If the current bar is larger than the last, the trend is sustained. This is the same principle that you would observe in the MACD. The core difference, however, is that this indicator is plugged in with a specific formula (beyond just the basic moving averages), that make them more responsive to price movement in a way that allows for the anticipation of signals being formed.
#2 — Ribbon
The ribbon on this indicator has about 3 different buy/sell signals embedded within it that will allow traders to anticipate an impending change in trend well before it EVER occurs.
This may be the most valuable part of the indicator itself.
Let’s start with the first facet of the ribbon.
A) — The ‘widening’ of the ribbon
When the ribbon ‘expands’, that means that the trend is ‘strengthening’ or growing. When the ribbon narrows or ‘contracts’, that means that the trend is becoming weaker and that this may serve as a warning of impending trend reversal.
In the picture above, you can see the color change of the ribbon itself as well.
You’ll notice that the ribbon transitions from a darker red to a lighter red. That’s a sign of waning sell pressure. You can apply this concept to the green portion of the ribbon too.
B)— The Line Sometimes Signals Before the Cross
This one is a bit harder to explain, but the way that the indicator is programmed is not to turn ‘green’ or ‘red’ based on the crosses, but rather on a mathematical formula.
Now, because of the way the indicator is programmed, the cross often coincides with the color change — but not always.
Below is an example:
Of course, beyond this, there are the usual buy and sell signals that come with the MACD as well.
For instance, there is —
C) The Change in Direction of the is a ‘Buy’ or ‘Sell’ Signal As Well
--------------
Changes in the Candle Colors
Perhaps the most elaborate part of this indicator is the fact that it changes the colors of the candles on the chart in live time without repainting.
In order to understand the candles, here’s a quick guide:
a) dark green with green outline = extreme buy pressure
b) lighter green with green outline = normal buy pressure
c) dark red = heavy sell pressure
d) light red = light sell pressure
e) dark green with red outline = impending reversal downward
f) purple with any outline = ambiguous / neutral
g) light green with red outline = very, very weak sell pressure
h) dark green with red outline = exhausted buy pressure
f) dark red with green outline = exhausted sell pressure
Effectiveness of Indicator
This indicator has the ability to be a ‘game changer’ in terms of its ability to dissect price action.
This next picture is another awesome example of how this indicator works.
Check it out:
Here are the multiple reasons why we could’ve anticipated the reversal in price direction before red candles started showing up:
1. The actual reversion lines themselves began to converge.
2. The Histogram is declining.
3. The bar colors move from dark green to light green.
Now, you may be looking at the above picture and thinking, ‘Well it seems that it didn’t catch the major upswing in the price later though’.
This is true, however —
The gain from this move was preposterous.
Even still, the indicator ensures that we still garner some pretty significant profits.
Conclusion
What you see here sums up this indicator for the most part. However, there are continued updates that will be put out for the indicator in the near future as well.
As always, these can be pushed directly through TradingView (which will happen soon).
Heffae Resolution Commander (RAW)This is a script to call resolutions with some math on top of your base resolution.
Using the modulo operator to quantize integer values, it works by converting the modified resolution integer to a 4 digit string value.
Use the function within your own scripts to call funny resolutions otherwise difficult to calculate.
You cannot add series expressions to the resolution value since pine does not allow "series" as a resolution for a security call
However, you could easily stack a crapload of these together and use an expression to switch the referenced security function for your purposes.
This is the raw timeframe output as integer, not string.
To go back to string outputs (for use in security calls etc) unslash line 52 //resvalue
For those interested in the verbose version of the timeframe mod function, showing all the steps, here is a pastebin:
pastebin.com
Cheers! Drop a line / comment if you enjoy or have any questions on how to integrate this into your script@!
The Modulo operator is so much fun!
Heffae Resolution CommanderThis is a script to call resolutions with some math on top of your base resolution.
THIS IS NOT AN INDICATOR TO USE ON A CHART!!! The resolution call function is really useful for your own scripting ideas!
Using the modulo operator to quantize integer values, it works by converting the modified resolution integer to a 4 digit string value.
The function within this script is what is valuable, use it within your own scripts to call funny resolutions otherwise difficult to calculate.
You cannot add series expressions to the resolution value since pine does not allow "series " as a resolution for a security call
However, you could easily stack a crapload of these together and use
an expression to switch the referenced security function for your purposes.
The SMA and plot overlay are just there to show a visual example of how the function works.
You can view the raw timeframe output integer by getting rid of tostring(x) and // out the security calls,
plotting the raw function outputs.
For those interested in the verbose version of the timeframe mod function, showing all the steps, here is a pastebin:
pastebin.com
Cheers! Drop a line / comment if you enjoy or have any questions on how to integrate this into your script@!
The Modulo operator is so much fun!
CM_Ultimate_MA_MTF_V2 with Alert Long and Short Hello All,
Here is a scirpt of ChrisMoody modified with the alerts of purchases and sales.
I just have a problem with automation. At the bottom of my script my alerts "Buy1" and "Sell2" give alerts constantly and I wish to have a single alert before the order is completed. Before "Sell1" or Buy2 ".
I found the function "barstate.isfirst" that could possibly work?
Does anyone have an idea ? :)
Script functionality test - work in progress (2RS + BB + MA)This is the first script I've written. Its sole purpose is to make me learn a bit of pine script. Its not intended to trade live.
Feel free to modify it if you wish and let me know if you do it. Also any comments are welcome!
Also i need help in two things:
1. Im unable to print the "in-strategy" rsi on chart
2. I want to ignore the first buy signal after each sell. I was looking to ad a counter to the signals but im unable to do it.
Any help will be greatly appreciated!
EMAcrossover_RSI Buy/sell signal-TRXBTC_15min by rajista EMAcrossover_RSI Buy/sell signal Strategy
To be used in combination with Alerts script, both can be added to your tradingview charts (Chart time-frame should be set to 15min) like you add any other simple indicator.
Add this script to your favorites and once you have been granted access, you will be notified in your Tradingview notifications section, then you can go ahead and add these two scripts into your charts from your favorite section of Indicator menu in Tradingview.
Benefits of this strategy:
1> Fully automated buy/sell signals 24x7
2>Your trades will always be based on a certain entry and exit plan.
3>No emotions involved with these trading calls, so no chance of FOMO buying/Panic Sell
4>You can fully customize the settings with a simple click(customization details given below)
5>Its completely free of cost!!!
There are two parts of this automated trading call system:
1>Strategy script- Gives the buy/sell signals based on the settings provided.
2>Alert script- Gives Alert notifications in tradingview when a buy/sell call is made.
Principle of working is very simple to understand:
Stragey script makes:
Buy call - When the 9EMA crosses above the 21EMA or RSI level-20 is reached in 15min-Chart.
Sell call -When 9EMA crosses below the 21EMA or RSI level-70 is reached in 15min-Chart.
Above values of EMA's and RSI are default values , which can be changed easily in settings panel of Strategy script.
Alert Script allows you to add Alerts when these buy/sell calls are made.
To create a Buy call alert:
1> Click on the create alert icon in your chart (top-centre)
2>Click on Condition -drop down button and select EMAcross_rsi_Alerts
3>Below that bar you will see another bar titled "Buy"-click on its drop down menu and select "Crossing Down"
4>Below that bar right next to Value change 0 to 0.9.
5>Set expiration date for your alerts as per your wish
6>Ensure "Show Popup" and "Play sound" is checked
7>You can check option of sending the alert to your email also.
Finally click on create.
To create Sell Alert:
Repeat same process, except that, after step 2- Do this- change the "long" option to "short" by clicking on the drop down menu right next to the first bar.
Click on create, Finally both of your automated buy/sell call alerts will be configured.
I know its been 2-3 days since i tweeted about this strategy and now i am making it available, you can understand i had to put in a lot of working hours, towards creating the source code for the strategy script and then for alerts script and even more so towards finding the perfect default settings which can be used straight away by anyone, even if you are new in crypto trading, apart from the time which i dedicate to analyse charts and pass on the knowledge/info to you all.
My next post will be even more helpful to you people as i am currently testing "fully automated trading" yea you heard that right!! - This system will trade 24x7 for you guys/girls no matter wherever you are either you are sleeping or watching a movie, your trades would still be getting executed with a proper entery-exit plan on a crypto exchange.
Having problems setting up alertsHi, I have overlayed the script I have prepared previously and figured out how to set alerts although they don't seem to match up correctly with my strategy.
Could anyone please help me fix the problem? It seems to be revolving around my exit conditions.
Thanks in advance.
K
Volume & Intraday ScriptI am still learning pinescript, and part of this was created using the Pine Script language reference manual. This includes looking at the time series, a fixed length, and the default intraday_loss variables. This also includes the basic fixed lengths for an swma (Symmetrically weighted moving average) and the script to start creating a strategy. All in all this is just a basic sample of pinescript that you can customize for your trading needs. This can work with Cryptocurrency but these moving averages usually work more efficiently for forex.
Renko CandlesThis is a script to place Renko candles on your chart alongside another candle type or more importantly, using the variables from this script, you can build a strategy using Renko candles that will depict true/proper entries and exits in a strategy when using the backtest feature.
We hope this helps!
Pine Script Tutorial #2In this second tutorial we build upon the previous tutorial. We add color shading for each different day and highlight Wednesday.
The idea here is to manually count if on Wednesdays close is bigger then open.
Hope it helps.
Feel free to comment.
MartinMystere
My Tutorial #1If you are just like me and cant just get your head around pine script, I have created this simple code so you get the main concept.
Unfortunately there are no good step by step tutorials out there teaching scripting.
Hope this helps.
Comments are welcome.
MatinMystere
15 Minute Gold Trend-Following StrategyThis is the main strategy that I will be forward testing on demo for a month or two, then making it an EA in MetaTrader4
You can see the code for yourself this time, all the strategy is, is a crossover of various moving averages.
Commission included, $10,000 account.
Results over the past 3 months, beginning in January 2017.
MAster Gold StrategyVersion 3 for you guys, just add to favorites and you can use.
Only 36 trades since 2017, since that is when the backtesting began.
I made the commission more realistic, now it is about 37 pips per trade.
Only works on gold, (XAUUSD).
Trend Following as you can see.
1 contract size, 1 trade at a time, good proof of how being correct less than a third of the time can still bring you in a lot of profits.
Essentially, the net profit will be close to $8000, or 80%, as a long position on XAUUSD is currently running, and when it is closed, the profit will go up.
Imagine that, 72% profit on your account in 3 months?
(Hint: add the indicator to your favs, pull up the 30 minute gold chart)
Updated Gold Strategy - Trend Following Script v4.0This strategy improves on the latest one that I posted in several ways.
the %profit is reduced by 3%
Success rate reduced by 2%
Drawdown decreased by half (from 40% to 20%)
Average trade $ increased by $500