OPEN-SOURCE SCRIPT
Cập nhật Pong

Experience PONG! The classic arcade game, now on your charts!
With this indicator, you can finally achieve your lifelong dream of beating the Markets. . . at PONG!
Pong is jam-packed with features! Such as:
This indicator is solely a visualization, it serves simply as an exercise to depict what is capable through PineScript. It can be used to re-skin other indicators or data, but on its own, is not intended as a market indicator.
With that out of the way...
> PONG
The Pong indicator is a recreation of the classic arcade game Pong developed to pit the markets against the cold hard logic of a CPU player.

Given the lack of interaction that is capable, the game is not played in the typical sense, by a player and computer or 2 players.
This version of Pong uses the chart price movements to control the "Market" Paddle, and it is contrasted by a (not AI) "CPU" Paddle, which is controlled by its own set of logic.
> Market Paddle
The Market Paddle is controlled by a data source which can be input by the user.
By default (Auto Mode), the Market Paddle is controlled through a fixed length Donchian channel range, pinning the range high to 100 and range low to 0. As seen below.

This can be altered to use data from different symbols or indicators, and can optionally be smoothed using multiple types of Moving Averages.
In the chart below, you can see how the RSI indicator is imported and smoothed to control the Market Paddle.

Note: The Market Paddle follows the moving average. If not desired, simply set the "Smoothing" input to "NONE".
> CPU Paddle
In simple terms, the CPU Paddle is a handicapped Aimbot.
Its logic is, more or less, "move directly towards the ball's vertical location".
If it were allowed to have full range of the screen, it would be impossible for it to lose a point. Due to this, we must slow it down to "play fair"... as fair as that may be.
The CPU Paddle is allowed to move at a rate specified by a certain Percent of its vertical width. By default, this is set to 2%.
When a point is scored, the CPU paddle maintains its position, similar to the original Pong game, the paddles were controlled solely by the raw output of the controllers and did not reset.
> Ball
At the start of each point, the ball begins at the center of the screen and moves in a randomly determined angle at its base speed.
The direction is determined by the player who scored the last point. The loser of the last point "serves" the ball.
Given the circumstances, serving is a gigantic advantage. So the loser serving is just another place where the Market is given an advantage.
The ball's base speed is 1, it will move 1 (horizontal) bar on each update of the script. This speed can "technically" increase to infinity over time, if given the perfect rally. This is due to the hit logic as described below.
Note: The minimum ball speed is also 1.
> Bonk Math
When the ball hits a paddle, essentially 3 outcomes can occur, each resulting in the ball's direction being changed from positive to negative.
The central 60% of each paddle produces a basic bounce. The special actions are determined by the trajectory of the ball and location on the paddle.
> Custom Mode
As stated above, the script loads in "Auto Mode" by default. While this works fine to simply watch the gameplay, the Custom Mode unlocks the ability to visualize countless possibilities of indicators and analyses playing Pong!
In the chart below, we have set up the game to use the NYSE TICK Index as our Market Player.
Therefore, we have set up Pong to use Ticker USI:TICK and set the Upper Boundary to 1000 and Lower Boundary to -1000. With this method, the paddle is directly controlled by the overall (NYSE) market behaviors.

As seen in a chart earlier, you can also take advantage of the Custom Mode to overlay Pong onto traditional oscillators for use anywhere!
> Styles
This version of Pong comes stocked with 5 colorways to suit your chart vibes!

> Pro Tips & Additional Information
- This game has sound! For the full experience, set alerts for this indicator and a notification sound will play on each hit!*
*Due to server processing, the notification sounds are not precisely played at each hit. :(
- In auto mode, decreasing the length used will give an advantage to the market, as its actions become more sporadic over this window.
- The CPU logic system actually[/i ]allows the market to have a "technical" edge, since the Market Paddle is not bound to any speed, and is solely controlled by the raw market movements/data input.
- This type of visualization only works on live charts, charts without updates will not see any movement.
- Indicator sources can only be imported from other indicators on the same chart.
- The base screen resolution is 159 bars wide, with the height determined by the boundaries.
- When using a symbol and an outside source, be mindful that the script is attempting to pull the source from the input symbol. Data can appear wonky when not considering the interactions of these inputs.
There are many small interesting details that can't be seen through the description. For example, the mid-line is made from a box. This is because a line object would not appear on top of the box used for the screen. For those keen eye'd coders, feel free to poke around in the source code to make the game truly custom.
Just remember:
The market may never be fair, but now at least it can play Pong!
Enjoy!
With this indicator, you can finally achieve your lifelong dream of beating the Markets. . . at PONG!
Pong is jam-packed with features! Such as:
- 2 Paddles
- A moving dot
- Floating numbers
- The idea of a net
This indicator is solely a visualization, it serves simply as an exercise to depict what is capable through PineScript. It can be used to re-skin other indicators or data, but on its own, is not intended as a market indicator.
With that out of the way...
> PONG
The Pong indicator is a recreation of the classic arcade game Pong developed to pit the markets against the cold hard logic of a CPU player.
Given the lack of interaction that is capable, the game is not played in the typical sense, by a player and computer or 2 players.
This version of Pong uses the chart price movements to control the "Market" Paddle, and it is contrasted by a (not AI) "CPU" Paddle, which is controlled by its own set of logic.
> Market Paddle
The Market Paddle is controlled by a data source which can be input by the user.
By default (Auto Mode), the Market Paddle is controlled through a fixed length Donchian channel range, pinning the range high to 100 and range low to 0. As seen below.
This can be altered to use data from different symbols or indicators, and can optionally be smoothed using multiple types of Moving Averages.
In the chart below, you can see how the RSI indicator is imported and smoothed to control the Market Paddle.
Note: The Market Paddle follows the moving average. If not desired, simply set the "Smoothing" input to "NONE".
> CPU Paddle
In simple terms, the CPU Paddle is a handicapped Aimbot.
Its logic is, more or less, "move directly towards the ball's vertical location".
If it were allowed to have full range of the screen, it would be impossible for it to lose a point. Due to this, we must slow it down to "play fair"... as fair as that may be.
The CPU Paddle is allowed to move at a rate specified by a certain Percent of its vertical width. By default, this is set to 2%.
Each update, the CPU Paddle can advance up or down 2% of its vertical width.The directional movement is determined based on the angle of the ball, and it's current position relative to the CPU Paddle's position. Given that it is not a direct follow, it may at times seem more... "human".
When a point is scored, the CPU paddle maintains its position, similar to the original Pong game, the paddles were controlled solely by the raw output of the controllers and did not reset.
> Ball
At the start of each point, the ball begins at the center of the screen and moves in a randomly determined angle at its base speed.
The direction is determined by the player who scored the last point. The loser of the last point "serves" the ball.
Given the circumstances, serving is a gigantic advantage. So the loser serving is just another place where the Market is given an advantage.
The ball's base speed is 1, it will move 1 (horizontal) bar on each update of the script. This speed can "technically" increase to infinity over time, if given the perfect rally. This is due to the hit logic as described below.
Note: The minimum ball speed is also 1.
> Bonk Math
When the ball hits a paddle, essentially 3 outcomes can occur, each resulting in the ball's direction being changed from positive to negative.
- Action A: Its angle is doubled, and its speed is doubled.
- Action B: Its angle is reversed, and its speed is decreased if it is going faster than base speed.
- Action C: Its angle is preserved, and its speed is preserved. "Basic Bounce"
The central 60% of each paddle produces a basic bounce. The special actions are determined by the trajectory of the ball and location on the paddle.
> Custom Mode
As stated above, the script loads in "Auto Mode" by default. While this works fine to simply watch the gameplay, the Custom Mode unlocks the ability to visualize countless possibilities of indicators and analyses playing Pong!
In the chart below, we have set up the game to use the NYSE TICK Index as our Market Player.
The NYSE TICK Index shows the number of NYSE stocks trading on an uptick minus those on a downtick. Its values fluctuate throughout the day, typically ranging between +1000 and -1000.
Therefore, we have set up Pong to use Ticker USI:TICK and set the Upper Boundary to 1000 and Lower Boundary to -1000. With this method, the paddle is directly controlled by the overall (NYSE) market behaviors.
As seen in a chart earlier, you can also take advantage of the Custom Mode to overlay Pong onto traditional oscillators for use anywhere!
> Styles
This version of Pong comes stocked with 5 colorways to suit your chart vibes!
> Pro Tips & Additional Information
- This game has sound! For the full experience, set alerts for this indicator and a notification sound will play on each hit!*
*Due to server processing, the notification sounds are not precisely played at each hit. :(
- In auto mode, decreasing the length used will give an advantage to the market, as its actions become more sporadic over this window.
- The CPU logic system actually[/i ]allows the market to have a "technical" edge, since the Market Paddle is not bound to any speed, and is solely controlled by the raw market movements/data input.
- This type of visualization only works on live charts, charts without updates will not see any movement.
- Indicator sources can only be imported from other indicators on the same chart.
- The base screen resolution is 159 bars wide, with the height determined by the boundaries.
- When using a symbol and an outside source, be mindful that the script is attempting to pull the source from the input symbol. Data can appear wonky when not considering the interactions of these inputs.
There are many small interesting details that can't be seen through the description. For example, the mid-line is made from a box. This is because a line object would not appear on top of the box used for the screen. For those keen eye'd coders, feel free to poke around in the source code to make the game truly custom.
Just remember:
The market may never be fair, but now at least it can play Pong!
Enjoy!
Phát hành các Ghi chú
Removed extra UDT :)Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Custom PineScript Development:
reciodev.com
reciodev.com
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Custom PineScript Development:
reciodev.com
reciodev.com
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.