What's Hot

    Learning a new language can be tough—especially for programmers. In my case, it was transitioning from Scratch to Python a few months ago.

    During the transition, I often found myself resorting to Scratch even when creating new projects. The truth is that when you have fully discovered a path to great things on one platform, it feels fruitless to backtrack and permanently abandon a familiar routine. One question nagged me specifically: If I pull back the curtains on this new project and let go of the habitual, will Python deconstruct my previous learning? I was always worried that once I started a Python project, I would have trouble moving forward. Once I met a roadblock, I would have no way of going back to my previous prestige… stranded in uncharted territory. 

    I have slowly built up the courage to venture across the dreadful bridge—with a trail of bread crumbs in the wake of danger. I started my TradingView project with two important files: one for Scratch and one for Python. (TradingView is a popular trading platform with advanced charting capabilities; my goal was to replicate its basic features.)

    Starting from translating Open, High, Low, Close, and Volume (OHLCV) data files from CSV/TXT to interpretable variables, I quickly created a system on Scratch to split lines by commas and, subsequently, a script to extract the meat by sorting the segments. Still barren on Python, I surged ahead with my rooted knowledge of Scratch—one candle that would seamlessly duplicate in order to match visible candles. Not only that, the program would plot candles and wicks that automatically scaled to optimal settings—with detection of average candle length, and offsets. Needless to say, I added other features to Scratch for visual appeal and to enable users to easily toggle preferences.

    In a frenzy, my Scratch counterpart had already turned into a visual masterpiece, and while I had started my Python version, I thought nothing could compare to what was already there. But oblivious to Python Packages—a trademark that implements other tools created by others—I overestimated the effort required for Python. 

    We can get surprisingly close to a TradingView-style experience in Python by combining a web dashboard framework with an interactive charting library. A common approach is Plotly + Dash: I loaded the OHLCV data into a pandas DataFrame, rendered candlestick charts with Plotly, and served them in a Dash app running in my Chrome browser. Plotly offers functions such as zoom in/out and a range slider to shift the visible horizon, while Dash provides the UI layer (sliders, dropdowns, buttons) to change the symbol, time window, or indicators.

    Though I hated the idea of using code written by others, the quick, easy solution was a good representation of Python’s accessibility-oriented theme. Everything could be done fast—as long as it had already been. The nature of Python isolated the project, which is what I loved most about programming—the process of discovery and personalization—but nevertheless, I was finished with what I wanted to achieve.

    Python code on the right, trading view output on the left

    In the end, taking a look at the bigger picture, while a Python program definitely has more room to expand and scale up, Scratch provides a great platform for a deep understanding of the different blocks, thereby fostering innovation and adaptability. 

    Share.

    Leave A Reply