TO ONLY BE USED FOR LOW FLOAT STOCKS WITH MARKET CAP LESS THAN $1 BILLION, This strategy is tailored for intraday traders and scalpers, providing automated entry and exit signals for dynamic market conditions. It combines technical indicators, volume analysis, and price action to optimize trading performance.
The code is suitable for stocks with high volatility and volume, offering adaptability through customizable input parameters such as trailing stop percentages and profit targets. By incorporating advanced exit logic, the script aims to maximize gains while minimizing risks in various market scenarios. Overlay: The script plots data directly on the price chart. Precision: Values are displayed with 2 decimal places. Initial Capital: The strategy assumes $1700 as the starting capital for calculating position sizing.
2. Candlestick Pattern Detection Small Body Long Wick: A candlestick pattern where the body size (difference between open and close) is small relative to the total range (difference between high and low). Input Parameter: Body Threshold Percentage defines the threshold for a "small body." Use Case: Identifying potential indecision or reversal points in the market.
3. Cumulative Day Volume Calculates cumulative volume for the current day: Resets at the start of a new trading session (is_new_day). Plot: Displays the cumulative volume on the chart to assess trading activity.
4. MACD (Moving Average Convergence Divergence) A widely used momentum indicator with: Fast and slow EMA inputs. Signal line for crossovers. Alerts: When the histogram transitions from positive to negative or vice versa, alerts are triggered.
5. Premarket Analysis Tracks premarket price action: Captures the open price of the premarket session and calculates percentage gains. Color-Coding: Green for positive and red for negative percentage changes.
6. Opening Price & Session Levels Session Open: Captures and plots the opening price of the main trading session at 9:30 AM. Includes horizontal lines for session high and low. Reset Conditions: Automatically updates for a new trading day.
7. Volume x Price (VxP) Momentum Compares the momentum of recent trading activity with the cumulative session activity: Calculates cumulative price-volume (VxP) for both session start and last 15 bars. Output: Ratio of VxP between the session and recent bars to highlight momentum changes.
8. Trend Analysis Using EMAs Three Exponential Moving Averages (EMA): Long-term (200-period), medium-term (50-period), and short-term (20-period). Trend Identification: Bullish: 20 EMA > 50 EMA > 200 EMA. Bearish: Reverse order of EMAs.
9. Position Sizing Calculates the number of shares to buy with a quarter of the initial capital ($1700) based on the current close price. Displays the value on the chart.
10. Other Features Price Thresholds: Defines conditions for stocks below $4 or $2 for tighter stop-loss settings. Dynamic Background: Changes based on VxP ratio, providing visual cues for momentum shifts. Customizable Inputs: Many parameters (e.g., EMA lengths, thresholds) are adjustable for flexibility.
VWAP and Bands Calculation:
VWAP is recalculated with flexible anchoring options, including unique time periods (Session, Week, Month, etc.) and events (Earnings, Dividends, Splits). Upper and lower VWAP bands are computed using either standard deviation or percentage-based calculations. Consecutive Bars Above Bands:
Tracks consecutive bars closing above each VWAP band (up to 5 bands). Resets the count if a bar fails to close above the respective band. Background Highlighting (Commented Out):
Logic for highlighting the background when a threshold of consecutive bars (e.g., 5 or more) above a band is reached. Currently commented out but easy to activate for visual cues. Variable Initialization:
Uses var for persistent variables to track states and counts across script runs. Signal Plotting Preparation:
Variables for plotting signals (e.g., plotSignal1) are defined, though the logic for plotting them isn't implemented yet.
Core Logic Entry Conditions
Long entry conditions require price confirmation above both VWAP (Volume Weighted Average Price) and TWAP (Time Weighted Average Price). Avoids entries during declining volume or when the last three bars closed below VWAP to prevent entering in downtrends or volatile pullbacks. Incorporates several monetary volume conditions (condH, cond10M, etc.) to filter trades based on trade sizes and specific thresholds. Trade Management
The script manages trades using variables such as tradeCount to limit entries and ensure logical flow. Tracks highestPrice after entry to enable trailing stops. Includes flags to control entry availability and reset trade states when a session ends. Exit Conditions
Incorporates trailing stops based on price ranges and percentage thresholds. Defines multiple stop-loss mechanisms tailored for different stock price ranges (e.g., <$4, <$2). Uses a trailing stop strategy for the first 10 minutes after market open for quicker risk management. Forces exits when critical conditions are breached, such as 15 consecutive bars closing below the entry price or price falling below VWAP/TWAP. Advanced Features
Handles session resets to reinitialize variables. Accounts for varying stock price ranges to adjust trailing stops and stop-loss percentages dynamically. Detects and responds to significant events such as new session starts, high volume trades, and quick profitability opportunities.
Key Features: Trailing Stop Loss and Take Profit:
Implements dynamic trailing stop losses based on specific conditions such as the percentage range of price movements and timeframes. For example, in the first two or five minutes of market open, trailing stops are adjusted based on price and volume trends. Exit Conditions:
Volume and Price Trends: Exits are triggered when decreasing volume and price trends indicate a reversal or weakness in the position. VWAP Bands: Uses VWAP band levels to identify overextended moves, exiting positions when prices cross these levels. EMA200 Cross: Closes positions when prices fall below the 200 EMA, signaling a bearish trend. Profit Targets: Takes profit at specific thresholds (e.g., 5%, 30%) based on rapid price movements. Specific Scenarios for Exit Strategies:
Doji at Market Open: Exits positions if a Doji candlestick appears during the first minute, coupled with a 5% profit threshold. Volume Profile Red Zone: Implements trailing stops specific to red zones in the volume profile to secure profits. Adaptive Logic Based on Market Conditions:
Bearish Indicators: Exits positions during bearish MACD crossovers or decreasing monetary volume combined with MACD red conditions. Pivot Levels: Exits positions if the price closes below a significant pivot high shortly after entry. Loss Recovery Mechanism: Adjusts trading bias to short positions after multiple consecutive losses or significant stock value drops. Time-Based Exit:
Ensures all trades are closed at the end of the trading day to avoid overnight risk. Testing and Scalability:
Includes sections marked for testing and potential enhancements, such as integrating additional trailing stop logic and refining conditions for specific market patterns.