Swing Trading

What’s Swing Trading

Swing trading is a medium term trading. it’s a mid-stage trading between day trader who buy and sell in the same day and long-term traders who hold positions for weeks and usually months. A Typical swing trade will be in range of days and less than a trading week.

Swing Trading involves capturing short term movements inside an overall trend. For Example, as a security has a bullish long term trend, there will be short term short term bearish movements which swing traders will try to identify and use to make profits. The same is true for short term bullish trends inside a long-term bearish trend.

Swing Trading is suitable for individuals and not suitable for institutional trading and hedge funds. The second type of traders are usually looking for long term trading and use for it fundamental rather than technical analysis.

Usage

Traders will use moving average as a guideline for entering the trade. Some traders will use 8-day moving average while other more patient traders will use 20-day moving average. in a normal long term bullish trend, the moving average will be below the the main security price chart. When a short term bearish trend in the overall bullish trend starts, the price chart will touch the movign average. This will be an entry point. An exit point will normally be set by a reasonable TK (in range 8 to 10 percent). A SL value should also be in place to minimize risk. a typical value will be around 5 percent.

Pine Script V6 for Swing Trading

Snippet
//@version=6indicator("Swing Trading MA Touch", shorttitle="MA Touch", overlay=true) // Input parametersma_length = input.int(8, title="Moving Average Length", minval=1)trend_ma_length = input.int(20, title="Trend MA Length (for trend direction)", minval=1)tp_percent = input.float(10.0, title="Take Profit %", minval=0.1, maxval=50.0)sl_percent = input.float(5.0, title="Stop Loss %", minval=0.1, maxval=20.0)touch_tolerance = input.float(0.5, title="Touch Tolerance %", minval=0.1, maxval=2.0)show_levels = input.bool(true, title="Show TP/SL Levels") // Calculate moving averagesma_8 = ta.sma(close, ma_length)trend_ma = ta.sma(close, trend_ma_length) // Position tracking variables (must be declared early)var float entry_price = navar float tp_level = navar float sl_level = navar bool position_active = false // Plot moving averagesplot(ma_8, color=color.blue, linewidth=2, title="8-Day MA")plot(trend_ma, color=color.orange, linewidth=1, title="Trend MA") // Determine bullish trendbullish_trend = close > trend_ma and ma_8 > trend_ma // Calculate touch conditiontouch_range = ma_8 * (touch_tolerance / 100)price_touching_ma = math.abs(close - ma_8) <= touch_range or math.abs(low - ma_8) <= touch_range // Buy signal condition (only when no position is active)buy_signal = bullish_trend and price_touching_ma and close > ma_8[1] and not position_active // Plot buy signalsplotshape(buy_signal, style=shape.triangleup, location=location.belowbar, color=color.lime, size=size.normal, title="Buy Signal") // Add buy signal labelif buy_signal label.new(bar_index, low * 0.995, text="BUY\nEntry: " + str.tostring(close, "#.##") + "\nTP: " + str.tostring(close * 1.10, "#.##") + "\nSL: " + str.tostring(close * 0.95, "#.##"), style=label.style_label_up, color=color.green, textcolor=color.white, size=size.normal) // Update position trackingif buy_signal entry_price := close tp_level := entry_price * (1 + tp_percent / 100) sl_level := entry_price * (1 - sl_percent / 100) position_active := true // Check if TP or SL is hittp_hit = position_active and high >= tp_levelsl_hit = position_active and low <= sl_level if position_active and (tp_hit or sl_hit) // Add exit label exit_text = tp_hit ? "TP HIT\n+10%" : "SL HIT\n-5%" exit_color = tp_hit ? color.green : color.red label.new(bar_index, tp_hit ? high * 1.005 : low * 0.995, text=exit_text, style=tp_hit ? label.style_label_down : label.style_label_up, color=exit_color, textcolor=color.white, size=size.normal) // Reset position - ready for new entry signals position_active := false entry_price := na tp_level := na sl_level := na // Plot TP and SL levelsplot(show_levels and position_active ? tp_level : na, color=color.green, linewidth=2, style=plot.style_stepline, title="Take Profit")plot(show_levels and position_active ? sl_level : na, color=color.red, linewidth=2, style=plot.style_stepline, title="Stop Loss")plot(show_levels and position_active ? entry_price : na, color=color.yellow, linewidth=1, style=plot.style_stepline, title="Entry Price") // Background color for trendbgcolor(bullish_trend ? color.new(color.green, 97) : color.new(color.gray, 98), title="Trend Background") // Create table for signal informationvar table info_table = table.new(position.top_right, 2, 4, bgcolor=color.white, border_width=1) if barstate.islast table.cell(info_table, 0, 0, "Status", text_color=color.black, bgcolor=color.gray) table.cell(info_table, 1, 0, position_active ? "Active Position" : "No Position", text_color=color.black, bgcolor=position_active ? color.yellow : color.white) if position_active table.cell(info_table, 0, 1, "Entry", text_color=color.black) table.cell(info_table, 1, 1, str.tostring(entry_price, "#.##"), text_color=color.black) table.cell(info_table, 0, 2, "TP (+10%)", text_color=color.black) table.cell(info_table, 1, 2, str.tostring(tp_level, "#.##"), text_color=color.green) table.cell(info_table, 0, 3, "SL (-5%)", text_color=color.black) table.cell(info_table, 1, 3, str.tostring(sl_level, "#.##"), text_color=color.red) // Alertsalertcondition(buy_signal, title="Buy Signal", message="Swing Trading Buy Signal: Price touched 8-day MA in bullish trend")alertcondition(position_active and high >= tp_level, title="Take Profit Hit", message="Take Profit level reached (+10%)")alertcondition(position_active and low <= sl_level, title="Stop Loss Hit", message="Stop Loss level hit (-5%)")

ThinkScript

Snippet

# Swing Trading MA Touch Indicator - ThinkScript Version# Generates buy signals when price touches 8-day MA in bullish trend# TP: 10%, SL: 5%, One position at a time declare upper; # Input parametersinput ma_length = 8;input trend_ma_length = 20;input tp_percent = 10.0;input sl_percent = 5.0;input touch_tolerance = 0.5;input show_levels = yes;input show_labels = yes; # Calculate moving averagesdef ma_8 = Average(close, ma_length);def trend_ma = Average(close, trend_ma_length); # Plot moving averagesplot MA8 = ma_8;MA8.SetDefaultColor(Color.BLUE);MA8.SetLineWeight(2); plot TrendMA = trend_ma;TrendMA.SetDefaultColor(Color.ORANGE);TrendMA.SetLineWeight(1); # Determine bullish trenddef bullish_trend = close > trend_ma and ma_8 > trend_ma; # Calculate touch conditiondef touch_range = ma_8 * (touch_tolerance / 100);def price_touching_ma = AbsValue(close - ma_8) <= touch_range or AbsValue(low - ma_8) <= touch_range; # Position tracking variablesdef entry_price;def tp_level;def sl_level;def position_active; # Initialize position trackingif (IsNaN(entry_price[1])) { entry_price = Double.NaN; tp_level = Double.NaN; sl_level = Double.NaN; position_active = 0;} else { entry_price = entry_price[1]; tp_level = tp_level[1]; sl_level = sl_level[1]; position_active = position_active[1];} # Check if TP or SL is hitdef tp_hit = position_active and high >= tp_level;def sl_hit = position_active and low <= sl_level;def exit_hit = tp_hit or sl_hit; # Reset position when TP or SL is hitif (exit_hit) { entry_price = Double.NaN; tp_level = Double.NaN; sl_level = Double.NaN; position_active = 0;} # Buy signal condition (only when no position is active)def buy_signal = bullish_trend and price_touching_ma and close > ma_8[1] and !position_active; # Update position when buy signal occursif (buy_signal) { entry_price = close; tp_level = close * (1 + tp_percent / 100); sl_level = close * (1 - sl_percent / 100); position_active = 1;} # Plot buy signalsplot BuySignal = if buy_signal then low * 0.99 else Double.NaN;BuySignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);BuySignal.SetDefaultColor(Color.LIME);BuySignal.SetLineWeight(3); # Plot TP and SL levelsplot TakeProfit = if (show_levels and position_active) then tp_level else Double.NaN;TakeProfit.SetDefaultColor(Color.GREEN);TakeProfit.SetLineWeight(2);TakeProfit.SetStyle(Curve.LONG_DASH); plot StopLoss = if (show_levels and position_active) then sl_level else Double.NaN;StopLoss.SetDefaultColor(Color.RED);StopLoss.SetLineWeight(2);StopLoss.SetStyle(Curve.LONG_DASH); plot EntryLevel = if (show_levels and position_active) then entry_price else Double.NaN;EntryLevel.SetDefaultColor(Color.YELLOW);EntryLevel.SetLineWeight(1);EntryLevel.SetStyle(Curve.LONG_DASH); # Plot exit signalsplot TPHit = if tp_hit then high * 1.01 else Double.NaN;TPHit.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);TPHit.SetDefaultColor(Color.GREEN);TPHit.SetLineWeight(3); plot SLHit = if sl_hit then low * 0.99 else Double.NaN;SLHit.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);SLHit.SetDefaultColor(Color.RED);SLHit.SetLineWeight(3); # Background color for trendAssignPriceColor(if bullish_trend then Color.DARK_GREEN else Color.GRAY); # Add labels for buy signalsAddLabel(show_labels and buy_signal, "BUY SIGNAL - Entry: " + Round(close, 2) + " | TP: " + Round(close * (1 + tp_percent/100), 2) + " | SL: " + Round(close * (1 - sl_percent/100), 2), Color.GREEN); # Add labels for exitsAddLabel(show_labels and tp_hit, "TAKE PROFIT HIT! +10%", Color.GREEN);AddLabel(show_labels and sl_hit, "STOP LOSS HIT! -5%", Color.RED); # Position status labelAddLabel(show_labels and position_active, "POSITION ACTIVE - Entry: " + Round(entry_price, 2), Color.YELLOW); # Cloud fill between MA and trend MAAddCloud(ma_8, trend_ma, if ma_8 > trend_ma then Color.LIGHT_GREEN else Color.LIGHT_RED, if ma_8 > trend_ma then Color.LIGHT_GREEN else Color.LIGHT_RED); # AlertsAlert(buy_signal, "Swing Trading Buy Signal: Price touched 8-day MA in bullish trend", Alert.BAR, Sound.Chimes);Alert(tp_hit, "Take Profit Hit! +10% gain achieved", Alert.BAR, Sound.Bell);Alert(sl_hit, "Stop Loss Hit! -5% loss occurred", Alert.BAR, Sound.Ding);