Fractal Boxes by Mobius for ThinkorSwim

markos

markos

Well-known member
VIP
Warehouse


Code:
# Fractal Boxes
# Mobius 2017
# Altered Fractals to show Box Breakouts

input sequenceCount = 4;

def maxSideLength = sequenceCount + 10;
def upRightSide = fold i1 = 1 to maxSideLength + 1
                  with count1
                  while count1 != sequenceCount and
                        count1 != -1
                  do if GetValue(high, -i1) > high or
                       (GetValue(high, -i1) == high and
                        count1 == 0)
                     then -1
                     else if GetValue(high, -i1) < high
                          then count1 + 1
                          else count1;
def upLeftSide = fold i2 = 1 to maxSideLength + 1
                 with count2
                 while count2 != sequenceCount and
                       count2 != -1
                 do if GetValue(high, i2) > high or
                      (GetValue(high, i2) == high and
                       count2 >= 1)
                    then -1
                    else if GetValue(high, i2) < high
                         then count2 + 1
                         else count2;
def downRightSide = fold i3 = 1 to maxSideLength + 1
                    with count3
                    while count3 != sequenceCount and
                          count3 != -1
                    do if GetValue(low, -i3) < low or
                         (GetValue(low, -i3) == low and
                          count3 == 0)
                          then -1
                        else if GetValue(high, -i3) > low
                             then count3 + 1
                             else count3;
def downLeftSide = fold i4 = 1 to maxSideLength + 1
                   with count4
                   while count4 != sequenceCount and
                         count4 != -1
                   do if GetValue(low, i4) < low or
                        (GetValue(low, i4) == low and
                         count4 >= 1)
                      then -1
                      else if GetValue(low, i4) > low
                      then count4 + 1
                      else count4;

def UF = if upRightSide == sequenceCount and
                    upLeftSide == sequenceCount
                 then high
                 else UF[1];
def pUF = if UF != UF[1]
          then UF[1]
          else pUF[1];
def DF = if downRightSide == sequenceCount and
                      downLeftSide == sequenceCount
                   then low
                   else DF[1];
def pDF = if DF != DF[1]
          then DF[1]
          else pDF[1];
plot UpFractal = UF;
plot DownFractal = DF;
def trend = if UF > pUF and DF > pDF
            then 1
            else if UF < pUF and DF < pDF
            then -1
            else 0;
UpFractal.SetPaintingStrategy(PaintingStrategy.Horizontal);
UpFractal.AssignValueColor(if Trend == 1
                           then color.green
                           else if Trend == -1
                                then color.red
                                else color.white);
UpFractal.SetLineWeight(2);
DownFractal.SetPaintingStrategy(PaintingStrategy.Horizontal);
DownFractal.AssignValueColor(if Trend == 1
                           then color.green
                           else if Trend == -1
                                then color.red
                                else color.white);
DownFractal.SetLineWeight(2);
AddCloud(if Trend ==  1 then UpFractal else double.nan, DownFractal, Color.green, Color.green);
AddCloud(if Trend == -1 then UpFractal else double.nan, DownFractal, Color.red, Color.red);
AddCloud(if Trend ==  0 then UpFractal else double.nan, DownFractal, Color.white, Color.white);
Code Share: http://tos.mx/SEidEM
 
Last edited by a moderator:
markos

markos

Well-known member
VIP
Warehouse
This Fractal Boxes study may have alerted you to the downside break if it had alarms put on it.
Or the break beyond the Expected Move, possibly. Had to kill the premium sellers without a net (hedge) today.
It's all there in the chart share.
Could someone please backtest it on a few short timeframes?
 
mc01439

mc01439

Active member
VIP
Warehouse
/CL (1) contract - raw signal to raw signal.

def sellsignal = Trend == -1 and close < DownFractal;
def buysignal = Trend == 1 and close > UpFractal;

AddOrder(OrderType.SELL_AUTO, sellsignal equals 1, close, 1, Color.RED, Color.RED);
AddOrder(OrderType.BUY_AUTO, buysignal equals 1, close, 1, Color.GREEN, Color.GREEN);

Example:
5M-180days = +$4,670 / 254 trades
10M-180days = -3,860 / 159 trades
15M-180days = -670 / 99 trades
30M-180days = +15,180.00 / 53 trades
1H-180days = +3,850.00 / 23 trades
4H-180days = -11,930 / 12 trades
1D-5years = +22,780 / 7 trades
 
markos

markos

Well-known member
VIP
Warehouse
Thanks @mc01439 ! (y)
I guess it more of a consolidation zone to help keep nervous folks in a trade by showing them there's no need to panic until it breaks out. Any thoughts? Just curious on your take. Hope you had a good day, markos
 
Last edited:
T

Talochka

New member
Thanks @mc01439 ! (y)
I guess it more of a consolidation zone to help keep nervous folks in a trade by showing them there's no need to panic until it breaks out. Any thoughts? Just curious on your take. Hope you had a good day, markos
Hello , where can I find Mobius_IMO_ms? Thanks
 
T

Talochka

New member
Thanks @mc01439 ! (y)
I guess it more of a consolidation zone to help keep nervous folks in a trade by showing them there's no need to panic until it breaks out. Any thoughts? Just curious on your take. Hope you had a good day, markos
It is on the bottom of the screen
 
markos

markos

Well-known member
VIP
Warehouse
It is on the bottom of the screen
Have you been through the tutorials on this site yet? It's a pretty good place to start. The TMO oscillator by Mobius can be found in several places.
Here are two:


In this second entry you will find links to more TMO information. RSI Laguerre is closely associated with it, thus it is intertwined in many threads.
 
T

Talochka

New member
Have you been through the tutorials on this site yet? It's a pretty good place to start. The TMO oscillator by Mobius can be found in several places.
Here are two:


In this second entry you will find links to more TMO information. RSI Laguerre is closely associated with it, thus it is intertwined in many threads.
thanks
 

Top