• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Pre-market High Low Indicator with Fibonacci for ThinkorSwim

Johnnyboyeh

New member
Hey, I have a similar question to the poster above me who is asking if there is a way to set an alert for this study based on a specific coefficient be broken above or below. I would like to be alerted if the stock breaks the premarket high or low in this study. Thanks.
 

tomsk

Well-known member
VIP
@Johnnyboyeh This study has the following coefficients defined:

Code:
input coeff_1 = .236;
input coeff_2 = .327;
input coeff_3 = .500;
input coeff_4 = .618;
input coeff_5 = .789;
input coeff_6 = .882;

Note that some of these coefficients are not fibonacci ratios e.g. .327, .789, .882
I imagine that the author might have wanted those levels for reasons known to him.

Suppose you want to be alerted if the price closes above/below the 50% coefficient, just add the following lines to the end of the study

Alert(close crosses below coeff3, "Below 50% Fib", Alert.Bar, Sound.Ring);
Alert(close crosses above coeff3, "Above 50% Fib", Alert.Bar, Sound.Ding);

Hope this helps
 
Last edited:

fcastrof

New member
Hi i appreciate if you know how plot the high and the low of the last hour of premarket. Thanks in advance for your help.
 

tomsk

Well-known member
VIP
Noticed that you've been asking this question several times across more than one different thread. Did you not see my response I posted here?

https://usethinkscript.com/threads/custom-indicator-in-watchlist-opening-range.1457/#post-13525
I spent quite some time looking into the code you provided, and even wrote a separate standalone study to confirm that, there's absolutely nothing wrong with your premarket high/low code that you posted here.

https://usethinkscript.com/threads/custom-indicator-in-watchlist-opening-range.1457/
 

Tally

New member
VIP
@BenTen I think this is a great indicator but for some reason on the low of premarket its not actually plotting the lowest bar/candlestick? also...is there a way to plot the open and close of the very first bar/candlestick? Thanks in advance. good stuff!
 

tomsk

Well-known member
VIP
@Tally Since @BenTen may not have an opportunity to respond to your query, I looked into the issue you pointed out. Several studies were shared above. My assumption is that you are referring to post #3 above. Looking through the code I can ascertain that it certainly is capturing the high/low of the premarket.

To convince yourself, run the following code on a 1 minute chart of say /ES or whatever equity you're tracking. This was extracted from post#3 and modified slightly to display the GlobeX/overnight period. A reading of 1 denotes the premarket period. Personally I see no issues here. This is always the best way to see if the period under consideration is correct or not.

Code:
declare lower;
plot GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
 

Tally

New member
VIP
@tomsk i have tried 1 min timeframe...on all timeframes with code you have posted declare lower still shows from premarket same day but its not including extended hours from pervious night. i have to draw the lower horizontal trend line. not an issue but just wanted to respond
 

Utajiri

New member
Hi @korygill - I picked up on this premarket Hilo code you built. Awesome.... Is there a way to add a marker or bubble input to it.... just so it can be identified in the midst of multiple lines on a chart?
 

korygill

Active member
VIP
Try this update to put a chart bubble on each line.

rSZuRf8.png


Code:
#
# see https://usethinkscript.com/threads/how-to-get-current-days-premarket-high.695/
#
declare once_per_bar;

input PlotPreMktLinesHrsPastOpen = yes;
input ShowChartBubbles = yes;

def bar = BarNumber();
def nan = Double.NaN;
def vHigh = high;
def vLow = low;

def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();
def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime();
def PMStart = RMhrs[1] and PMhrs;
def PMHigh = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMHigh[1]) else PMHigh[1], 0);
def PMLow = CompoundValue(1, if PMStart then vLow else if PMhrs then Min(vLow, PMLow[1]) else PMLow[1], 0);
def highBar = if PMhrs and vHigh == PMHigh then bar else nan;
def lowBar = if PMhrs and vLow == PMLow then bar else nan;
def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1];
def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1];

plot PMH =  if PlotPreMktLinesHrsPastOpen and PMHighBar != 0
            then PMHighBar
            else nan;
plot PML =  if PlotPreMktLinesHrsPastOpen and PMLowBar != 0
            then PMLowBar
            else nan;
plot PMMid = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 and PMLowBar != 0
             then (PMHighBar + PMLowBar) / 2
             else nan;

AddChartBubble(ShowChartBubbles and bar == HighestAll(highBar),
  PMHigh,
  "PM High",
  Color.Gray,
  1);

AddChartBubble(ShowChartBubbles and bar == HighestAll(lowBar),
  PMLow,
  "PM Low",
  Color.Gray,
  0);

AddChartBubble(ShowChartBubbles and bar == Max(HighestAll(highBar), HighestAll(lowBar)),
  (PMHighBar + PMLowBar) / 2,
  "PM Mid",
  Color.Gray,
  1);

# end of script
 

Utajiri

New member
Thanks @korygill - appreciate it. Can we however have an additional input on where to place the bubble? Something like a "distance from last candle" input..... which allows us input a value and it places the chart bubble where we want it... either to the left,right or center?
 

Buckbull

Active member
@BenTen is there a way to put this in a scan for the 15 min chart a candle close above the pre market high ? and a close below pre market low Thanks
 
Last edited:

BenTen

Administrative
Staff
VIP
@Buckbull You would want something like “close crosses above or below pre-market high or low”. Depending on what you need.
 

Similar threads

Top