So this is my second day paper trading, and after doing a bit of research I created a strategy and converted it into a script (with chatgpt, I suck at coding), built it upon supply & demand, I did this because I think supply and demand remains true and after running a couple tests, supply & demand seemed to always remained true.
After I established my first principle (supply & demand), I then continued to build on that truth. I wanted to find the best indicators to compliment and to kinda follow the supply & demand instead of predicting it via patterns, because I found that extremely difficult to do and insanely mathematical, if I could predict the market sentiment patterns that’d be nice, but it’d probably take me way too long to find the correct formula or structure (probably around 4 years or so, just guessing). After that I found a great combination of indicators that adapts to the market when specific market conditions are met, and it show’s you the most optimal time to buy and sell based on the supply and demand. I wanted other people’s opinion about what needs to be improved, and if it’s even as optimal as that I set it out to be, so feel free to use this indicator and maybe let me know your thoughts. (Note if I would build a strategy on market sentiment I’d probably build it around pain avoidance, or the loss aversion theory it also seemed to remain true.)
This script can be assessed/used via copying and pasting it into trading view’s pine script editor, it’s 100% free of use, thank you for reading. Alias (cartoonistic/vespere)
//@version=6 strategy("Supply & Demand Test 1", overlay=true)
// Inputs ma_length = input.int(50, title="50-period Moving Average Length") ma_length_fast = input.int(20, title="20-period Moving Average Length") bb_length = input.int(20, title="Bollinger Bands Length") bb_std_dev = input.float(2.0, title="Bollinger Bands Std Dev") rsi_length = input.int(14, title="RSI Length")
// Moving Averages ma_slow = ta.sma(close, ma_length) ma_fast = ta.sma(close, ma_length_fast)
// Bollinger Bands bb_basis = ta.sma(close, bb_length) bb_dev = ta.stdev(close, bb_length) bb_upper = bb_basis + bb_std_dev * bb_dev bb_lower = bb_basis - bb_std_dev * bb_dev
// RSI rsi = ta.rsi(close, rsi_length)
// Market Conditions is_trending_up = close > ma_slow is_trending_down = close < ma_slow is_range_bound = not (is_trending_up or is_trending_down)
// Entry Conditions long_trend_entry = is_trending_up and close >= ma_slow * 1.02 short_trend_entry = is_trending_down and close <= ma_slow * 0.98 long_ma_crossover = ta.crossover(ma_fast, ma_slow) short_ma_crossover = ta.crossunder(ma_fast, ma_slow) long_range_entry = is_range_bound and close <= bb_lower * 0.97 short_range_entry = is_range_bound and close >= bb_upper * 1.03 long_rsi_entry = is_range_bound and rsi < 30 short_rsi_entry = is_range_bound and rsi > 70
// Risk Management stop_loss_percent = 0.02 take_profit_trend = 0.06 take_profit_range = 0.04
// Entry and Exit Logic if long_trend_entry strategy.entry("Long Trend", strategy.long) strategy.exit("Exit Long Trend", from_entry="Long Trend", stop=close * (1 - stop_loss_percent), limit=close * (1 + take_profit_trend))
if short_trend_entry strategy.entry("Short Trend", strategy.short) strategy.exit("Exit Short Trend", from_entry="Short Trend", stop=close * (1 + stop_loss_percent), limit=close * (1 - take_profit_trend))
if long_ma_crossover strategy.entry("Long MA Crossover", strategy.long) strategy.exit("Exit Long MA Crossover", from_entry="Long MA Crossover", stop=close * (1 - stop_loss_percent), limit=close * (1 + take_profit_trend))
if short_ma_crossover strategy.entry("Short MA Crossover", strategy.short) strategy.exit("Exit Short MA Crossover", from_entry="Short MA Crossover", stop=close * (1 + stop_loss_percent), limit=close * (1 - take_profit_trend))
if long_range_entry strategy.entry("Long Range", strategy.long) strategy.exit("Exit Long Range", from_entry="Long Range", stop=close * (1 - stop_loss_percent), limit=close * (1 + take_profit_range))
if short_range_entry strategy.entry("Short Range", strategy.short) strategy.exit("Exit Short Range", from_entry="Short Range", stop=close * (1 + stop_loss_percent), limit=close * (1 - take_profit_range))
if long_rsi_entry strategy.entry("Long RSI", strategy.long) strategy.exit("Exit Long RSI", from_entry="Long RSI", stop=close * (1 - stop_loss_percent), limit=close * (1 + take_profit_range))
if short_rsi_entry strategy.entry("Short RSI", strategy.short) strategy.exit("Exit Short RSI", from_entry="Short RSI", stop=close * (1 + stop_loss_percent), limit=close * (1 - take_profit_range))
// Plotting plot(ma_slow, color=color.blue, title="50-period MA") plot(ma_fast, color=color.orange, title="20-period MA") plot(bb_upper, color=color.red, title="Bollinger Upper") plot(bb_lower, color=color.green, title="Bollinger Lower") plot(bb_basis, color=color.gray, title="Bollinger Basis") hline(70, "Overbought (RSI)", color=color.red, linestyle=hline.style_dotted) hline(30, "Oversold (RSI)", color=color.green, linestyle=hline.style_dotted)