Automatic Quadrant Lines for ThinkorSwim

chewie76

Well-known member
VIP Enthusiast
Odd... I added it while I still had the original in place and the original stayed motionless while the alternate was moving with price action... Notice the lime colored line from the alternate...

j1NddlK.png
I'm using this code with an input barsback. What am I doing wrong?
def c2 = if !IsNaN(close) and IsNaN(close[-1])
then close
else c2[1];
plot priceLine = if isNaN(close[-barsBack])
then c2[-barsBack]
else Double.NaN;
 

rad14733

Well-known member
VIP
@chewie76 Yeah, I just pasted the code I use into your study and it also lags while my external priceline continues to move... That tells me there is some inherent lag in the study for some reason... It can't be just that code that is lagging, or at least I wouldn't think it could be... Interesting...

Edited at add: And those are the only two indicators on the chart...
 

chewie76

Well-known member
VIP Enthusiast
@chewie76 Yeah, I just pasted the code I use into your study and it also lags while my external priceline continues to move... That tells me there is some inherent lag in the study for some reason... It can't be just that code that is lagging, or at least I wouldn't think it could be... Interesting...

Edited at add: And those are the only two indicators on the chart...
Ah, I may just remove that from my code and have it by itself. Thanks!
 

rad14733

Well-known member
VIP
@chewie76 Ok... After looking over the code I'm wondering if the sheer number of fold() and Highest() and the other HighestAll() are causing the issue... Try replacing the other instance(s) of HighestAll() first...
 

s1111

Active member
Supposed to be price level. It works well on the mobile, but the desktop looks delayed. TOS has some issue with how the code works.

I was so confused lol . I have a separate priceline indicator so when I saw priceline from your script which is very leggy I thought it's for something else . Thanks for the info
 

tem2005

Member
VIP
there are cases where when price goes against the arrows direction the arrows disappear, i don't know in this case if its a stop loss or the previous signal is considered again valid. another case is sometimes price breaks out or down the lines entries, arrows is still not showing so what you guys think whether this is an entry even no signal shown or no trade considered?
 

Ghostwar19

Member
VIP
there are cases where when price goes against the arrows direction the arrows disappear, i don't know in this case if its a stop loss or the previous signal is considered again valid. another case is sometimes price breaks out or down the lines entries, arrows is still not showing so what you guys think whether this is an entry even no signal shown or no trade considered?
I wouldnt look at the arrows, always look at price and how it reacts with the lines.
 

meyh3m

New member
this indicator is good to know where price is headed or will stop dropping at. but you will need to acquire proper knowledge of price action to effective apply this especially on choppy days
 

vighnaraj

New member
Hi,

Could you please post the script to color the candles the way you show it on your chart with the meaning of each color or the criteria for painting the candles red versus yellow, green etc?
 

chewie76

Well-known member
VIP Enthusiast
Hi,

Could you please post the script to color the candles the way you show it on your chart with the meaning of each color or the criteria for painting the candles red versus yellow, green etc?
That's a paid indicator.
 

MatthewA

Active member
@chewie76
Wow! Just Wow!
As usual you create something similar to my thoughts!

I have some ideas to combine this and you Fib lines into an intelligent Ewave, Wolf Wave, Harmonic that can be confirmed or challenged by order flow...
I will contact you on discord
 

tem2005

Member
VIP
I wouldnt look at the arrows, always look at price and how it reacts with the lines.
because arrows give more confidence where prices do breakout the entry line. what if price goes above the line without arrow and it pullback? then in here i believe it is right not to get in when price went above that!
 

vloqnam

New member
VIP
Can you please show how to scan for S1 in first bar alert? i tried to set up S1 is true but not work the way i want.
 

chewie76

Well-known member
VIP Enthusiast
Can you please show how to scan for S1 in first bar alert? i tried to set up S1 is true but not work the way i want.
Not sure since it will appear for each bar that is lower than the previous S1 bar.
 

Mr.Hockey

New member
The Automatic Quadrant Lines is a trading strategy upper indicator that projects where price might go in the future. Use weekly/daily/4 hr chart for swing trading. Use 30 min or less for day trading. This indicator shows you the long entry and long target. It shows you a short entry and short target. In the indicator, L/E is Long Entry, and S/E is Short Entry. The targets show the price in the chart bubble. There is a break down target line (dark green) that indicates if price breaks lower than the support line, this is where price may break down to. The indicator includes an up and down arrow that indicates when price breaks through the Long or Short Entry line. There are also alerts built in when the arrows appear.

Long strategy lines are dashed and have a (2) weight while short strategy are solid and single weighted lines.

(NOTE: If price breaks down or up from the dark red support and resistance lines, a new set of lines will appear. There are no guarantees price will hit the target.)

Here are some examples.

/RTY on 4 hr chart.
QHCgUTb.jpg


/ES on 15m chart. Price broke above target on FED news.
eXuBWHZ.jpg


/NQ on 4 hr chart. Hit target.
6f667mU.jpg


Tesla on 4 hr chart. Above the 50% line. Target at $751.80.
xZ8fu65.jpg


/SI on 10 min chart. Hit target.
nTh5CZH.jpg


Shareable Link:
http://tos.mx/2pnajoG

Long Entry Scan Alert
http://tos.mx/3Jppd0g

Short Entry Scan Alert
http://tos.mx/KGlOVLi

CODE:

Code:
#Automatic Quadrant Lines

#based on Mobius's Fractal Pivot Strategy

#developed by Chewie76 on 8/27/2021



# User Inputs

input n = 20;

input FractalEnergyLength = 8;

input FractalEnergyThreshold = .68;

input AtrMult = .70;

input nATR = 4;

input AvgType = AverageType.HULL;

input LabelsOn = yes;

input AlertsOn = yes;



# Variables

def o = open;

def h = high;

def l = low;

def c = close;

def bar = BarNumber();

def TS = TickSize();

def nan = double.nan;

def ATR = Round((MovingAverage(AvgType, TrueRange(h, c, l), nATR)) / TS, 0) * TS;

def risk = if Between(c, 0, 1500)

           then ATR

           else if Between(c, 1500, 3500)

           then 2

           else if Between(c, 3500, 5500)

                then 4

           else 6;

def FE = Log(Sum((Max(h, c[1]) - Min(l, c[1])), FractalEnergyLength) /

        (Highest(h, FractalEnergyLength) - Lowest(l, FractalEnergyLength)))

            / Log(FractalEnergyLength);

# Parent Aggregation Pivot High

# Pivot High Variables

def p_hh = fold i = 1 to n + 1

           with p = 1

           while p

           do h > GetValue(h, -1);

def p_PivotH = if (bar > n and

                   h == Highest(h, n) and

                   p_hh)

               then h

               else NaN;

def p_PHValue = if !IsNaN(p_PivotH)

                then p_PivotH

                else p_PHValue[1];

def p_PHBar = if !IsNaN(p_PivotH)

                    then bar

                    else nan;

# Pivot High and Pivot High Exit Variables

# Pivot High Variables

def hh = fold ii = 1 to n + 1

         with pp = 1

         while pp

         do h > GetValue(h, -1);

def PivotH = if (bar > n and

                 h == Highest(h, n) and

                 hh)

            then h

            else Double.NaN;

def PHValue = if !IsNaN(PivotH)

              then PivotH

              else PHValue[1];

def PHBar = if !IsNaN(PivotH)

                  then bar

                  else nan;

# Pivot High Exit Variables

def PHExit = if (bar > n and

              h == Highest(h, n) and

              hh)

             then if l[1] < l

                  then l[1]

                  else fold r = 0 to 20

                       with a = NaN

                       while IsNaN(a)

                       do if GetValue(l[1], r) < l

                          then GetValue(l[1], r)

                          else NaN

            else Double.NaN;

def PHExitValue = if !IsNaN(PHExit)

                  then PHExit

                  else PHExitValue[1];

def PHExitBar = if (bar > n and

                    h == Highest(h, n) and

                    hh)

                then if l[1] < l

                then bar - 1

                else fold d = 0 to 20

                     with y = NaN

                     while IsNaN(y)

                     do if GetValue(l[1], d) < l

                        then GetValue(bar - 1, d)

                        else NaN

                else NaN;

# Pivot Low and Pivot Low Entry Variables

# Parent Pivot Low Variables

def p_ll = fold j = 1 to n + 1

           with q = 1

           while q

           do l < GetValue(l, -1);

def p_PivotL = if (bar > n and

                 l == Lowest(l, n) and

                 p_ll)

             then l

             else NaN;

def p_PLValue = if !IsNaN(p_PivotL)

              then p_PivotL

              else p_PLValue[1];

def p_PLBar = if !IsNaN(p_PivotL)

              then bar

              else nan;



# Pivot Low Variables

def ll = fold jj = 1 to n + 1

         with qq = 1

         while qq

         do l < GetValue(l, -1);

def PivotL = if (bar > n and

                 l == Lowest(l, n) and

                 ll)

             then l

             else NaN;

def PLValue = if !IsNaN(PivotL)

              then PivotL

              else PLValue[1];

def PLBar = if !IsNaN(PivotL)

            then bar

            else nan;



# Pivot Low Entry Variables

def PLEntry = if (bar > n and

                  l == Lowest(l, n) and

                  ll)

              then if h[1] > h

              then h[1]

              else fold t = 0 to 20

                   with w = NaN

                   while IsNaN(w)

                   do if GetValue(h[1], t) > h

                      then GetValue(h[1], t)

                      else NaN

              else NaN;

def PLEntryValue = if !IsNaN(PLEntry)

                   then PLEntry

                   else PLEntryValue[1];

def PLEntryBar =  if (bar > n and

                  l == Lowest(l, n) and

                  ll)

                  then if h[1] > h

                       then bar - 1

                       else fold u = 0 to 20

                            with z = NaN

                            while IsNaN(z)

                            do if GetValue(h[1], u) > h

                               then GetValue(bar - 1, u)

                               else NaN

              else NaN;



# Plots



plot R1 = if bar >= HighestAll(PHBar)

          then HighestAll(if isNaN(close[-1])

                          then PHValue

                          else nan)

         else nan;

R1.SetDefaultColor(Color.dark_red);

R1.SetLineWeight(1);

plot ShortEntry = if bar >= HighestAll(PHexitBar)

                   then HighestAll(if isNaN(close[-1])

                                   then PHExitValue

                                   else nan)

                   else nan;

ShortEntry.SetDefaultColor(Color.red);

def SE =(if isNaN(ShortEntry[1]) then ShortEntry else Double.NaN);

addchartBubble(LabelsOn and ShortEntry, SE,"S/E",color.red);



plot S1 = if bar >= HighestAll(PLBar)

          then HighestAll(if isNaN(c[-1])

                          then PLValue

                          else nan)

          else nan;

S1.SetDefaultColor(Color.dark_red);

S1.SetLineWeight(3);

plot LongEntry = if bar >= HighestAll(PLEntryBar)

                    then HighestAll(if isNaN(c[-1])

                                    then PLEntryValue

                                    else nan)

                    else nan;

LongEntry.SetDefaultColor(Color.GREEN);

LongEntry.SetStyle(Curve.long_DASH);

LongEntry.SetLineWeight(2);

def LE =(if isNaN(LongEntry[1]) then LongEntry else Double.NaN);

addchartBubble(LabelsOn and LongEntry, LE,"L/E",color.green);


plot UpArrow = if c crosses above LongEntry and FE > .5

               then l

               else Double.NaN;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

UpArrow.SetLineWeight(5);

UpArrow.SetDefaultColor(Color.GREEN);

plot DnArrow = if c crosses below ShortEntry and ((FE > .618)

                or (FE < .382))

               then h

               else Double.NaN;

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

DnArrow.SetLineWeight(5);

DnArrow.SetDefaultColor(Color.RED);



plot Fifty = (LongEntry - S1) + LongEntry;

Fifty.setdefaultcolor(color.yellow);

Fifty.SetStyle(Curve.long_DASH);

Fifty.setlineweight(2);



plot SeventyFive = (LongEntry - S1) + Fifty;

SeventyFive.setdefaultcolor(color.cyan);

SeventyFive.SetStyle(Curve.long_DASH);

SeventyFive.setlineweight(2);



plot Target = (LongEntry - S1) + SeventyFive;

Target.setdefaultcolor(color.red);

Target.SetStyle(Curve.long_DASH);

Target.setlineweight(3);

def LT =(if isNaN(TARGET[1]) then Target else Double.NaN);

addchartBubble(LabelsOn and Target, LT,"LONG TARGET: " + asDollars(LT),color.red);



plot BreakDownTarget = S1 -(LongEntry - S1);

BreakDownTarget.setdefaultcolor(color.dark_Green);

BreakDownTarget.SetStyle(Curve.long_DASH);

BreakDownTarget.setlineweight(3);



plot S_Fifty = ShortEntry - (R1 - ShortEntry);

S_Fifty.setdefaultcolor(color.yellow);

S_Fifty.setlineweight(1);



plot S_SeventyFive = S_Fifty - (R1 - ShortEntry);

S_SeventyFive.setdefaultcolor(color.cyan);

S_SeventyFive.setlineweight(1);



plot S_ShortTarget = S_SeventyFive - (R1 - ShortEntry);

S_ShortTarget.setdefaultcolor(color.green);

S_ShortTarget.setlineweight(1);

def ST =(if isNaN(S_ShortTarget[1]) then S_ShortTarget else Double.NaN);

addchartBubble(LabelsOn and S_ShortTarget, ST,"SHORT TARGET: " + asDollars(ST),color.light_green);



# Alerts

Alert(AlertsOn and UpArrow, " ", Alert.Bar, Sound.ding);

Alert(AlertsOn and DnArrow, " ", Alert.Bar, Sound.ding);

Hey, how can I add this as a strategy so I can backtest it on multiple different time frames.
 

Similar threads

Top