Community ideas
Thinking in Pine - Time Series Special CasesHello Everyone,
Welcome back to "Thinking in Pine" short video series. In this session, we have discussed few special cases of time series variables and using historical operator within local scope.
If you have not watched our previous video - "Thinking in Pine - Time Series" , request you to do that before continuing this video.
🎲 Summary of our today's discussion
How historical operator works for variables defined inside an conditional block
How historical operator works for variables defined in a loop.
🎯 Example Program Used
// Time series for variables within a condition
varip showLogInLoop = true
if(bar_index%3 == 0)
specialBarIndex = bar_index
if(bar_index > last_bar_index-3 and showLogInLoop)
log.info('Current and Previous special bar index are : {0} and {1}', specialBarIndex, specialBarIndex )
showLogInLoop := false
// Time series of variables within a loop
arrayOfX = array.new()
arrayOfLastX = array.new()
for i = 1 to 5
x = i*10
arrayOfX.push(x)
arrayOfLastX.push(x )
if(barstate.islastconfirmedhistory)
log.info('Array of X : {0}', arrayOfX)
log.info('Array of last X : {0}', arrayOfLastX)
🎲 References:
Pine Script® User Manual - Execution Model
Pine Script® User Manual - Time Series
Pine Script® User Manual - History Referencing Operator
Pine Script® Reference Manual - History Referencing Operator
Thinking in Pine - var, varip and regular variablesThis is our first video session on "Thinking in Pine" series. Before we start, we want to explain a bit about our new initiative.
🎲 What is "Thinking in Pine"?
In our journey to empower the trading community, we're excited to introduce "Thinking in Pine," a series of concise, 5-10 minute videos dedicated to unraveling the complexities of Pine Script®. We have our own list of topics to be covered, and we will start releasing the videos one by one. However, if you're grappling with any aspect of Pine Script® or stuck on an implementation, we encourage you to reach out to us or drop a comment here. We aim to address your queries by breaking down challenging concepts or implementations into easily digestible content.
What kind of videos are covered in "Thinking in Pine"?
Pine Script® Focus: We try to keep our focus on Pine Script® concepts and implementations.
General Utility: We prioritize topics that offer broader learning value. Though it's challenging to quantify this, we'll use our judgment to select topics that benefit the wider audience.
Time-Efficient Demonstrations: Ideally, we want to keep our demonstrations to 5–10 mins of time.
We're here to demystify Pine Script®, one topic at a time, making it accessible for everyone from beginners to advanced users. Stay tuned for insightful sessions with "Thinking in Pine"!
🎲 Demonstrating var, varip and regular variables in Pine Script®
In this video, we have demonstrated the difference between var, varip and regular variables by using an example implementation of OBV indicator.
🎯 Logic of OBV Calculation
Start with the value 0
On each bar, add volume to the indicator if close price is higher than previous bar close price.
On each bar, remove volume from the indicator is close price is lesser than previous bar close price
🎯 Highlights
Regular variables are initialized separately on each bar and does not propagate value to next bar unless coded to do it.
var variables are initialized once and then can be reassigned any number of times using := operator . The variables declared as var will propagate the current values to the next bar.
varip variables are initialized once and then can be reassigned any number of times using := operator . varip will behave similar to var on historical bars. However, on real time bars, they are recalculated on every tick, and they remember the state of each tick.
🎯 Example Program Used
Here is the example program used in the demonstration.
//Plot built-in OBV value for reference
plot(ta.obv, "OBV Built In", color=color.yellow)
//Volume multiplied by +-1 based on change in close price compared to previous bar.
volumeBySign = math.sign(nz(ta.change(close), 0))*volume
//Obv calculation by using regular variable. Code need to access and add last bar value using obvByRegular
obvByRegular = 0.0
obvByRegular += nz(obvByRegular , 0) + volumeBySign
plot(obvByRegular, "OBV By Regular Variable", color=color.blue)
//Obv calculation using var variable. Since var variables propagate values to next bar,
// we do not need to use historical operator to get the last bar value
var obvByVar = 0.0
obvByVar += volumeBySign
plot(obvByVar, "OBV by var Variable", color = color.maroon)
//Obv implementation using varip. The OBV is calculated based on every tick. Histoical values will match the same as that of other implementation.
//However, in real time, the calculations are done based on the tick values
varip obvByVarip = 0.0
varip lastPrice = close
varip lastVolume = volume
if(barstate.isnew)
lastVolume := 0
obvByVarip += math.sign(close-lastPrice)*(volume-lastVolume)
lastPrice := close
lastVolume := volume
plot(obvByVarip, "OBV by varip Variable", color = color.purple)
🎲 References:
Pine Script® User Manual - Variable declarations
Pine Script® Reference Manual - var
Pine Script® Reference Manual - varip
Pine Script® User Manual - Operators
Live stream - Daily Pitch Int. with Darius Anucauskas Ep. 182Nikkei225,China50,ASX200,DJIA,S&P500,Nasdaq100,DAX40,FTSE100,DXY,Gold,Silver,Copper,WTIOil,NatGas,Cotton,Sugar,Bitcoin,BitcoinCash,Ethereum,Litecoin,Dogecoin,AUDUSD,AUDNZD,AUDCAD,NZDCHF,USDJPY,USDCAD,USDCHF,USDMXN,GBPUSD,GBPCHF,EURCHF,EURNZD,EURUSD.
Navigating the Markets with Fibonacci ChannelsToday we delve into the fascinating world of Fibonacci Channels, a powerful tool for traders looking to identify potential non-horizontal support and resistance levels in the market.
Throughout the video, we provide a step-by-step guide on how to place Fibonacci Channels on price charts, allowing you to visualize and understand their significance in identifying key price levels. We also showcase real-world examples to demonstrate how Fibonacci Channels can be used to find points of interest, such as trend reversals and price targets.
Furthermore, we discuss the integration of Fibonacci Channels with other technical indicators, providing insights into how this combination can enhance your trading strategy. By the end of this video, you will have a comprehensive understanding of Fibonacci Channels and the ability to confidently incorporate them into your trading approach. Get ready to unlock the potential of Fibonacci Channels and take your trading skills to the next level!
Live stream - Candlestick Analysis for Dynamic Scalping and Day The FX Evolution team are back with an advanced session! They're talking Multi-Time Frame Analysis for precise entry and exit decisions in both scalping and day trading scenarios, Candlestick Pattern Combinations & Volume Analysis with Candlesticks.
Rate Cut 1930 - Pattern Recognition: 30s vs Today In 1930, when the Fed cut interest rates, the market crashed further. In today's tutorial, we will be comparing the 30s and today’s market to identify some of their similarities.
Where exactly are interest rates’ direction pointing us?
As we may have read, many analysts are forecasting that there will be a few rate cuts in 2024. Is this the best option?
My work in this channel, as always, is to study behavioral science in finance, discover correlations between different markets, and uncover potential opportunities.
Micro Treasury Yields & Its Minimum Fluctuation
Micro 2-Year Yield Futures
Ticker: 2YY
0.001 Index points (1/10th basis point per annum) = $1.00
Micro 5-Year Yield Futures
Ticker: 5YY
0.001 Index points (1/10th basis point per annum) = $1.00
Micro 10-Year Yield Futures
Ticker: 10Y
0.001 Index points (1/10th basis point per annum) = $1.00
Micro 30-Year Yield Futures
Ticker: 30Y
0.01 Index points (1/10th basis point per annum) = $1.00
Disclaimer:
• What presented here is not a recommendation, please consult your licensed broker.
• Our mission is to create lateral thinking skills for every investor and trader, knowing when to take a calculated risk with market uncertainty and a bolder risk when opportunity arises.
CME Real-time Market Data help identify trading set-ups in real-time and express my market views. If you have futures in your trading portfolio, you can check out on CME Group data plans available that suit your trading needs www.tradingview.com
How to Quantify & Identify (real-time) a Trading RangeOne of the most challenging & frustrating tasks for a trader,
is to define with a rules-based (systematic) methodology,
and identify (on a real-time basis),
when a market is in a trading range.
Using the MACD-v both of these goals are achieved.
The market is defined as being as "Ranging"
(one of the Core 7 Range Rules/States)
when the MACD-v is between the -50 and 50 ranges,
for more than 25 bars consecutively.
Live stream - Week Ahead And What To Lookout For - Daily Pitch INikkei225, China50, ASX200, DJIA, S&P500, Nasdaq100, DAX40, FTSE100, DXY, Gold, Silver, Copper, WTI Oil, Wheat, Bitcoin, BitcoinCash, Ethereum, Ripple, Litecoin, Dogecoin,AUDUSD,AUDJPY,AUDCAD,NZDUSD,USDJPY,USDCAD, USDCHF,GBPUSD,GBPCHF,EURCHF,EURAUD,EURUSD
Create No Code Auto Trading Bot with Tradingview and OKXHello Everyone,
In this tutorial, we learn about how to create simple auto trading bot using tradingview alerts and OKX exchange built in integration mechanism.
Few exchanges have come up with this kind of direct integration from tradingview alerts to exchanges and as part of this tutorial, we are exploring the interface provided by OKX.
In this session, we have discussed
🎲 Preparation Steps
Preparing tradingview account
Webhooks are only available for essential plans and plus.
Enable 2FA in your tradingview account.
Preparing your OKX account
Create OKX account, and we prefer you do the initial tests under demo account before moving to active trading account.
Bots created in demo account will not appear in the active trading account. Hence, when switching to active account, you need to create all the setup again.
🎲 OKX Tradingview Interface Features
What is supported
Auto trading based on strategy signal
Custom signals - Enter Long, Exit Long, Enter Short, Exit Short
What is not supported:
Stop/Limit orders
Bracket orders/ Complex execution templates
🎲 Weighing Pros and Cons of Using Direct Interface rather than Third party integration tools
Pros
Latency is minimal as per our observation
Easy Integration with Tradingview and Pinescript Strategy Framework and no coding required
You save cost on third parties and also avoid one hop.
More secure as your data is shared between less number of parties.
Cons
No native support for Stop/Limit orders