RPG Daily Wisdom

Aden_Suraud · study · 269 行 · 点赞 2 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
// RPG Daily Wisdom - a quote from an investor, trader, philosopher, business builder or coach,
// plus a one-line reflection, pinned to the chart. Every quote is checked against a sourced record
// (see sources.md). Generated by build.py from entries_src.json - edit there, not here.
indicator("RPG Daily Wisdom", overlay = true)
 
// ---------- Inputs ----------
const string G_ROT = "Rotation"
rotation = input.string("Daily", "Change quote", options = ["Daily", "Every session", "Hourly"], group = G_ROT, display = display.none)
themeSel = input.string("All themes", "Theme", options = ["All themes", "Greed & Patience", "Fear & Risk", "Discipline & Ego", "Work & Legacy"], group = G_ROT, display = display.none)
shuffleN = input.int(0, "Shuffle (click up for a random quote, 0 = off)", minval = 0, group = G_ROT, display = display.none)
alertOn  = input.bool(true, "Send alert when the quote changes", group = G_ROT, tooltip = "Create an alert on this indicator with the condition 'Any alert() function call'.", display = display.none)
 
const string G_LAY = "Layout"
posSel    = input.string("Bottom left", "Position", options = ["Top left", "Top center", "Top right", "Middle left", "Middle center", "Middle right", "Bottom left", "Bottom center", "Bottom right"], group = G_LAY, display = display.none)
sizeSel   = input.string("Normal", "Text size", options = ["Tiny", "Small", "Normal", "Large"], group = G_LAY, display = display.none)
alignSel  = input.string("Center", "Alignment", options = ["Center", "Left", "Right"], group = G_LAY, display = display.none)
wrapW     = input.int(46, "Card width (characters per line)", minval = 20, maxval = 120, group = G_LAY, display = display.none)
showEmoji = input.bool(true, "Show theme emoji", group = G_LAY, display = display.none)
showTheme = input.bool(true, "Show theme name", group = G_LAY, display = display.none)
showQuote = input.bool(true, "Put the quote in quotation marks", group = G_LAY, display = display.none)
 
const string G_STY = "Text style"
styRef   = input.string("Bold", "Reference", options = ["Normal", "Bold", "Italic", "Bold + Italic"], group = G_STY, display = display.none)
styVerse = input.string("Bold + Italic", "Quote", options = ["Normal", "Bold", "Italic", "Bold + Italic"], group = G_STY, display = display.none)
styRefl  = input.string("Normal", "Reflection", options = ["Normal", "Bold", "Italic", "Bold + Italic"], group = G_STY, display = display.none)
 
const string G_COL = "Colors"
cBg     = input.color(#F5EFE0, "Background", group = G_COL, display = display.none)
cFrame  = input.color(#000000, "Border", group = G_COL, display = display.none)
frameW  = input.int(1, "Border width", minval = 0, maxval = 5, group = G_COL, display = display.none)
cRef    = input.color(#000000, "Reference", group = G_COL, display = display.none)
cVerse  = input.color(#000000, "Quote", group = G_COL, display = display.none)
cRefl   = input.color(#000000, "Reflection", group = G_COL, display = display.none)
 
const string G_HL = "Highlight"
hlRef   = input.bool(false, "Reference", inline = "hr", group = G_HL, display = display.none)
cHlRef  = input.color(#FFE58A, "", inline = "hr", group = G_HL, display = display.none)
hlVerse = input.bool(false, "Quote", inline = "hv", group = G_HL, display = display.none)
cHlVer  = input.color(#FFE58A, "", inline = "hv", group = G_HL, display = display.none)
hlRefl  = input.bool(false, "Reflection", inline = "hf", group = G_HL, display = display.none)
cHlRefl = input.color(#FFE58A, "", inline = "hf", group = G_HL, display = display.none)
 
// ---------- Data ----------
// Each entry: "theme|author|quote|reflection"
var array<string> E = array.new<string>()
 
load0() =>
    E.push("0|Warren Buffett|...the stock market serves as a relocation center at which money is moved from the active to the patient.|Money moves from the restless to the patient. Be the patient one today.")
    E.push("1|Warren Buffett|It's only when the tide goes out that you learn who's been swimming naked.|Shortcuts stay hidden until conditions change. Build so you can handle the tide going out.")
    E.push("2|Warren Buffett|Once you have ordinary intelligence, what you need is the temperament to control the urges that get other people into trouble in investing.|You don't need more brains. You need to control the urges that trip everyone else up.")
    E.push("3|Warren Buffett|Love is the greatest advantage a parent can give.|The best thing you can give your kids isn't money. It's love.")
    E.push("0|Warren Buffett|...we simply attempt to be fearful when others are greedy and to be greedy only when others are fearful.|When everyone is rushing in, slow down. When everyone is running out, look closer.")
    E.push("1|Warren Buffett|An investor needs to do very few things right as long as he or she avoids big mistakes.|You don't need to be brilliant. You need to avoid the big mistakes.")
    E.push("2|Warren Buffett|What counts for most people in investing is not how much they know, but rather how realistically they define what they don't know.|Be honest about what you don't know. That's real knowledge.")
    E.push("3|Charlie Munger|The safest way to try and get what you want is to try and deserve what you want.|Want something? Work to deserve it. That's the surest path.")
    E.push("0|Warren Buffett|Nothing sedates rationality like large doses of effortless money.|Easy money makes you careless. Stay sharpest when things feel easiest.")
    E.push("1|Charlie Munger|You fix what can be fixed, and what can't be fixed you endure.|Fix what you can today. Carry what you can't with as much grace as you have.")
    E.push("2|Charlie Munger|It is remarkable how much long-term advantage people like us have gotten by trying to be consistently not stupid, instead of trying to be very intelligent.|Avoiding dumb mistakes beats chasing genius. Keep it simple today.")
    E.push("3|Charlie Munger|They go to bed every night a little wiser than they were when they got up and boy does that habit help - particularly when you have a long run ahead of you.|Go to bed a little wiser than you woke up. Over the years, it adds up.")
    E.push("0|Charlie Munger|The wise ones bet heavily when the world offers them that opportunity. They bet big when they have the odds. And the rest of the time, they don't.|You don't have to swing at everything. Wait for the clear chance, then commit.")
    E.push("1|Ed Seykota|Here's the essence of risk management: Risk no more than you can afford to lose, and also risk enough so that a win is meaningful. If there is no such amount, don't play.|Only put at risk what you can afford to lose. If that's nothing, sit this one out.")
    E.push("2|Benjamin Graham|Wall Street has a few prudent principles; the trouble is that they are always forgotten when they are most needed.|Your rules matter most when they're hardest to follow. Hold to them today.")
    E.push("3|Charlie Munger|You don't overspend your income, you stay cheerful in spite of your troubles, you deal with reliable people, and you do what you're supposed to do.|Live below your means, stay cheerful, keep good company, and do your job.")
    E.push("0|Charlie Munger|There are huge advantages for an individual to get into a position where you make a few great investments and just sit back and wait...|A few good decisions and a lot of patience can carry you further than constant action.")
    E.push("1|Nassim Nicholas Taleb|My idea of the modern Stoic sage is someone who transforms fear into prudence, pain into information, mistakes into initiation, and desire into undertaking.|Turn fear into caution and pain into lessons. That's how setbacks pay you back.")
    E.push("2|Edwin Lefevre|A stock operator has to fight a lot of expensive enemies within himself.|Your toughest opponent is usually in the mirror. Win that fight first.")
    E.push("3|John Bogle|The courage to press on regardless - regardless of whether we face calm seas or rough seas... - is the quintessential attribute of the successful investor.|Keep going in calm seas and rough ones. Persistence is the edge.")
    E.push("0|Benjamin Graham|Never buy a stock immediately after a substantial rise or sell one immediately after a substantial drop.|Don't let the last big move make your next decision for you.")
    E.push("1|Edwin Lefevre|The speculator's deadly enemies are: Ignorance, greed, fear and hope.|Ignorance, greed, fear and hope. Notice which one is talking to you today.")
    E.push("2|Edwin Lefevre|If a man didn't make mistakes he'd own the world in a month. But if he didn't profit by his mistakes he wouldn't own a blessed thing.|Everyone makes mistakes. Learning from them is what makes the difference.")
    E.push("3|Benjamin Graham|The genuine investor in common stocks does not need a great equipment of brain and knowledge, but he does need some unusual qualities of character.|Character beats brilliance over the long run. Build yours.")
    E.push("0|Edwin Lefevre|It never was my thinking that made the big money for me. It was always my sitting.|Sometimes the hardest and most rewarding thing you can do is nothing at all.")
    E.push("1|Edwin Lefevre|I always knew I would have another chance and that I would not make the same mistake a second time. I believed in myself.|A setback isn't the end. There will be another chance, so learn from this one.")
    E.push("2|Ed Seykota|It can be very expensive to try to convince the markets you are right.|Being stubborn is expensive. Let go of needing to be right.")
    E.push("3|Marcus Aurelius|No longer talk at all about the kind of man that a good man ought to be, but be such.|Stop talking about who you want to be. Be that person today.")
    E.push("0|Edwin Lefevre|The desire for constant action irrespective of underlying conditions is responsible for many losses in Wall Street...|Busy is not the same as productive. Act when it matters, rest when it doesn't.")
    E.push("1|Marcus Aurelius|Be like the promontory against which the waves continually break, but it stands firm and tames the fury of the water around it.|Let the noise crash around you today. You don't have to move with every wave.")
    E.push("2|Stanley Druckenmiller|It's not whether you're right or wrong that's important, but how much money you make when you're right and how much you lose when you're wrong.|It's not about being right. It's about how you handle being wrong.")
    E.push("3|Marcus Aurelius|In the morning when thou risest unwillingly, let this thought be present: I am rising to the work of a human being.|Getting up is hard some days. Remember you're rising to do meaningful work.")
    E.push("0|John Bogle|...don't stop a program of regular investing because the market goes down.|Keep your good habits going on the down days. That's when they count most.")
    E.push("1|Marcus Aurelius|If thou art pained by any external thing, it is not this thing that disturbs thee, but thy own judgment about it. And it is in thy power to wipe out this judgment now.|Your reaction often hurts more than the event. You can change your reaction today.")
    E.push("2|Marcus Aurelius|If any man is able to convince me and show me that I do not think or act right, I will gladly change; for I seek the truth, by which no man was ever injured.|If someone shows you you're wrong, thank them and change. Truth never hurt anyone.")
    E.push("3|Seneca|Hold every hour in your grasp. Lay hold of to-day's task, and you will not need to depend so much upon to-morrow's.|Own today's work, and tomorrow won't feel so heavy.")
    E.push("0|Ed Seykota|To avoid whipsaw losses, stop trading.|If you keep getting knocked around, step back. Sitting out is a real choice.")
    E.push("1|Epictetus|Of things some are in our power, and others are not.|Sort today into what you control and what you don't. Put your energy into the first.")
    E.push("2|Epictetus|Men are disturbed not by the things which happen, but by the opinions about the things.|Events don't upset you; your take on them does. Choose your take carefully today.")
    E.push("3|Confucius|Though but one basketful is thrown at a time, the advancing with it is my own going forward.|One basket at a time still moves the mountain. Keep going.")
    0
 
load1() =>
    E.push("0|Seneca|It is not the man who has too little, but the man who craves more, that is poor.|Wealth starts with wanting less. Notice what you already have today.")
    E.push("1|Seneca|There are more things, Lucilius, likely to frighten us than there are to crush us; we suffer more often in imagination than in reality.|Most of what you're dreading won't happen. Don't suffer it twice.")
    E.push("2|Seneca|Our plans miscarry because they have no aim. When a man does not know what harbour he is making for, no wind is the right wind.|Know where you're headed today, or every wind will feel wrong.")
    E.push("3|Ralph Waldo Emerson|Work... in every hour, paid or unpaid, see only that thou work, and thou canst not escape the reward.|Do the work, paid or not. The reward will find you.")
    E.push("0|Seneca|Natural desires are limited; but those which spring from false opinion can have no stopping-point.|Real needs have an end. Ask yourself which of today's wants actually do.")
    E.push("1|Seneca|Our minds should be sent forward in advance to meet all problems, and we should consider, not what is wont to happen, but what can happen.|Think through what could go wrong before it does, and fear loses its surprise.")
    E.push("2|Confucius|When you know a thing, to hold that you know it; and when you do not know a thing, to allow that you do not know it; this is knowledge.|Saying 'I don't know' is a sign of wisdom, not weakness.")
    E.push("3|Aristotle|Men come to be builders, for instance, by building; harp-players, by playing on the harp: exactly so, by doing just actions we come to be just.|You become what you practice. Practice who you want to be.")
    E.push("0|Lao Tzu|There is no guilt greater than to sanction ambition; no calamity greater than to be discontented with one's lot; no fault greater than the wish to be getting.|Wanting more never ends on its own. Decide today what enough looks like.")
    E.push("1|Confucius|When you have faults, do not fear to abandon them.|Don't be afraid to drop a bad habit. Letting go is a strength.")
    E.push("2|Lao Tzu|He who knows other men is discerning; he who knows himself is intelligent. He who overcomes others is strong; he who overcomes himself is mighty.|Mastering yourself is the strongest win there is.")
    E.push("3|Andrew Carnegie|The man who dies thus rich dies disgraced.|Wealth is for more than keeping. Think about what yours will do for others.")
    E.push("0|Lao Tzu|The tree which fills the arms grew from the tiniest sprout... the journey of a thousand li commenced with a single step.|Everything big started small. Take today's single step and trust the growth.")
    E.push("1|Lao Tzu|Who is content needs fear no shame. Who knows to stop incurs no blame. From danger free long live shall he.|Knowing when to stop keeps you out of trouble. Know your limit today.")
    E.push("2|Benjamin Franklin|He is a Governor that governs his Passions, and he a Servant that serves them.|Rule your emotions, or they'll rule you.")
    E.push("3|Andrew Carnegie|It is not the rich man's son that the young struggler for advancement has to fear... Let him look out for the 'dark horse' in the boy who begins by sweeping out the office.|The humble beginner who works hardest often ends up ahead. Keep sweeping.")
    E.push("0|Confucius|Do not be desirous to have things done quickly; do not look at small advantages... Looking at small advantages prevents great affairs from being accomplished.|Rushing for small wins can cost you the big ones. Think longer term today.")
    E.push("1|Aristotle|The rash... being eager before danger, when actually in it fall away, while the Brave are quick and sharp in action, but before are quiet and composed.|Brave isn't loud before the moment. It's calm before and steady during.")
    E.push("2|Benjamin Franklin|In reality, there is, perhaps, no one of our natural passions so hard to subdue as pride... it is still alive, and will every now and then peep out and show itself.|Pride never fully goes away. Catch it when it peeks out today.")
    E.push("3|Henry Ford|Money doesn't change men... it merely unmasks them.|Money only reveals who you already are. Work on who you are.")
    E.push("0|Marcus Aurelius|Think not so much of what thou hast not as of what thou hast...|Start the day counting what you have, not what you're missing.")
    E.push("1|Michel de Montaigne|The thing in the world I am most afraid of is fear, that passion alone, in the trouble of it, exceeding all other accidents.|Fear itself is often the biggest problem. Name it, then keep going.")
    E.push("2|John D. Rockefeller|It has always been our policy to hear patiently and discuss frankly until the last shred of evidence is on the table, before trying to reach a conclusion...|Listen fully and get the facts before you decide.")
    E.push("3|Steve Jobs|Being the richest man in the cemetery doesn't matter to me ... Going to bed at night saying we've done something wonderful... that's what matters to me.|Being rich isn't the point. Doing something worthwhile is.")
    E.push("0|Epictetus|Suppose that it is not yet come to you. Do not send your desire forward to it, but wait till it is opposite to you.|Don't chase what isn't in front of you yet. Let it come to you.")
    E.push("1|Henry Ford|Failure is only the opportunity more intelligently to begin again. There is no disgrace in honest failure; there is disgrace in fearing to fail.|Failing isn't the shame. Being too afraid to try is. Start again, smarter.")
    E.push("2|Bill Gates|Success is a lousy teacher. It seduces smart people into thinking they can't lose.|Success can make you careless. Stay humble when things go well.")
    E.push("3|Jeff Bezos|I'm talking about the work that no one sees. The work that gets done when no one is watching. In a high standards culture, doing that work well is its own reward.|The work nobody sees still counts. Do it well today.")
    E.push("0|Epictetus|Nothing great... is produced suddenly, since not even the grape or the fig is.|Good things take time to ripen. Give yours the time it needs.")
    E.push("1|John D. Rockefeller|It is hardly necessary to caution a young man... not to lose his head over a little success, or to grow impatient or discouraged by a little failure.|Don't let one good day inflate you or one bad day crush you.")
    E.push("2|Jeff Bezos|People who are right a lot change their mind... they wake up, and they re-analyze things all the time, and they come to a new conclusion, and then they change their mind.|Smart people change their minds. Revisit your thinking today.")
    E.push("3|Thomas Edison|Genius is one per cent inspiration, ninety-nine per cent perspiration.|Ideas are nice, but effort does most of the work.")
    E.push("0|Benjamin Franklin|Constant dropping wears away stones; and by diligence and patience the mouse ate in two the cable; and little strokes fell great oaks.|Small, steady effort wins. Keep chipping away today.")
    E.push("1|John D. Rockefeller|We knew how much we made and where we gained or lost. At least, we tried not to deceive ourselves.|Be honest with yourself about your numbers. Self-deception costs the most.")
    E.push("2|John Wooden|Failure is not fatal, but failure to change might be.|Failing won't finish you. Refusing to change might.")
    E.push("3|Vince Lombardi|You don't win once in a while; you don't do things right once in a while; you do them right all the time.|Doing things right isn't occasional. Make it your habit.")
    E.push("0|Steve Jobs|I'm convinced that about half of what separates the successful entrepreneurs from the non-successful ones is pure perseverance.|Half the battle is just not quitting. Keep showing up.")
    E.push("1|Andrew Carnegie|I determined that the proper policy was 'to put all good eggs in one basket and then watch that basket.'|Focus is a form of protection. Know what you hold and watch it closely.")
    E.push("2|John Wooden|You should never try to be better than someone else... you should never cease trying to be the best you could be because that's under your control and the other isn't.|Learn from everyone, but measure yourself only against your own best.")
    E.push("3|Muhammad Ali|I hated every minute of it. But I said to myself, 'Suffer now, and live the rest of your life as a champion'.|The hard part now is buying you something better later.")
    0
 
load2() =>
    E.push("0|Jeff Bezos|We've had three big ideas at Amazon that we've stuck with for 18 years... Put the customer first. Invent. And be patient.|Pick a few things that matter and stick with them for years.")
    E.push("1|Walt Disney|You may not realize it when it happens, but a kick in the teeth may be the best thing in the world for you.|The hard hits you've taken have made you stronger. Today's will too.")
    E.push("2|Kobe Bryant|Get over yourself! 'Cause it's not about you, man. Like, okay, you feel embarrassed. You are not that important! Get over yourself!|It's not about you. Let go of the embarrassment and move on.")
    E.push("3|Jackie Robinson|A life is not important except in the impact it has on other lives.|A life matters most by how it lifts others. Lift someone today.")
    E.push("0|Naval Ravikant|Play iterated games. All the returns in life, whether in wealth, relationships, or knowledge, come from compound interest.|Your habits, money and relationships all compound. Feed the good ones today.")
    E.push("1|Steve Jobs|Sometimes life hits you in the head with a brick. Don't lose faith.|When life knocks you down, don't lose belief in what you're building.")
    E.push("2|Tom Brady|If I throw an interception or have a bad day or make a bad business decision, by staying in that place I will just make things worse.|Bad moment? Don't stay there. Dwelling only makes it worse.")
    E.push("3|Tom Brady|There are no shortcuts to success on the field or in life.|There are no shortcuts. Do the work.")
    E.push("0|Naval Ravikant|Pick an industry where you can play long term games with long term people.|Choose people and paths you'd still want to be with in ten years.")
    E.push("1|Jeff Bezos|Most decisions should probably be made with somewhere around 70% of the information you wish you had. If you wait for 90%, in most cases, you're probably being slow.|You'll rarely have every answer. Decide with what you know and adjust as you go.")
    E.push("2|Derek Jeter|I'd boo myself, too. The fans expect us to do well, and that's good.|Hold yourself to a high standard, even when nobody else is watching.")
    E.push("3|Benjamin Franklin|Diligence is the Mother of Good-Luck.|Luck tends to show up for people who keep working.")
    E.push("0|John D. Rockefeller|I am sure it is a mistake to assume that the possession of money in great abundance necessarily brings happiness.|Money can't do the job your peace of mind is meant to do. Protect both.")
    E.push("1|Jeff Bezos|If you're good at course correcting, being wrong may be less costly than you think, whereas being slow is going to be expensive for sure.|Being wrong is fixable. Being frozen is expensive. Make the call and correct as needed.")
    E.push("2|Warren Buffett|Mr. Market is there to serve you, not to guide you.|Use what's in front of you as information, not as orders. You decide.")
    E.push("3|Benjamin Franklin|Plough deep, while Sluggards sleep, and you shall have Corn to sell and to keep.|Work while others rest, and you'll have plenty to keep and to share.")
    E.push("0|Henry Ford|Business on a money-making basis is most insecure. It is a touch-and-go affair, moving irregularly and rarely over a term of years amounting to much.|Chasing only money makes everything shaky. Build on something more solid.")
    E.push("1|Michael Jordan|I've failed over and over and over again in my life. And that is why I succeed.|Every failure is part of the climb. Keep climbing.")
    E.push("2|Benjamin Graham|Intelligent investment is more a matter of mental approach than it is of technique.|Your mindset matters more than any technique. Work on it today.")
    E.push("3|Ralph Waldo Emerson|The reward of a thing well done, is to have done it.|Doing something well is its own reward. Take pride in your work today.")
    E.push("0|Andrew Carnegie|I have adhered to the rule never to purchase what I did not pay for, and never to sell what I did not own.|Don't spend money you don't have. Freedom starts there.")
    E.push("1|Michael Jordan|Limits, like fears, are often just an illusion.|Some of your limits are just fears in disguise. Test one today.")
    E.push("2|Confucius|The cautious seldom err.|A little caution today saves a lot of regret tomorrow.")
    E.push("3|Ralph Waldo Emerson|Nothing great was ever achieved without enthusiasm.|Bring some energy to what you do today. Nothing great happens without it.")
    E.push("0|Ray Kroc|I was an overnight success all right, but thirty years is a long, long night.|Overnight success usually takes years. Keep building, even when nobody notices.")
    E.push("1|Michael Jordan|I can accept failure. Everyone fails at something. But I can't accept not trying.|Failing is allowed. Not trying isn't.")
    E.push("2|Epictetus|Every habit and faculty is maintained and increased by the corresponding actions...|Every habit grows with practice. Choose which ones you're feeding today.")
    E.push("3|Aristotle|For as it is not one swallow or one fine day that makes a spring, so it is not one day or a short time that makes a man blessed and happy.|One good day doesn't make a life. Keep stacking good days.")
    E.push("0|Muhammad Ali|I have learned to live my life one step, one breath, and one moment at a time, but it was a long road.|When it feels like too much, shrink it down: one step, one breath, one moment.")
    E.push("1|Muhammad Ali|I never thought of losing, but now that it's happened, the only thing is to do it right... We all have to take defeats in life.|Everyone takes losses. What matters is how you handle the next step.")
    E.push("2|Confucius|He acts before he speaks, and afterwards speaks according to his actions.|Do it first, talk about it after.")
    E.push("3|Steve Jobs|...getting fired from Apple was the best thing that could have ever happened to me.|Sometimes the worst thing that happens to you turns into the best.")
    E.push("0|Tom Brady|...there can be a variety of opportunities that may not be obvious in the moment but that through hard work, preparation, and persistence can present themselves over time.|Some doors only open after a lot of quiet work. Keep preparing.")
    E.push("1|Mike Tyson|Everybody has plans until they get hit for the first time.|Plans change once you get hit. Have one anyway, and keep your composure when it does.")
    E.push("2|Aristotle|...by doing just actions we come to be just; by doing the actions of self-mastery we come to be perfected in self-mastery; and by doing brave actions brave.|Self-control is built by practicing it. Practice it today.")
    E.push("3|Andrew Carnegie|Here is the prime condition of success, the great secret: concentrate your energy, thought, and capital exclusively upon the business in which you are engaged.|Put your energy where it counts most. Scattered effort builds very little.")
    E.push("0|Benjamin Graham|The margin of safety is always dependent on the price paid. It will be large at one price, small at some higher price, nonexistent at some still higher price.|Leave yourself room for error. The price you pay sets your safety.")
    E.push("1|Bill Belichick|We're on to Cincinnati.|After a bad day, don't dwell. Turn the page and focus on what's next.")
    E.push("2|Epictetus|First say to yourself who you wish to be: then do accordingly what you are doing.|Decide who you want to be first. Then do what that person would do today.")
    E.push("3|Seneca|Nothing, Lucilius, is ours, except time.|Time is the one thing that's truly yours. Spend today's on purpose.")
    0
 
const string TZ = "America/New_York"
var THEMES = array.from("Greed & Patience", "Fear & Risk", "Discipline & Ego", "Work & Legacy")
var EMOJI  = array.from("⏳", "🦁", "🎯", "🏆")
 
var array<int> POOL = array.new<int>()
if barstate.isfirst
    load0()
    load1()
    load2()
    for i = 0 to E.size() - 1
        t = int(str.tonumber(str.split(E.get(i), "|").get(0)))
        if themeSel == "All themes" or THEMES.get(t) == themeSel
            POOL.push(i)
 
// ---------- Rotation ----------
f_dayKey(int t) =>
    int(math.floor(timestamp(TZ, year(t, TZ), month(t, TZ), dayofmonth(t, TZ), 0, 0) / 86400000.0))
 
f_key(int t, int td) =>
    switch rotation
        "Every session" => int(math.floor(td / 86400000.0))
        "Hourly"        => f_dayKey(t) * 24 + hour(t, TZ)
        => f_dayKey(t)
 
f_entry(int key) =>
    str.split(E.get(POOL.get(key % POOL.size())), "|")
 
// ---------- Text helpers ----------
f_wrap(string s, int w) =>
    string out  = ""
    string line = ""
    for wd in str.split(s, " ")
        if str.length(line) > 0 and str.length(line) + 1 + str.length(wd) > w
            out  := out + line + "\n"
            line := wd
        else
            line := str.length(line) == 0 ? wd : line + " " + wd
    out + line
 
f_header(array<string> p) =>
    t = int(str.tonumber(p.get(0)))
    (showEmoji ? EMOJI.get(t) + "  " : "") + p.get(1) + (showTheme ? "   |   " + THEMES.get(t) : "")
 
// ---------- Card ----------
pos = switch posSel
    "Top left"      => position.top_left
    "Top center"    => position.top_center
    "Middle left"   => position.middle_left
    "Middle center" => position.middle_center
    "Middle right"  => position.middle_right
    "Bottom left"   => position.bottom_left
    "Bottom center" => position.bottom_center
    "Bottom right"  => position.bottom_right
    => position.top_right
 
txtSize = switch sizeSel
    "Tiny"  => size.tiny
    "Small" => size.small
    "Large" => size.large
    => size.normal
 
// Plain strings (not text.align_* constants) so the choice can come from a setting.
halign = alignSel == "Left" ? "left" : alignSel == "Right" ? "right" : "center"
 
var table card = table.new(pos, 1, 3, bgcolor = cBg, frame_color = cFrame, frame_width = frameW, border_width = 0)
 
// Pine only accepts a fixed text style on a cell, so each style choice gets its own call.
f_cell(int row, string txt, color col, color bg, string sty) =>
    if sty == "Bold"
        card.cell(0, row, txt, text_color = col, text_size = txtSize, text_halign = halign, bgcolor = bg, text_formatting = text.format_bold)
    else if sty == "Italic"
        card.cell(0, row, txt, text_color = col, text_size = txtSize, text_halign = halign, bgcolor = bg, text_formatting = text.format_italic)
    else if sty == "Bold + Italic"
        card.cell(0, row, txt, text_color = col, text_size = txtSize, text_halign = halign, bgcolor = bg, text_formatting = text.format_bold + text.format_italic)
    else
        card.cell(0, row, txt, text_color = col, text_size = txtSize, text_halign = halign, bgcolor = bg)
 
if barstate.islast
    key = f_key(timenow, time_tradingday)
    // Shuffle: TradingView reuses the result for a setting it has already seen, so a checkbox could
    // only flip between two quotes. A number gives a new value, and a new quote, on every click.
    // Scrambled with the day so the shuffle order changes daily.
    p = f_entry(shuffleN > 0 ? (shuffleN * shuffleN * 7919 + shuffleN * 104729 + key * 31) % 1000003 : key)
    verse = showQuote ? "\"" + p.get(2) + "\"" : p.get(2)
    f_cell(0, f_header(p), cRef, hlRef ? cHlRef : cBg, styRef)
    f_cell(1, f_wrap(verse, wrapW), cVerse, hlVerse ? cHlVer : cBg, styVerse)
    f_cell(2, f_wrap(p.get(3), wrapW), cRefl, hlRefl ? cHlRefl : cBg, styRefl)
 
// ---------- Alert ----------
kBar = f_key(time, time_tradingday)
if alertOn and barstate.isrealtime and kBar != kBar[1]
    a = f_entry(kBar)
    alert(a.get(1) + " - \"" + a.get(2) + "\"  " + a.get(3), alert.freq_once_per_bar)

← 返回列表