Enhance AI analysis with professional trading assistant approach

- Updated AI prompts to behave like professional proprietary desk trader
- Enhanced take profit display with RSI/OBV expectations and detailed descriptions
- Added timeframe risk assessment with leverage recommendations
- Implemented comprehensive indicator analysis (RSI, VWAP, OBV, MACD)
- Added alternatives section with tighter stops and scaled entry options
- Enhanced test script output for better trade setup visualization
- Improved confirmation triggers with specific technical signals
- Added cross-layout consensus analysis for multi-screenshot comparison
- Cost-effective analysis using gpt-4o mini (~/usr/bin/bash.006 per analysis)
This commit is contained in:
mindesbunister
2025-07-13 17:53:35 +02:00
parent 4965a3d0af
commit 94ed58f781
2 changed files with 278 additions and 56 deletions

View File

@@ -29,8 +29,18 @@ export interface AnalysisResult {
rationale: string
}
takeProfits?: {
tp1?: { price: number; description: string }
tp2?: { price: number; description: string }
tp1?: {
price: number
description: string
rsiExpectation?: string
obvExpectation?: string
}
tp2?: {
price: number
description: string
rsiExpectation?: string
obvExpectation?: string
}
}
riskToReward?: string
confirmationTrigger?: string
@@ -38,6 +48,24 @@ export interface AnalysisResult {
rsi?: string
vwap?: string
obv?: string
macd?: string
crossLayoutConsensus?: string
}
layoutComparison?: {
aiLayout?: string
diyLayout?: string
consensus?: string
divergences?: string
}
timeframeRisk?: {
assessment?: string
positionSize?: string
leverageRecommendation?: string
}
alternatives?: {
tigherStopOption?: string
scaledEntry?: string
invalidationScenario?: string
}
}
@@ -50,9 +78,35 @@ export class AIAnalysisService {
const imageBuffer = await fs.readFile(imagePath)
const base64Image = imageBuffer.toString('base64')
const prompt = `You are a technical chart analysis expert. Please analyze this TradingView chart image and provide objective technical analysis data.
const prompt = `You are now a professional trading assistant. You behave with the precision and decisiveness of a top proprietary desk trader. No vagueness, no fluff.
**Important**: This is for educational and research purposes only. Please analyze the technical indicators, price levels, and chart patterns visible in the image.
**TRADING ANALYSIS REQUIREMENTS:**
1. **TIMEFRAME RISK ASSESSMENT**: Based on the timeframe shown in the screenshot, adjust risk accordingly:
- Lower timeframes (1m-15m): Higher risk, use at least 10x leverage for scalps, smaller position sizes
- Higher timeframes (4H+): Lower risk, larger position sizes, swing trades
- 5-minute scalps require at least 10x leverage
2. **BE 100% SPECIFIC** - Provide exact levels with clear rationale:
**ENTRY**: Exact price level (with ± buffer if needed)
- Rationale: e.g., "Rejection from 15 EMA + VWAP confluence near intraday supply"
**STOP-LOSS**: Exact level (not arbitrary)
- Explain WHY it's there: "Above VWAP + failed breakout zone"
**TAKE PROFITS**:
- TP1: Immediate structure (previous low/high, key level)
- TP2: Extended target if momentum continues
- Mention expected RSI/OBV behavior at each TP zone
3. **RISK-TO-REWARD**: Show R:R ratio with dollar amounts if possible
4. **CONFIRMATION TRIGGERS**: Exact signals to wait for:
- Specific candle patterns, indicator crosses, volume confirmations
- RSI behavior: "If RSI crosses above 70 while price is under resistance → wait"
- VWAP: "If price retakes VWAP with bullish momentum → consider invalidation"
- OBV: "If OBV starts climbing while price stays flat → early exit or reconsider bias"
Examine the chart and identify:
- Current price action and trend direction
@@ -64,7 +118,7 @@ Examine the chart and identify:
Provide your analysis in this exact JSON format (replace values with your analysis):
{
"summary": "Objective description of what you observe in the chart",
"summary": "Objective technical analysis with timeframe risk assessment and specific trading setup",
"marketSentiment": "BULLISH|BEARISH|NEUTRAL",
"keyLevels": {
"support": [list of visible support price levels as numbers],
@@ -72,26 +126,47 @@ Provide your analysis in this exact JSON format (replace values with your analys
},
"recommendation": "BUY|SELL|HOLD",
"confidence": 75,
"reasoning": "Technical analysis reasoning based on indicators and price action",
"reasoning": "Specific technical analysis reasoning with exact rationale for each level",
"entry": {
"price": 150.50,
"buffer": "±0.25",
"rationale": "Technical reasoning for entry level"
"rationale": "Specific technical reasoning: rejection from 15 EMA + VWAP confluence near intraday supply"
},
"stopLoss": {
"price": 148.00,
"rationale": "Technical reasoning for stop level"
"rationale": "Exact reasoning: Above VWAP + failed breakout zone"
},
"takeProfits": {
"tp1": { "price": 152.00, "description": "First target reasoning" },
"tp2": { "price": 154.00, "description": "Second target reasoning" }
"tp1": {
"price": 152.00,
"description": "Immediate structure target with indicator expectations",
"rsiExpectation": "RSI should reach 60-65 zone",
"obvExpectation": "OBV confirming momentum"
},
"tp2": {
"price": 154.00,
"description": "Extended target if momentum continues",
"rsiExpectation": "RSI approaching 70+ overbought",
"obvExpectation": "OBV making new highs with price"
}
},
"riskToReward": "1:2",
"confirmationTrigger": "Technical signal to watch for",
"confirmationTrigger": "Specific signal: Bearish engulfing candle on rejection from VWAP zone with RSI under 50",
"indicatorAnalysis": {
"rsi": "RSI level and interpretation",
"vwap": "VWAP relationship to price",
"obv": "Volume analysis if visible"
"rsi": "Specific RSI level and precise interpretation with action triggers",
"vwap": "VWAP relationship to price with exact invalidation levels",
"obv": "Volume analysis with specific behavioral expectations",
"macd": "MACD signal line crosses and momentum analysis"
},
"timeframeRisk": {
"assessment": "Risk level based on detected timeframe",
"positionSize": "Suggested position sizing based on timeframe",
"leverageRecommendation": "Specific leverage suggestion for the timeframe"
},
"alternatives": {
"tigherStopOption": "Alternative setup with tighter stop if original SL is too far",
"scaledEntry": "Scaled entry approach if better levels become available",
"invalidationScenario": "What price action would invalidate this setup completely"
}
}
@@ -196,35 +271,49 @@ Return only the JSON object with your technical analysis.`
return 'Unknown Layout'
}).join(' and ')
const prompt = `You are a professional technical chart analysis expert. I'm providing you with ${filenames.length} TradingView chart screenshots from different layouts: ${layoutInfo}.
const prompt = `You are now a professional trading assistant. You behave with the precision and decisiveness of a top proprietary desk trader. No vagueness, no fluff.
**IMPORTANT**: Please analyze ALL screenshots together to provide comprehensive trading advice. Compare the different layouts and use ALL available information to make the most informed recommendation.
I'm providing you with ${filenames.length} TradingView chart screenshots from different layouts: ${layoutInfo}.
**Analysis Requirements:**
1. Examine ALL charts for:
- Current price action and trend direction across all timeframes/layouts
- Key support and resistance levels visible in any chart
- Technical indicator readings (RSI, moving averages, volume, etc.)
- Chart patterns or formations
- Market structure elements
- Any divergences or confirmations between the layouts
**TRADING ANALYSIS REQUIREMENTS:**
2. **Cross-Layout Analysis**:
- Compare insights from different chart layouts
- Look for confirmations or contradictions between views
- Identify which layout provides the clearest signals
1. **TIMEFRAME RISK ASSESSMENT**: Based on the timeframe shown in the screenshots, adjust risk accordingly:
- Lower timeframes (1m-15m): Higher risk, use at least 10x leverage for scalps, smaller position sizes
- Higher timeframes (4H+): Lower risk, larger position sizes, swing trades
- 5-minute scalps require at least 10x leverage
2. **BE 100% SPECIFIC** - Provide exact levels with clear rationale:
**ENTRY**: Exact price level (with ± buffer if needed)
- Rationale: e.g., "Rejection from 15 EMA + VWAP confluence near intraday supply"
**STOP-LOSS**: Exact level (not arbitrary)
- Explain WHY it's there: "Above VWAP + failed breakout zone"
**TAKE PROFITS**:
- TP1: Immediate structure (previous low/high, key level)
- TP2: Extended target if momentum continues
- Mention expected RSI/OBV behavior at each TP zone
3. **RISK-TO-REWARD**: Show R:R ratio with dollar amounts if possible
4. **CONFIRMATION TRIGGERS**: Exact signals to wait for:
- Specific candle patterns, indicator crosses, volume confirmations
- RSI behavior: "If RSI crosses above 70 while price is under resistance → wait"
- VWAP: "If price retakes VWAP with bullish momentum → consider invalidation"
- OBV: "If OBV starts climbing while price stays flat → early exit or reconsider bias"
5. **CROSS-LAYOUT ANALYSIS**:
- Compare insights from different chart layouts for confirmations/contradictions
- Use multiple perspectives to increase confidence
- Note which layout provides clearest signals
3. **Comprehensive Trading Setup**:
- Provide entry, stop loss, and take profit levels
- Include risk-to-reward analysis
- Suggest confirmation triggers
- Rate your confidence based on multi-layout consensus
6. **ALTERNATIVES**: If SL is far, offer tighter alternatives or scaled entries
**Response Format** (return only valid JSON):
{
"summary": "Comprehensive analysis of all charts including cross-layout insights and consensus",
"summary": "Comprehensive multi-layout analysis with timeframe risk assessment and cross-layout insights",
"marketSentiment": "BULLISH|BEARISH|NEUTRAL",
"keyLevels": {
"support": [array of support levels from all charts],
@@ -232,33 +321,54 @@ Return only the JSON object with your technical analysis.`
},
"recommendation": "BUY|SELL|HOLD",
"confidence": 85,
"reasoning": "Multi-layout technical analysis reasoning explaining how different charts confirm or contradict each other",
"reasoning": "Multi-layout technical analysis with specific rationale for each level and timeframe-adjusted risk assessment",
"entry": {
"price": 150.50,
"buffer": "±0.25",
"rationale": "Entry reasoning based on multiple chart analysis"
"rationale": "Specific technical reasoning: rejection from 15 EMA + VWAP confluence near intraday supply"
},
"stopLoss": {
"price": 148.00,
"rationale": "Stop loss reasoning considering all layouts"
"rationale": "Exact reasoning: Above VWAP + failed breakout zone"
},
"takeProfits": {
"tp1": { "price": 152.00, "description": "First target based on multi-chart analysis" },
"tp2": { "price": 154.00, "description": "Second target with cross-layout confirmation" }
"tp1": {
"price": 152.00,
"description": "Immediate structure target with RSI/OBV expectations",
"rsiExpectation": "RSI should reach 60-65 zone",
"obvExpectation": "OBV confirming momentum"
},
"tp2": {
"price": 154.00,
"description": "Extended target if momentum continues",
"rsiExpectation": "RSI approaching 70+ overbought",
"obvExpectation": "OBV making new highs with price"
}
},
"riskToReward": "1:2.5",
"confirmationTrigger": "Multi-layout signal confirmation to watch for",
"confirmationTrigger": "Specific signal: Bearish engulfing candle on rejection from VWAP zone with RSI under 50",
"indicatorAnalysis": {
"rsi": "RSI analysis across layouts",
"vwap": "VWAP analysis from multiple views",
"obv": "Volume analysis synthesis",
"crossLayoutConsensus": "How well different layouts agree on the signals"
"rsi": "Specific RSI level and precise interpretation with action triggers",
"vwap": "VWAP relationship to price with exact invalidation levels",
"obv": "Volume analysis with specific behavioral expectations",
"macd": "MACD signal line crosses and momentum analysis",
"crossLayoutConsensus": "Detailed comparison of how different layouts confirm or contradict signals"
},
"layoutComparison": {
"aiLayout": "Insights specific to AI layout",
"diyLayout": "Insights specific to DIY module layout",
"consensus": "Areas where both layouts agree",
"divergences": "Areas where layouts show different signals"
"aiLayout": "Specific insights and edge from AI layout analysis",
"diyLayout": "Specific insights and edge from DIY module layout analysis",
"consensus": "Exact areas where both layouts strongly agree with confidence boost",
"divergences": "Specific contradictions between layouts and how to resolve them"
},
"timeframeRisk": {
"assessment": "Risk level based on detected timeframe",
"positionSize": "Suggested position sizing based on timeframe",
"leverageRecommendation": "Specific leverage suggestion for the timeframe"
},
"alternatives": {
"tigherStopOption": "Alternative setup with tighter stop if original SL is too far",
"scaledEntry": "Scaled entry approach if better levels become available",
"invalidationScenario": "What price action would invalidate this setup completely"
}
}