racer8

Baseline Summation [racer8]

859 views
117
Baseline Summation is a trend indicator that takes the summation of the true ranges above the current close and subtracts that from the summation of the true ranges below the current close over 30 periods back. The result is then smoothed out with a smoothing parameter and plotted. Green means buy, red means sell. Enjoy :)
Release Notes: Added feature that colors price bars according to indicator.
Release Notes: ...
Baseline Summation has now been simplified from 123 lines to 29 lines of code.
And finally, the Baseline Summation parameter is no longer fixed at 35 period lookback...it can be changed to whatever the user prefers.
Remove from Favorite Scripts Add to Favorite Scripts

Comments

Hi racer8, you could simplify your code using for loops

Baseline() =>
_first = close - low
_second = close - high
_third = 0.

for i = 1 to 35
_first := _first + (high <= close ? tr : 0)
_second := _second + (low >= close ? -tr : 0)
_third := _third + (high > close ? (low < close ? (close - low) + (close - high) : 0 ) : 0)
summation = _first + _second + _third

BaselineSummation = Baseline()
BaselineColor = BaselineSummation > 0 ? color.green : color.red
plot(BaselineSummation, "BaselineSummation", BaselineColor)
bgcolor(BaselineColor, transp=80)
+2 Reply
racer8 Mango2Juice
@Mango2Juice, Thank you very much. I actually contacted LucF regarding this issue, and he's provided a solution as well. But I will definitely consider implementing your solution.
Reply
This is great, thanks for sharing.
Although I have a question, would not be better to declare high, low, close just once? like CLOSE = close, HIGH = high and LOW = low? Wouldn`t this make script faster? Asking this because I want to combine this code with what I have and already having dozens and looking to improve the loading speed. Thanks in advance
+1 Reply
racer8 CUBYC
@CUBYC, yea, everyone is noticing how redundant the amount of lines of code I have in this script, and they are right. It will be fixed...coders like Mango2Juice & LucF have already provided solutions to this, and I will pick the best one to replace the current code I have for Baseline Summation. Stay tuned.
+1 Reply
CUBYC racer8
@racer8, Great news, can`t wait and would be really helpful. Thanks again mate
Reply
racer8 CUBYC
@CUBYC, Done, your wish has been granted.
+1 Reply
CUBYC racer8
@racer8, BRILIANT!!
+1 Reply
great work, thanks for sharing!
+1 Reply
racer8 blackcat1402
@blackcat1402, maybe this will inspire you to create something ;)
+1 Reply
@racer8, indeed, it give me some hints in mind :D
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out