entries = df.index[(df[“pos”].diff() == 1)]
exits = df.index[(df[“pos”].diff() == -1)]
fig, (ax1, ax2, ax3) = plt.subplots(
3, 1, figsize=(13, 10), sharex=True,
gridspec_kw={“height_ratios”: [3, 1, 2]},
)
ax1.plot(df.index, df[“close”], lw=1.1, color=”black”, label=”Close”)
ax1.plot(df.index, df[“SMA_20″], lw=0.9, label=”SMA 20”)
ax1.plot(df.index, df[“SMA_50″], lw=0.9, label=”SMA 50”)
bbu, bbl = “BBU_20_2.0”, “BBL_20_2.0″
if bbu in df and bbl in df:
ax1.fill_between(df.index, df[bbl], df[bbu], alpha=0.12, label=”Bollinger 20,2”)
ax1.scatter(entries, df.loc[entries, “close”], marker=”^”, s=70,
color=”green”, zorder=5, label=”Entry”)
ax1.scatter(exits, df.loc[exits, “close”], marker=”v”, s=70,
color=”red”, zorder=5, label=”Exit”)
ax1.set_title(f”{TICKER} — price, MAs, Bollinger, signals”)
ax1.legend(loc=”upper left”); ax1.grid(alpha=0.3)
ax2.plot(df.index, df[“RSI_14″], lw=0.9, label=”RSI 14″)
ax2.axhline(70, color=”red”, ls=”–“, lw=0.6)
ax2.axhline(30, color=”green”, ls=”–“, lw=0.6)
ax2.set_title(“RSI 14″); ax2.legend(loc=”upper left”); ax2.grid(alpha=0.3)
ax3.plot(df.index, (1 + df[“ret”]).cumprod(), lw=1.1, label=”Buy & Hold”)
ax3.plot(df.index, (1 + df[“strat_ret”]).cumprod(), lw=1.1, label=”Strategy”)
ax3.set_title(“Equity curves ($1 start)”)
ax3.legend(loc=”upper left”); ax3.grid(alpha=0.3)
plt.tight_layout(); plt.show()
print(“\nTweak TICKER, the Strategy list, or the sweep grid to keep exploring.”)
Trending
- Storage keeps getting more expensive, but these new Amazon deals should lessen the blow — just in time for Back to School
- Pebble Time 2 teardown exposes a missing button clip
- OnePlus may be on the verge of a major global retreat
- Siri AI makes the Apple Watch finally feel like a wrist computer
- OnePlus may leave Europe and the US, putting future watches in doubt
- Global phone market dropped in Q2 2026, and the holiday season might not help it later
- Bevel adds Google Health support for Fitbit Air users
- Yes, Verizon really wants to give you a free Google Pixel 10 Pro — here’s how you can claim it

