Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

Fun with ThinkScript

Posted by robert 
Re: count highs and lows
March 19, 2019 08:13AM
Hi se,

I used this one to analyze swings.

#There were modifications added to allow input of ATR length and factor, bubble color coding, bubble placement and bubbles showing or not. There is now code to add bubbles for price, volume, and bar count at each zigzag, in addition to the existing code to record change between zigzags:

# bubble colors are based upon higher high (green)/ lower low (red) / no change (yellow) to previous zigzag
input showBubblesprice = yes;
input showBubbleschange = yes;
input showBubblesbarcount = yes;
input showBubblesVolume = yes;
input bubbleoffset = 3;
def price = close;
def priceH = high; # swing high
def priceL = low; # swing low
input ATRreversalfactor = 2.2;
input ATRlength = 7;
def ATR = reference ATR(length = ATRlength);
def zzSave = if !IsNaN(data) then if (barNumber == barCount or barNumber == 1) then if IsNaN(barNumber[-1]) and state == state.uptrend then priceH else priceL else currentPriceLevel else GetValue(zzSave, 1);

def chg = (if barNumber == barCount and currentPoints < 0 then priceH else if barNumber == barCount and currentPoints > 0 then priceL else currentPriceLevel) - GetValue(zzSave, 1);

def isUp = chg >= 0;

#Higher/Lower/Equal High, Higher/Lower/Equal Low
def xxhigh = if zzSave == priceH then priceH else xxhigh[1];
def chghigh = priceH - xxhigh[1];
def xxlow = if zzSave == priceL then priceL else xxlow[1];
def chglow = priceL - xxlow[1];
#def xxhigh = if zzSave == priceH then Round(high, 2) else Round(xxhigh[1], 2);
#def chghigh = Round(high, 2) - Round(xxhigh[1], 2);
#def xxlow = if zzSave == priceL then Round(low, 2) else Round(xxlow[1], 2);
#def chglow = Round(Round(low, 2) - Round(xxlow[1], 2), 2);

def isConf = AbsValue(chg) >= reversalAmount or (IsNaN(GetValue(data, 1)) and GetValue(isConf, 1));

plot "ZZ$" = if isConf then data else Double.NaN;
"ZZ$".EnableApproximation();
"ZZ$".SetDefaultColor(Color.CYAN);


DefineGlobalColor("Unconfirmed", Color.WHITE);
DefineGlobalColor("Up", Color.UPTICK);
DefineGlobalColor("Down", Color.DOWNTICK);

#Bar Count between zigzags
def zzcount = if zzSave[1] != zzSave then 1 else if zzSave[1] == zzSave then zzcount[1] + 1 else 0;
def zzcounthilo = if zzcounthilo[1] == 0 and (zzSave == priceH or zzSave == priceL) then 1 else if zzSave == priceH or zzSave == priceL then zzcounthilo[1] + 1 else zzcounthilo[1];
def zzhilo = if zzSave == priceH or zzSave == priceL then zzcounthilo else zzcounthilo + 1;
def zzcounthigh = if zzSave == priceH then zzcount[1] else Double.NaN;
def zzcountlow = if zzSave == priceL then zzcount[1] else Double.NaN;

AddChartBubble(showBubblesbarcount and !IsNaN("ZZ$"winking smiley and BarNumber() != 1, if isUp then Max(high, priceH) + bubbleoffset * TickSize() else Min(low, priceL) - bubbleoffset * TickSize() , (if zzSave == priceH then zzcounthigh else zzcountlow) + " bars", if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, if isUp then yes else no );

#Volume at Reversals
def vol = if BarNumber() == 0 then 0 else volume + vol[1];
def vol1 = if BarNumber() == 1 then volume else vol1[1];
def xxvol = if zzSave == priceH or zzSave == priceL then TotalSum(volume) else xxvol[1];
def chgvol = if xxvol - xxvol[1] + vol1 == vol then vol else xxvol - xxvol[1];

AddChartBubble(showBubblesVolume and !IsNaN("ZZ$"winking smiley and BarNumber() != 1, if isUp then priceH + bubbleoffset * TickSize() else priceL - bubbleoffset * TickSize(), chgvol, if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, if isUp then yes else no );

#Price at High/Low
AddChartBubble(showBubblesprice and !IsNaN("ZZ$"winking smiley and BarNumber() != 1, if isUp then priceH + bubbleoffset * TickSize() else priceL - bubbleoffset * TickSize() , if isUp then AsDollars(priceH) else AsDollars(priceL) , if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, isUp);

AddChartBubble(showBubbleschange and !IsNaN("ZZ$" ) and barNumber != 1, if isUp then priceH + bubbleoffset * TickSize() else priceL - bubbleoffset * TickSize() , AsDollars(Round(chg, 2)) , if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, if isUp then yes else no );
Re: Study filter - hourly intraday - condition met for any of 7 candles
March 19, 2019 10:43PM
anyone to help?
se
Re: count highs and lows
March 20, 2019 12:26PM
Hi Billy101,
Thank you. Some errors/questions?
1. I added a ) after BarNumber(). Like this: AddChartBubble(showBubblesVolume and !IsNaN("ZZ$"and BarNumber()) != 1. Is this correct
2. but I am not sure how to get a future BarNumber[-1]??
3. Also, are these variables defined? data, barcount, state
4. from: [researchtrade.com]
5. the below works, replace it for the last bubble.
def dLo = xxLow;
def dHi = xxHigh;
def diff = xxHigh - xxLow;
def avg = average(diff,1900);
input xSp = "          ";
AddChartBubble(showBubbleschange and !IsNaN("ZZ$" ) and barNumber != 1, close+2.5, 
if isUp 
then avg+ "\n"+"this"+dHi+"\n"+xSp+"-"+diff + "\nlast "+dLo
else avg+ "\n"+"last"+dLo+"\n"+xSp+"-"+diff + "\nthis  "+dHi
,color.white,yes);
6. But I can't figure out why diff is sometimes negative number, even when I take the abs.
Thanks so much! On the other hand, if I change it to: def diff = AbsValue(xxHigh - xxLow) and use def avg = average(diff,100), I get a positive number ? But I wonder if this method is really returining the average of the diff's?
7. Does the above seem like a good way to get the range from hi's to low's but on small frames?
SE



Edited 3 time(s). Last edit at 03/20/2019 05:55PM by se.
Custom Watchlist column
March 21, 2019 12:25PM
Hello

Please do anyone know how to create custom column that up date net change during pre market and post market in TOS
Tick Study Alert
March 29, 2019 09:45AM
Hi,

I am trying to add an alert when the cumulative tick crosses above and below the zeroline, I use it on a 5 min chart. The alerts I added produce unreliable results, Any help would be appreciated
# Tick Profile
# Mobius
# V01.01.23.2019

declare lower;

def active = GetTime() >= RegularTradingStart(getYYYYMMDD()) and
GetTime() <= RegularTradingEnd(getYYYYMMDD());
def tick_Bid = if isNaN(tick_count(priceType = "BID"winking smiley)
then tick_Bid[1]
else tick_count(priceType = "BID"winking smiley;
def tick_Ask = if isNaN(tick_count(priceType = "ASK"winking smiley)
then tick_Ask[1]
else tick_count(priceType = "ASK"winking smiley;
def cum_TB = if active and !active[1]
then tick_Bid
else if active
then cum_TB[1] + tick_Bid
else cum_TB[1];
def cum_TA = if active and !active[1]
then tick_Ask
else if active
then cum_TA[1] + tick_Ask
else cum_TA[1];
plot TA = if isNaN(close) or !active
then double.nan
else cum_TA - cum_TB;
TA.SetPaintingStrategy(PaintingStrategy.Squared_Histogram);
TA.AssignValueColor(if TA > 0 and TA >= TA[1]
then color.green
else if TA > 0 and TA <= TA[1]
then color.yellow
else if TA < 0 and TA <= TA[1]
then color.red
else color.orange);
plot zeroline = 0;
#AddLabel(1, "tick at Bid = " + tick_Bid +
# " tick at Ask = " + tick_Ask, if tick_Bid > tick_Ask
# then color.red
# else if tick_Bid == tick_Ask
# then color.white
# else color.green);
# Alerts
#Alert(cum_TA - cum_TB crosses above zeroline , "crossUP", sound = Sound.Ding, "alert type" = Alert.BAR);
#Alert(cum_TA - cum_TB crosses below zeroline , "crossDOWN", sound = Sound.chimes, "alert type" = Alert.BAR);
# End Tick Profile
Re: Fun with ThinkScript
March 31, 2019 02:35AM
Hi,

I'm trying to convert a large study into a workable scan. The portions which are proving difficult are the functions. Here is a sample:
script isABCD {
    input _mode=0;
    input abc=0;
    input bcd=0;
    input d=0;
    input c=0;
    def _abc = abc >= 0.382 and abc <= 0.886;
    def _bcd = bcd >= 1.13 and bcd <= 2.618;
    def ret =_abc and _bcd and (if _mode == 1 then d < c else d > c);

}

def u_abcd2 = isABCD(1,abc,bcd,d,c) and isABCD(1,abc,bcd,d,c)[1]==0;
I've tried a myriad of different approaches to solve the issue, but nothing has worked. I'm hoping a fellow scripter might be able to provide some insight into how a function (script) might be rewritten to work within a scan...

Thanks in advance. Thanks also to Syracusepro for generously sharing the original study and BenTen at usethinkscript for posting it...
Re: Fun with ThinkScript
March 31, 2019 07:18AM
I ask for help in writing the code searching for the roots of an equation using the bisection method whith examples
[www.mathcs.emory.edu]
My code is not accepted whith error in fold while do { }
script func { #  simple fuction
    input x = 0;
    plot f = x - 2.035;
}
script Bisec {
    input a = 1.0001;
    input b = 2.31;
    def e = 0.00001;
    def mn = a;
    def mx = b;
    plot ret = fold i = 0 to 100 with mid=(a +b) / 2 while mx - mn > e do  {
        if func(mn) * func(mid) < 0 then  mx == mid  else  mn == mid;
        mid=(mn + mx) / 2;     
    } 
}

def res =  Bisec().ret;
    AddLabel(yes, "Res = " + res);

Examle Java is very simly

 // Bisection Method - Solves: x^2 - 3 = 0
    
   public class Bisection01
   {
      public static void main(String[] args)
      {
   	 final double epsilon = 0.00001;
   	 double a, b, m, y_m, y_a;
    
   	 a = 0;  b = 4;
    
   	 while ( (b-a) > epsilon )
   	 {
   	    m = (a+b)/2;           // Mid point
    
   	    y_m = m*m - 3.0;       // y_m = f(m)
   	    y_a = a*a - 3.0;       // y_a = f(a)
    
   	    if ( (y_m > 0 && y_a < 0) || (y_m < 0 && y_a > 0) )
   	    {  // f(a) and f(m) have different signs: move b
   	       b = m;
   	    }
   	    else
   	    {  // f(a) and f(m) have same signs: move a
   	       a = m;
   	    }
            System.out.println("New interval: [" + a + " .. " + b + "]"winking smiley;   
                                           // Print progress  
   	 }
    
   	 System.out.println("Approximate solution = " + (a+b)/2 );
      }
   }



Edited 1 time(s). Last edit at 03/31/2019 07:42AM by Stemar.
Re: Fun with ThinkScript
April 01, 2019 11:52PM
Hi,

I am trying to get this scan to work. Despite my best efforts, I am unable to figure out how to properly resolve the portion of the code that is bold and italicized below:

script isRegularFractal {
    input mode = 0;
    plot ret = if mode == 1 then high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0] else if mode == -1 then low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0] else 0;
}

script isBWFractal {
    input mode = 0;
    plot ret = if mode == 1 then high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0] else if mode == -1 then low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0] else 0;
}

input filterBW = No;
input ShowTimeFractals1 = No;

def bn = BarNumber();
def h2 = high[2];
def l2 = low[2];

def filteredtopf = if filterBW then isRegularFractal(1) else isBWFractal(1);
def filteredbotf = if filterBW then isRegularFractal(-1) else isBWFractal(-1);

def b1_0 = if bn == 0 then -1 else if filteredtopf == 0 then 0 else if b1_0[1] > -1 then b1_0[1] + 1 else -1;
def b1_1 = b1_0 + GetValue(b1_0, b1_0 + 1, 0) + 1;
def b1_2 = b1_1 + GetValue(b1_0, b1_1 + 1, 0) + 1;
def b2_0 = if bn == 0 then -1 else if filteredbotf == 0 then 0 else if b2_0[1] > -1 then b2_0[1] + 1 else -1;
def b2_1 = b2_0 + GetValue(b2_0, b2_0 + 1, 0) + 1;
def b2_2 = b2_1 + GetValue(b2_0, b1_1 + 1, 0) + 1;

def higherhigh = if filteredtopf == 0 or b1_2 == b1_1 then 0 else GetValue(high[2], b1_1, 0) < GetValue(high[2], b1_0, 0) and GetValue(high[2], b1_2, 0) < GetValue(high[2], b1_0, 0);
def lowerhigh = if filteredtopf == 0 or b1_2 == b1_1 then 0 else GetValue(high[2], b1_1, 0) > GetValue(high[2], b1_0, 0) and GetValue(high[2], b1_2, 0) > GetValue(high[2], b1_0, 0);
def higherlow = if filteredbotf == 0 or b2_2 == b2_1 then 0 else GetValue(low[2], b2_1, 0) < GetValue(low[2], b2_0, 0) and GetValue(low[2], b2_2, 0) < GetValue(low[2], b2_0, 0);
def lowerlow = if filteredbotf == 0 or b2_2 == b2_1 then 0 else GetValue(low[2], b2_1, 0) > GetValue(low[2], b2_0, 0) and GetValue(low[2], b2_2, 0) > GetValue(low[2], b2_0, 0);

def hh = if bn == 0 then -1 else if higherhigh == 1 then 0 else if hh[1] > -1 then hh[1] + 1 else -1;
def ll = if bn == 0 then -1 else if lowerlow == 1 then 0 else if ll[1] > -1 then ll[1] + 1 else -1;
def higherhhigh = if higherhigh == 0 or hh == -1 then 0 else GetValue(high[2], hh, 0) >= high;
def lowerllow = if lowerlow == 0 or ll == -1 then 0 else GetValue(low[2], ll, 0) <= low;

def istop = if ShowTimeFractals1 then (if higherhhigh  then 1 else 0) else (if filteredtopf then 1 else 0);
def isbot = if ShowTimeFractals1 then (if lowerllow then 1 else 0) else (if filteredbotf then 1 else 0);

def topcount0 = if istop then bn else topcount0[1];
def botcount0 = if isbot then bn else botcount0[1];
def topcount = bn - topcount0;
def botcount = bn - botcount0;

def zigzag = if istop and topcount[1] > botcount[1] then h2 else if isbot and topcount[1] < botcount[1] then l2 else Double.NaN;

def z_0 = if bn == 0 then -1 else if IsNaN(zigzag) == 0 then 0 else if z_0[1] > -1 then z_0[1] + 1 else -1;
def z_1 = z_0 + GetValue(z_0, z_0 + 1, 0) + 1;
def z_2 = z_1 + GetValue(z_0, z_1 + 1, 0) + 1;
def z_3 = z_2 + GetValue(z_0, z_2 + 1, 0) + 1;
def z_4 = z_3 + GetValue(z_0, z_3 + 1, 0) + 1;
def z_5 = z_4 + GetValue(z_0, z_4 + 1, 0) + 1;

def x = GetValue(zigzag, z_4, 0);
def a = GetValue(zigzag, z_3, 0);
def b = GetValue(zigzag, z_2, 0);
def c = GetValue(zigzag, z_1, 0);
def d = GetValue(zigzag, z_0, 0);

#def de = if d and istop then  high else de[1];
#def ce = if c and isbot then  low else ce[1];
#def be = if b and istop then  high else be[1];
#def ae = if a  and isbot then  low else ae[1];
def du = if d and isbot then low else du[1];
def cu = if c and istop then  high else cu[1];
def bu = if b and isbot then  low else bu[1];
def au = if a  and istop then  high else au[1];

#def abc_be;
#def bcd_be;
def abc_bu;
def bcd_bu;

if topcount0 > botcount0 {
 abc_bu = round((AbsValue(bu - cu) / AbsValue(bu- au)),2);
 bcd_bu = round((AbsValue(du - cu) / AbsValue(bu - cu)),2);
# abc_be = round((AbsValue(ae- be) / AbsValue(ae - be)),2);
# bcd_be = round((AbsValue(be - de) / AbsValue(ae - be)),2);
}else {
 abc_bu = round((AbsValue(bu - cu) / AbsValue(bu- au)),2);
 bcd_bu = round((AbsValue(du - cu) / AbsValue(bu - cu)),2);
# abc_be = round((AbsValue(ae- be) / AbsValue(ae - be)),2);
# bcd_be = round((AbsValue(be - de) / AbsValue(ae - be)),2);
}

def bull = between(bcd_bu,1.13,2.618)&& between(abc_bu,.382,.886);
#def bear = between(bcd_be,1.13,2.618)&& between(abc_be,.382,.886);

plot scan = bull;


Any thoughts, comments or suggestions would be gratefully appreciated. Thanks in advance.
Re: Fun with ThinkScript
April 04, 2019 12:12AM
I am trying to create an alert from the following study but keep getting an error and I don't understand what it means. Can anyone help advise what the problem is and if there is a way around it to create an alert? Any help is much appreciated.

I'm trying to create an alert when the DPO line crosses above the upperband or below the lowerband. Here is what I tried for the upperband crossing:
DPO_MOBO()."DPO" crosses above DPO_MOBO()."UpperBandP"

These error messages come up:
Error processing referenced script DPO_MOBO: No such function: compoundValue at 1:1
Error processing referenced script DPO_MOBO: No such function: compoundValue at 1:32
Expected interface com.devexperts.tos.thinkscript.data.IDataHolder at 1:18
Expected interface com.devexperts.tos.thinkscript.data.IDataHolder at 1:18

Here's the study I'm using:
declare lower;
input price = close;
input colorNormLength = 3;
input DPO_length = 14;

input MOBO_displace = 0;
input MOBO_length = 10;
input Num_Dev_Dn = -1.0;
input Num_Dev_Up = +1.0;

plot Zeroline = 0;
ZeroLine.SetDefaultColor(Color.White);

plot DPO = price - Average(price[DPO_length / 2 + 1], DPO_length);
DPO.DefineColor("Highest", Color.White);
DPO.DefineColor("Lowest", Color.Red);
DPO.AssignNormGradientColor(colorNormLength, DPO.color("Lowest"winking smiley, DPO.color("Highest"winking smiley);

def Midline = Average (data = DPO, MOBO_length);
def sDev = stdev(data = DPO[-MOBO_displace], length = MOBO_length);
def LowerBand = Midline + num_Dev_Dn * sDev;
def UpperBand = Midline + num_Dev_Up * sDev;

def MoboStatus =
if DPO > UpperBand then 2
else
if DPO < LowerBand then -2
else 0;

rec BreakStatus = compoundValue(1,

if BreakStatus[1] == MoboStatus or MoboStatus == 0 then BreakStatus[1]
else
if MoboStatus == 2 then 2
else -2, 0);

plot MidlineP = Midline;
MidLineP.SetDefaultColor(Color.White);
MidlineP.SetStyle(Curve.SHORT_DASH);
MidLineP.HideBubble();

plot UpperBandP = UpperBand;
UpperBandP.AssignValueColor (
if BreakStatus[0] == 2 then Color.LIGHT_GREEN
else Color.LIGHT_RED);
UpperBandP.HideBubble();

plot LowerBandP = LowerBand;
LowerBandP.AssignValueColor (
if BreakStatus[0] == 2 then Color.LIGHT_GREEN
else Color.LIGHT_RED);
LowerBandP.HideBubble();
MTF Simple Moving Average
April 05, 2019 07:10AM
Hi all, I am in need of a thinkscript, I want to plot the 4Hr. 5SMA on to a 5Min. Chart. Any help will be appreciated, thanks
Re: MTF Simple Moving Average
April 07, 2019 11:22AM
Quote
Superspot
Hi all, I am in need of a thinkscript, I want to
plot the 4Hr. 5SMA on to a 5Min. Chart. Any help
will be appreciated, thanks
-------------------------------------------------------

Hi, please look in my replies, I am sure that somewhere I have already indicated how to combine different aggregation times

R



Edited 1 time(s). Last edit at 04/08/2019 02:53PM by rigel.
Re: Fun with ThinkScript
April 12, 2019 07:32PM
Hi All,

I have a request. I'm looking for an indicator that will alert me with an arrow when a possible double top or double bottom is forming. I'm thinking maybe if close is coming within a certain distance (used as an input) from the HOD/LOD . If anyone has a already made indicator for DT/DB that you could share I'd appreciate it.
Re: Fun with ThinkScript
April 14, 2019 11:15AM
.



Edited 1 time(s). Last edit at 04/14/2019 11:17AM by rck53705.
Re: Fun with ThinkScript
April 14, 2019 11:16AM
brazilianpillar Wrote:
-------------------------------------------------------
> Hi All,
>
> I have a request. I'm looking for an indicator
> that will alert me with an arrow when a possible
> double top or double bottom is forming. I'm
> thinking maybe if close is coming within a certain
> distance (used as an input) from the HOD/LOD . If
> anyone has a already made indicator for DT/DB that
> you could share I'd appreciate it.


Hi brazilianpillar, Sorry I don't have anything to help on this particular request, but I PM'd you the other day and I just wanted to touch base with you another way because of not knowing if you have 'email me on private messages' turned on in forum options. I had a request about a post you made a few years ago. Hopefully you can help. Thanks!
Re: chop indicator
April 20, 2019 10:01AM
you can share the code for the TTM squeeze
thanks
Equivolume Charts & Dynamic Volume
April 28, 2019 10:21AM
Hi
I wanted to see if you can help me to figure out how to do a custom indicator? I want to be able to see on the chart dynamic volume but with open close high and low. This is the link to see..I would appreciate it if you could tell me if its possible to customize.

[pro.algoji.com]
[stockcharts.com]
Re: Equivolume Charts & Dynamic Volume
May 04, 2019 10:32AM
TOS script language does not offer the capabilities to modify volume bar shape(width) neither candle width.
Dpo alert
May 05, 2019 04:34AM
Fredm try this at the end of your code:
#-------- Alerts 
def conditionBull = Crosses(DPO, UpperBand, CrossingDirection.Above) ;
def conditionBear = Crosses(DPO, LowerBand, CrossingDirection.Below) ;
Alert(conditionBull, "Bullish!", Alert.BAR,sound.ring) ;
Alert(conditionBear, "Bearish!", Alert.BAR,sound.ring) ;
Re: Equivolume Charts & Dynamic Volume
May 06, 2019 10:38PM
@nir shahar,

You can do Equivolume charts right in Thinkorswim:



Hope this helps!

Good Luck and Good Trading smiling smiley
Cumulative indicator
May 19, 2019 08:28AM
Hi, I've been trying for some time to create a cumulative indicator that plots the cumulative value (and a moving average) of the values of another indicator. Currently the only option is to get the cumulative value of an instrument.

I was wondering if someone has any clue how it could be done.
Re: Cumulative indicator
May 20, 2019 04:00PM
Can you post a link to such cumulative values?
Re: Cumulative indicator
May 20, 2019 05:39PM
I found several cumulative indicators, all referring to the $TICK instrument (although they can be modified for other symbols):

https://readtheprospectus.wordpress.com/2010/10/25/cumulative-tick-study-v2-for-think-or-swim/

https://futures.io/thinkorswim/41392-cumulative-tick-script.html#post624087
Re: Fun with ThinkScript
May 22, 2019 08:10PM
does anyone know how I can extend lines right? I also am trying to color the volume profiles within the volume profile indicator to reflect and color the buys vs sells. can anyone help me?
Re: Fun with ThinkScript
June 11, 2019 10:08AM
I would really appreciate it if I could add the below alert

alert(state != state[1], "ATR Trailing Stop Alert", alert.BAR, sound.ring);
assignBackgroundColor(if state != state[1] or state != state[2] then color.yellow else color.current);

to

# E-Charts v2

declare upper;
input short_average = 5;
input medium_average = 10;
input long_average = 20;
input average_type = {default "SMA", "EMA"};
input show_vertical_line = no;
input show_bubble_labels = yes;

def MA1;
def MA2;
def MA3;
switch (average_type) {
case "SMA":
MA1 = Average(close, short_average);
MA2 = Average(close, medium_average);
MA3 = Average(close, long_average);
case "EMA":
MA1 = ExpAverage(close, short_average);
MA2 = ExpAverage(close, medium_average);
MA3 = ExpAverage(close, long_average);
}

# define e-signal and crossover point
def Eup = MA1 > MA2 && MA2 > MA3;
def Edn = MA1 < MA2 && MA2 < MA3;

def CrossUp = close > MA1 && Eup && !Eup[1];
def CrossDn = close < MA1 && Edn && !Edn[1];

# Define up and down signals
def higherHigh = close > Highest(max(open,close), 3)[1];
def lowerLow = close < Lowest(min(open,close), 3)[1];
def SignalUp = if (CrossUp && higherHigh)
then 1
else if (CrossUp[1] && higherHigh && !higherHigh[1])
then 1
else if (CrossUp[2] && higherHigh && !higherHigh[1] && !higherHigh[2])
then 1
else Double.NaN;
def SignalDn = if (CrossDn && lowerLow)
then 1
else if (CrossDn[1] && lowerLow && !lowerLow[1])
then 1
else if (CrossDn[2] && lowerLow && !lowerLow[1] && !lowerLow[2])
then 1
else Double.NaN;

# Plot the moving average lines
plot ln1 = MA1;
ln1.SetDefaultColor(CreateColor(145, 210, 144));
ln1.SetLineWeight(2);
plot ln2 = MA2;
ln2.SetDefaultColor(CreateColor(111, 183, 214));
ln2.SetLineWeight(2);
plot ln3 = MA3;
ln3.SetDefaultColor(CreateColor(249, 140, 182));
ln3.SetLineWeight(2);

# Draw vertical line to indicate call and put signals
AddVerticalLine(SignalUp && show_vertical_line, "Up", Color.UPTICK);
AddVerticalLine(SignalDn && show_vertical_line, "Down", Color.LIGHT_RED);

# Show Call / Put Signal in a Chart Bubble
AddChartBubble(SignalUp && show_bubble_labels, low - 0.3, "Up", Color.UPTICK, no);
AddChartBubble(SignalDn && show_bubble_labels, high + 0.3, "Dn", Color.LIGHT_RED);

# Add label for Eup or Edn
AddLabel(Eup, "E Up", Color.GREEN);
AddLabel(Edn, "E Dn", Color.RED);
Triangle Breakout / Breakdown
June 13, 2019 08:48PM
Hello All, Im looking for a script on ToS that draws triangles with indicated breakout / breakdown points of support / resistance. Been scalping recently so this would help out in a huge way as I hate to have to draw lines manually on my charts and IM LAZY
Re: Fun with ThinkScript
June 14, 2019 12:01PM
Made a Volume Watchlist Column using
VOLUME


pretty simple question.... how do i make the .0 disappear, so instead of showing 40.0 20.0 it shows as 40 and 20....i just want it to show the whole number without decimals ive tried ROUND and ABSVAL and i cant figure it out.
[oi63.tinypic.com]

Thanks in advance



Edited 1 time(s). Last edit at 06/14/2019 12:03PM by dchenski.
Re: Fun with ThinkScript
June 15, 2019 11:50AM
thank you for this amazing opportunity. I am brand new at this ,so bare with me please. I have read a few topics, but have not really coded anything of substance. There are so many excellent coders in here, I am humbled.

I am requesting help for code that will provide the 3 desired results that could possibly help me.

First, Code that will define 5 swings.
Second, code to idendify that the 5th swing is complete.
Third, code that will identicate that the 5th swing is longer than the 3rd swing.

What ever you can do for me will be deeply appreciated.
TOS script
July 03, 2019 11:28PM
I was wondering if someone cold help me write a simple script for TOS. I would like to display in the upper left hand corner of the screen
the open ,high, low close and net change for today's daily bar. I would like it to look like this if possible:

For example:

Open 22.00
High 22.40
Low 22.00
Close 22.26
Net change +.23 (in green if the net change is positive...red if negative)


Any help would be greatly appreciated.

Kevin
Re: TOS script
July 06, 2019 04:34PM
traderk1836 Wrote:
-------------------------------------------------------
> I was wondering if someone cold help me write a
> simple script for TOS. I would like to display in
> the upper left hand corner of the screen
> the open ,high, low close and net change for
> today's daily bar. I would like it to look like
> this if possible:
>
> For example:
>
> Open 22.00
> High 22.40
> Low 22.00
> Close 22.26
> Net change +.23 (in green if the net change is
> positive...red if negative)
>
>
> Any help would be greatly appreciated.
>
> Kevin


Hi Kevin,
Here is the code. I did not write it but it is from this website/topic thread. Thank you original coder.
You can change label color if you like and even change "O" to for "open"


### Start Code


# ___________________________________________________________
# ________________  DAY/ HI-LOW / VOLUME ____________________
# ___________________________________________________________
#


input show_label = yes;
input show_bubble = no;


def period_Type = AggregationPeriod.DAY;

def begin = close(period = period_Type)[1];
def end = close(period = period_Type);
def NetChg = end - begin;
def PctChg = (end / begin) - 1;
def DayVolume =  volume(period = "DAY"winking smiley;

#AddLabel(show_label, "Open: " + Open + "  High: " + High + "  Low: " + Low +  "   Last: " 
+ close + "  " + " Volume: " + DayVolume + "  " , if NetChg > 0 then CreateColor( 165, 105, 189 ) 
else if NetChg < 0 then CREATEColor( 46, 204, 113 ) else Color.LIGHT_GRAY);


AddLabel(show_label, "Open: " + Open + "  High: " + High + "  Low: " + Low 
+  " Volume: " + DayVolume + "  " , if NetChg > 0 then CreateColor( 44, 62, 80) 
else if NetChg < 0 then CREATEColor( 46, 204, 113 ) else Color.LIGHT_GRAY);

def bar = if IsNaN(close) 
             then if yes
                     then bar[1]
                     else Double.NaN
             else BarNumber();
def ThisBar = HighestAll(bar);
def barCount   = if bar == ThisBar 
                 then close
                 else Double.NaN;


#### End code



Edited 2 time(s). Last edit at 07/06/2019 04:37PM by paperclips.
Re: Fun with ThinkScript
July 09, 2019 08:13PM
Thank you all for your contributions. I am new to this forum. What do the following letters mean? FP/HRFP
Thanks
Sorry, only registered users may post in this forum.

Click here to login