Auto Fib on Previous Bar(5 min, 10 min, etc.,)

jackjac2019

New member
Hi, I am new to trading and learning on TOS SIM. I did went through lot of threads and learned a lot. Lot of bright and helpful people helping others like me. I have absolutely no programming experience. If anyone can help that is greatly appreciated.

1) Is it possible to draw auto fib lines on the previous 5 min bar (a) when the bar (b) starts.
2) Move on the auto fibs to the next 5 min bar (b) once that bar (a) closes and when a new bar(c) opens. Hide the old bar (a) fib's and so on.

I ask as I observed after the market slows down like after 10:30 AM EST, the price direction reacts/attracts to which co-efficient # the new bar opens and travels that side (mostly) giving a "POINT" or 2 on futures for scalping like /NQ (if it is really good bar like > 3 point bar and more.)

Thanks much.
 
Last edited:
Hi, I am new to trading and learning on TOS SIM. I did went through lot of threads and learned a lot. Lot of bright and helpful people helping others like me. I have absolutely no programming experience. If anyone can help that is greatly appreciated.

1) Is it possible to draw auto fib lines on the previous 5 min bar (a) when the bar (b) starts.
2) Move on the auto fibs to the next 5 min bar (b) once that bar (a) closes and when a new bar(c) opens. Hide the old bar (a) fib's and so on.

I ask as I observed after the market slows down like after 10:30 AM EST, the price direction reacts/attracts to which co-efficient # the new bar opens and travels that side (mostly) giving a "POINT" or 2 on futures for scalping like /NQ (if it is really good bar like > 3 point bar and more.)

Thanks much.

See if this helps. You can change the fib levels at the input screen to what you use.

Capture.jpg

Code:
def na = Double.NaN;
input onexpansion = yes;
input displace = 0;

input Fpos236 = .236;
input Fpos382 = .382;
input Fpos50  = .5;
input Fpos618 = .618;
input Fpos764 = .764;

def rhi =  if isnan(close) then rhi[1] else high[1];
def rlo =  if isnan(close) then rlo[1] else low[1];
def range  = rHi - rLo;
def F236   = rHi - (range * Fpos236);
def F382   = rHi - (range * Fpos382);
def F50    = rHi - (range * Fpos50);
def F618   = rHi - (range * Fpos618);
def F764   = rHi - (range * Fpos764);

    plot ORH;
    plot ORL;  
    plot Fib50;
    plot Fib236;
    plot Fib382;
    plot Fib618;
    plot Fib764;
    ORH      = if onexpansion and !isnan(close) then double.nan else rhi;
    ORL      = if onexpansion and !isnan(close) then double.nan else rlo;
    Fib50    = if onexpansion and !isnan(close) then double.nan else F50;
    Fib236   = if onexpansion and !isnan(close) then double.nan else F236;
    Fib382   = if onexpansion and !isnan(close) then double.nan else F382;
    Fib618   = if onexpansion and !isnan(close) then double.nan else F618;
    Fib764   = if onexpansion and !isnan(close) then double.nan else F764;



ORH.SetDefaultColor(Color.GREEN);
ORH.setpaintingStrategy(paintingStrategy.HORIZONTAL);
ORH.SetLineWeight(2);

ORL.SetDefaultColor(Color.RED);
ORL.setpaintingStrategy(paintingStrategy.HORIZONTAL);
ORL.SetLineWeight(2);

Fib50.SetDefaultColor(Color.WHITE);
Fib50.setpaintingStrategy(paintingStrategy.HORIZONTAL);
Fib50.SetLineWeight(1);

Fib236.SetDefaultColor(Color.CYAN);
Fib236.setpaintingStrategy(paintingStrategy.HORIZONTAL);
Fib236.SetLineWeight(1);

Fib382.SetDefaultColor(Color.MAGENTA);
Fib382.setpaintingStrategy(paintingStrategy.HORIZONTAL);
Fib382.SetLineWeight(1);

Fib618.SetDefaultColor(Color.YELLOW);
Fib618.setpaintingStrategy(paintingStrategy.HORIZONTAL);
Fib618.SetLineWeight(1);

Fib764.SetDefaultColor(Color.DARK_RED);
Fib764.setpaintingStrategy(paintingStrategy.HORIZONTAL);
Fib764.SetLineWeight(2);

input showfib_bubbles = yes;
input n = 5;
def  n1 = n +1;
AddChartBubble(showfib_bubbles and !IsNaN(close[n1 + if onexpansion then 1 else 0]) and IsNaN(close[n]), orh[n1], orh[n1], Color.green, yes);
AddChartBubble(showfib_bubbles and !IsNaN(close[n1 + if onexpansion then 1 else 0]) and IsNaN(close[n]), orl[n1], orl[n1], Color.red, no);
AddChartBubble(showfib_bubbles and !IsNaN(close[n1 + if onexpansion then 1 else 0]) and IsNaN(close[n]), fib618[n1], aspercent(fpos618), Color.cyan, yes);
AddChartBubble(showfib_bubbles and !IsNaN(close[n1 + if onexpansion then 1 else 0]) and IsNaN(close[n]), fib236[n1], aspercent(fpos236), Color.yellow, yes);
AddChartBubble(showfib_bubbles and !IsNaN(close[n1 + if onexpansion then 1 else 0]) and IsNaN(close[n]), fib50[n1], aspercent(fpos50), Color.yellow, yes);
AddChartBubble(showfib_bubbles and !IsNaN(close[n1 + if onexpansion then 1 else 0]) and IsNaN(close[n]), fib382[n1], aspercent(fpos382), Color.white, yes);
AddChartBubble(showfib_bubbles and !IsNaN(close[n1 + if onexpansion then 1 else 0]) and IsNaN(close[n]), fib764[n1], aspercent(fpos764), Color.yellow, yes);
 
Last edited:
@SleepyZ This is wonderful.

What I observed this afternoon on good long bars, using your code and using the limit order's.

If the price hits 61.8% from Bottom, it tries to go to 38.2%, but sometimes little short or over shoots.
If it hits 38.2% from Top, it tries to go to 61.8%, but sometimes little short or over shoots.
If it opens red below the 76.4%, it tries to go to the next level, but sometimes little short or over shoots.
If it open's Green above 23.6%, it tries to go to the next level, but sometimes little short or over shoots.

Your code will help me with my practice on TOS SIM/Paper trading. I guess Screen Time is the best training. Thanks Much.

Disclaimer: As usual this is all for practicing on Paper Trading to understand and not a trading advise for anyone. Trade at your own risk.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
441 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top