Pine Script Algo Limitations For TradingView Coding

There are several PineScript strategies available for traders. The best Pine Scripts offer indicators and signals that are testable through backtesting or forward testing. These scripts automate the decision making process and remove emotion from trading. As an algo trader, you can develop your own algorithms, indicators, and strategies. These unique scripts can power your bots and signals for trading regularly. However, there are some limitations to TradingView’s Pine Script and Pine Editor. In this post, we’ll share some of the main limitations and strategies associated with Pine Script development.

Pine Script Bid-Ask Spread

The Pine Script development environment does not have access to live bid/ask prices. Unless TV changes this, or introduces user permissions that we are not aware of, currently you will have to code a workaround. These are some of the bid-ask alternatives that we found:

  • Calculate your bid-ask based on price open and close of 1 min time frame
  • Calculate the spread based on close of candle and open of next candle
  • Calculate spread of price between two time intervals, for ex. 30min or 30 seconds

Here’s an example of the price close comparison:

// Conditions
priceChangeUp = (close / close[1] - 1) >= priceMoveThreshold
priceChangeDown = (close / close[1] - 1) <= -priceMoveThreshold
spreadCondition = (high - low) > spreadThreshold

While you can not directly calculate the bid ask spread from TradingView, you can develop a workaround using current price. Note: The Bid/Ask price label exists. So, if you can import the data some other way, it can be plotted on the chart.

Currently, you can plot bid-ask spread as an indicator with TC2000. Additionally, in the future, we’ll look into options for writing bid-ask algo bots with MT4 or Interactive Brokers terminal.

Author of this article

Picture of Chad Axelrod

Chad Axelrod

Chad Axelrod is a professional forex trader and market analyst with 15+ years of industry experience. Starting his career on Wall Street, he quickly realized his passion for writing and finance, working with a national publication for a decade. Through his posts, reviews, and broker comparisons - he believes beginner and seasoned traders should make informed decisions while selecting a broker. Leading the team at BrokerageToday.com, Chad prioritizes publishing unbiased and transparent reviews for traders in the industry.

Free Access To 100+ Trading Algos

What Is Your Trading Experience?

Free Access To 100+ Trading Algos

What Is Your Trading Experience?