script (⏱,💰)

script (⏱,💰)

Is it reliable to use LLM for technical analysis?

This article is aimed at readers who have a basic understanding of cryptocurrency trading and are interested in using AI for technical analysis.

1. Background#

There has been an increase in discussions about contract trading in the community recently, indicating potential market demand. Considering that large language models (LLMs) have surpassed the average programmer in the field of programming, I have developed an AI trading assistant bot called CoinGlass on the MyShell platform to verify the capabilities of LLM in the trading field.

CleanShot 2024-08-05 at 10.54.03@2x

The name "CoinGlass" is derived from the data platform coinglass.com, which provides comprehensive contract trading indicators. When using CoinGlass, you need to upload a screenshot of CoinGlass for analysis by the bot. In addition, the bot also supports the analysis of other technical indicator charts, such as Tradingview or exchange charts.

MyShell is a Web3 AI platform that allows users to create, share, and profit from AI applications. Creators can develop and deploy AI applications quickly using the powerful LLM without the need for coding.

The bot is designed as an expert in cryptocurrency derivatives trading. After extensive backtesting and iterative optimization, it performs well in most cases. Here is a short position recommendation for SOL when it was still above 150 on August 4th: https://app.myshell.ai/share/AjMbEj

Note: Financial market trends are unpredictable. Although the recommendations are provided by AI, users should always be cautious of risks.

2. Design Concept#

The effectiveness of technical indicators varies depending on the situation. You need to have a deep understanding of the indicators and choose them based on different trading strategies.

Top traders usually focus on controllable factors and risk management in the present, rather than predicting the uncertain future market trends.

When designing prompts, I referred to the experiences of multiple traders and selected several commonly used cryptocurrency trading indicators. The indicator parameter settings are consistent with the default interface of the largest cryptocurrency exchange, Binance.

The main problems encountered during development were:

  • Minor differences in the same chart leading to inconsistent output results
  • Different language responses resulting in inconsistent output results
  • Difficulties in accurately identifying specific indicator values, especially the relationship between moving averages and prices
  • Inability to accurately interpret the meaning of abnormal indicators

After multiple iterations, the latest version uses the Chain of Thought (CoT) technique to analyze the charts in the following steps: 1. Read the chart 2. Identify indicator features 3. Analyze the direction 4. Find support and resistance levels 5. Calculate the risk-reward ratio 6. Assess the feasibility of the trade 7. Quantify the indicator scores 8. Calculate the total score 9. Provide trading recommendations.

All subsequent analyses are based on the indicator data obtained in the first step to ensure the consistency and traceability of the results.

The bot uses the Claude Sonnet 3.5 model with a temperature parameter set to 0 to ensure consistent output results for the same input.

3. Pros and Cons of LLM in Technical Analysis#

During development, I found the following pros and cons worth noting when using LLM for technical analysis:

Pros#

  • Image pattern recognition: LLM has been exposed to a large amount of image data during training, so it performs well in pattern recognition of trading charts such as candlestick charts.
  • Understanding of technical indicators: It can explain common technical indicators and provide insights.
  • Generalization ability: It can interpret various charts and indicators, answer diverse questions, and support multi-language output.
  • Ease of use: It is as simple to use and build as chatting.

Cons#

  • Need for guidance: For some technical indicators, you must explicitly provide specific hidden information to LLM. For example, when there is a divergence between CVD and price, there are different interpretations, but LLM often fails to discover potential signals.
  • Illusions: Without using the Chain of Thought (CoT) method for step-by-step analysis, inconsistent or incorrect results may be generated. When using different language outputs, it sometimes leads to inconsistent trading recommendations.
  • Automated trading: Unless customized development is done locally, it is not possible to connect to live trading for automated trading.
  • Difficulties in backtesting: Compared to traditional quantitative trading, evaluating the effectiveness of models and prompts is more complex and usually requires a large amount of manual testing.

4. User Guide#

how to use

The diagram above shows the basic operation process: open CoinGlass, take a screenshot, provide the image and text to the bot, and then send it. However, there are many details to pay attention to in actual use.

First, open CoinGlass at https://www.coinglass.com/tv/Binance_BTCUSDT and register (registration is required to save layouts).

4.1 Set up the chart#

live layout

It is recommended to add additional indicators besides important contract data. Here are my choices for indicators (click "CoinGlass - Indicator" and "Indicators" in the top menu to select other indicators):

  • Main Price: Basic category. Choose 1D, 4H, 1H.
  • Moving Averages (MA): Trend category. Choose 7/25/99, consistent with Binance's default.
  • Volume: Basic category. Default Binance SMA 9.
  • Aggregated Spot Cumulative Volume Delta (<CoinGlass>Aggregated Spot Cumulative Volume Delta): Volume category, abbreviated as CVD. Generally, the spot market leads the futures market, so choose the CVD of the spot market. Different currencies require different exchanges. For example, during the rebound of BTC on July 26-27, 2024, the CVD of CoinBase was decreasing, while the CVD of Karken was increasing, indicating that the spot buying on Karken led to the price increase. Click ⚙️ to modify the chart, and I usually select Binance + CoinBase.

CVD setting

  • Funding Rates: Contract category.
  • Long/Short Ratio (Accounts): Contract category. You can also choose Top Trader Ratio (Accounts).
  • Open Interest (Candles): Contract category.
  • Stochastic RSI: Oscillator category. Default settings are 14 14 3 3, consistent with Binance.
  • Aggregated Liquidations: Contract category.
  • ATR: Trend strength category, default 14.
  • Aggregated Spot Orderbook Liquidity Delta (±1%): Order flow category. Reference for depth when opening a position.

These indicators cover basic indicators, important contract indicators, one moving average category, one volume category, one oscillator category, one trend strength category, and one order flow category, allowing the AI to have a comprehensive judgment of the market.

It is also recommended to make the following settings by clicking the ⚙️ in the lower right corner:

  • Open Symbol last price label to avoid not being able to read the latest value.
  • Close Indicator value labels to reduce text in the screenshot and allow the AI to focus more on changes rather than numerical values.

setting 1

  • Open High and low price labels and Price line to display high and low points, which are important resistance and support levels.
  • Close Count down to bar close to reduce unnecessary distracting information.

setting 2

After setting up, click "Save" in the menu bar to save the layout.

4.2 Take a screenshot#

When taking a screenshot, make sure the time span is not too small or too large. Right-click and select "Reset chart view" if needed.

Reset chart view

Then use the screenshot function of the webpage or a screenshot tool to manually take a screenshot. I usually use the "Take better screenshots and GIFs" software on MacOS to manually take screenshots.

Copy image

Ensure that the text and lines in the screenshot are clear and legible. If the bot's first step of reading the chart provides incorrect indicator numbers, consider whether the screenshot is clear and concise enough. Different language interfaces can also cause recognition errors.

Here is a reference for a complete screenshot.

screenshot ref

4.3 Interact with the LLM#

Visit the CoinGlass MyShell bot at https://app.myshell.ai/bot/rYbENf/1713925324, click "+" to add the screenshot, or press Ctrl+V to paste the screenshot, and then send it.

CleanShot 2024-08-05 at 11.22.37@2x

When interacting with the bot:

  • Minimize irrelevant information: Provide the chart directly and avoid adding unnecessary text to prevent it from affecting the bot's judgment.
  • Use English: To maintain consistency in judgment, it is recommended to directly use English to interact with the bot.
  • Clear memory: Before analyzing different currencies, it is recommended to click the "Clear memory" button to clear the previous conversation history to avoid the bot misunderstanding it as a multi-timeframe analysis.

Clear memory

  • Multiple timeframe analysis: Have a continuous conversation and provide charts from different timeframes to obtain a comprehensive view.
  • Respond to market changes: When there are significant changes in the market, provide the latest chart and current position information to request updated recommendations from the bot.

add text

4.4 Establishing a Position#

To optimize the risk-reward ratio, I use the following strategy:

  1. Analyze the charts of the 1-day and 4-hour timeframes. When the trends are consistent, determine the long or short direction.
  2. Observe the Stochastic RSI indicator on the 1-hour chart:
    • Long condition: Oversold (both lines above 80).
    • Short condition: Overbought (both lines below 20).
    • More robust entry signals:
      a) Fast line crossing over slow line in Stochastic RSI.
      b) Divergence between Stochastic RSI and price.
      Observe the chart below. After adding the daily cycle line, this strategy can almost daily identify overbought or oversold trading opportunities.

Stoch RSI

  1. When the Stochastic RSI reaches the target, send the 1-hour chart to the bot with the text "find entry to LONG/SHORT", and it will provide you with entry points. You can also directly send the chart without additional text.
  2. Place the order manually and set the take profit and stop loss levels.

Things to note:

  • Adjust the strategy based on personal trading habits.
  • Be patient and wait for the best entry opportunities.
  • Optimize entry points to increase profit potential under the premise of confirming the correct major trend.
  • In a one-sided volatile market, the take profit and stop loss levels provided by the 1-hour chart are relatively conservative. You can use the 4-hour or 1-day chart for reference.

4.5 How to Backtest#

If you need to backtest, there should be no latest values on the chart. There are two methods:

Method 1#

  1. Close all "Values in status line" for indicators.
    CleanShot 2024-08-05 at 11.48.28@2x

  2. Open "Indicators value labels".
    CleanShot 2024-08-05 at 11.49.55@2x

  3. Save the layout.

  4. Drag the chart to the desired time, the last candle for backtesting. Take a screenshot.

Method 2#

  1. Drag the chart to the desired time, the last candle for backtesting.
  2. Move the mouse to any indicator position on the last candle. When a vertical dashed line appears, the displayed indicator values are historical values.
  3. Take a screenshot using a third-party tool.

CleanShot 2024-08-05 at 12.06.57@2x

Notes for backtesting with multiple timeframes#

When conducting backtesting with multiple timeframes, it is important to pay attention to the corresponding time relationship between different period candles. Here are the specific correspondences:

  • Daily candles correspond to 20:00 of the next day's 4-hour candles and 23:00 of the 1-hour candles. If it is Beijing time (UTC+8), it would be 04:00 and 07:00 of the next day.
  • 04:00 of the 4-hour candles corresponds to 07:00 of the 1-hour candles.
  • 09:00 of the 1-hour candles corresponds to 09:45 of the 15-minute candles.

This correspondence ensures the correct synchronization of data from different timeframes during the backtesting process, which helps obtain more accurate backtesting results.

5. Conclusion#

LLM has the potential to enhance trading strategies and profitability by providing in-depth insights and trend recognition capabilities. Its user-friendly features make it easy for ordinary traders to use.

In the future, I will continue to improve the design of prompts and explore other use cases to further improve the effectiveness of AI in trading. The use of emerging models such as Claude Opus 3.5 is expected to bring better results.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.