This indicator displays how many buyers and sellers are trapped into their positions. These figures are calculated by comparing the price they entered their positions, to the current price +- trading fees.
This indicator also features an option to account for trading fees, so that it can be used as reliably in the real world, on real people as much as possible!
The chart is a simple zero-line cross, displaying both buyers and sellers trapped in the form of a histogram.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Meesemoo
//@version=4
study("Identifying Trapped Traders")
lookback = input(defval = 10, title = "How many bars lookback?", minval = 2, maxval = 500, type = input.integer)
trading_fees = input(defval = true, title = "Account for Trading fees?", type=input.bool)
fee = 0.0
if trading_fees
fee := (hl2 * 0.002)
trapped_buyers = 0.0
trapped_sellers = 0.0
for i = 0 to lookback
if high[i] > (hl2 - fee)
trapped_buyers := trapped_buyers + (hl2 - high[i])
if low[i] < (hl2 + fee)
trapped_sellers := trapped_sellers + (hl2 - low[i])
plot(trapped_buyers, color = color.green)
plot(trapped_sellers, color = color.red)
plot(0, color = color.gray)
fill(plot(0), plot(trapped_buyers, color = color.green), color = color.green, transp = 70)
fill(plot(0), plot(trapped_sellers, color = color.red), color = color.red, transp = 70)
[attachment file=”174558″]
Hi,
is there a difference with this other one earlier?
https://www.prorealcode.com/topic/tradingview-trapped-traders-indicator-conversion/
If not, please keep in mind the forum publication rule against double posting (you can find these rules in the yellow box below), and let us know which one of the 2 topics you prefer to be deleted, thanks.
Thanks, I followed the link below to post the second request as I thought I’d posted the first one in the wrong place… If that makes sense. So please delete the first request. Thanks
hillsee – Welcome to the forums.
When requesting code conversions please follow the instructions found here:
https://www.prorealcode.com/free-code-conversion/
Please find below the code converted for ProRealTime:
lookback = 10 //"How many bars lookback?"
tradingfees = 1 //"Account for Trading fees?"
fee = 0.0
if tradingfees then
fee = (medianprice * 0.002)
endif
trappedbuyers = 0.0
trappedsellers = 0.0
hl2=medianprice
for i = 0 to lookback
if high[i] > (hl2 - fee) then
trappedbuyers = trappedbuyers + (hl2 - high[i])
endif
if low[i] < (hl2 + fee) then
trappedsellers = trappedsellers + (hl2 - low[i])
endif
next
return trappedbuyers coloured(0,200,0),trappedsellers coloured(255,0,0)
Thanks, Nicolas I’m look forward to using it.