This 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.
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.