Posted by robert

Re: Fun with ThinkScript January 17, 2018 05:59PM |
Registered: 3 years ago Posts: 4 |

In English the steps you need to plot the Composite Index are the following: This indicator is on all of Constance's Brown's chart and in her book. Just need to code it in TOS.

Step 1: create a 9-period momentum (momentum is indicator of a 14 period RSI. Yes, it is momentum on RSI, not price. This is an indicator on an indicator. I put the momentum formula below since TOS does not have this indicator.

Step 2: create a very short 3-period RSI and then a simple 3-period moving average of the 3-period RSI to smooth it slightly.

Step 3: add Steps 1 and 2 together to create the Composite Index.

Step 4: Create two simple moving averages of the Composite Index using the periods 13 and 33.

Step 5: Plot the Composite Index and its two simple averages as three lines in a separate frame under the price data.

momentum (M) is a comparison between the current closing price (CP) a closing price "n" periods ago (CPn). M = CP - CPn

How to plot Connie Brown's Composite Index in TradeStation:

Create two functions.

The function RSIMO9 is written:

RSIMO9 = MOMENTUM(RSI(Close,14),9)

The second function is written:

RSI3 = AVERAGE(RSI(CLOSE,3)3)

The formula is then written:

Plot1(RSIMO(+RSI3,"Plot1":

Plot2(average((plot1),13),"Plot2";

Plot3(average((plot1),33),"Plot3');

I would really appreciate anyone's help with this. If you have any questions or need to know something else just let me know. I would be more than happy to pay for it.

Step 1: create a 9-period momentum (momentum is indicator of a 14 period RSI. Yes, it is momentum on RSI, not price. This is an indicator on an indicator. I put the momentum formula below since TOS does not have this indicator.

Step 2: create a very short 3-period RSI and then a simple 3-period moving average of the 3-period RSI to smooth it slightly.

Step 3: add Steps 1 and 2 together to create the Composite Index.

Step 4: Create two simple moving averages of the Composite Index using the periods 13 and 33.

Step 5: Plot the Composite Index and its two simple averages as three lines in a separate frame under the price data.

momentum (M) is a comparison between the current closing price (CP) a closing price "n" periods ago (CPn). M = CP - CPn

How to plot Connie Brown's Composite Index in TradeStation:

Create two functions.

The function RSIMO9 is written:

RSIMO9 = MOMENTUM(RSI(Close,14),9)

The second function is written:

RSI3 = AVERAGE(RSI(CLOSE,3)3)

The formula is then written:

Plot1(RSIMO(+RSI3,"Plot1":

Plot2(average((plot1),13),"Plot2";

Plot3(average((plot1),33),"Plot3');

I would really appreciate anyone's help with this. If you have any questions or need to know something else just let me know. I would be more than happy to pay for it.

Re: Fun with ThinkScript January 18, 2018 09:26AM |
Registered: 3 years ago Posts: 32 |

Can anyone help me create a paint bar thinkscript?

What I'm looking for is a quick easy way to visualize the difference between a base candle and a leg candle. Leg candles would be the paint bar.

A leg candle is one where the current candle closes outside of the previous candle's range ( high to low ).

A base candle is one where the current close is within the previous candle's range ( between high and low ).

Much like an inside bar. But with the closes. And if it could include my current inside bar thinkscript that would be great. Just using different color paint bars for base candles and inside bars.

Anyone know how to do this? Thank you

Inside bar script:

def insideBar = high < high[1] and low > low[1];

def insideMatch = insideBar and (high == high[1] or low == low[1]);

AssignPriceColor(if insideMatch then Color.blue else if insideBar then Color.MAGENTA else Color.CURRENT);

What I'm looking for is a quick easy way to visualize the difference between a base candle and a leg candle. Leg candles would be the paint bar.

A leg candle is one where the current candle closes outside of the previous candle's range ( high to low ).

A base candle is one where the current close is within the previous candle's range ( between high and low ).

Much like an inside bar. But with the closes. And if it could include my current inside bar thinkscript that would be great. Just using different color paint bars for base candles and inside bars.

Anyone know how to do this? Thank you

Inside bar script:

def insideBar = high < high[1] and low > low[1];

def insideMatch = insideBar and (high == high[1] or low == low[1]);

AssignPriceColor(if insideMatch then Color.blue else if insideBar then Color.MAGENTA else Color.CURRENT);

Re: Fun with ThinkScript January 18, 2018 10:25PM |
Registered: 1 year ago Posts: 8 |

Hello,

I am trying to draw an opening range that starts at 18:00pm eastern and ends at 9:00am eastern the following day. The lines will extend until 17:00pm. I tried to modify Robert's and ReadtheProspectus' OR scripts but I have zero coding background so I haven't been successful. Help anyone? Thanks in advance.

I am trying to draw an opening range that starts at 18:00pm eastern and ends at 9:00am eastern the following day. The lines will extend until 17:00pm. I tried to modify Robert's and ReadtheProspectus' OR scripts but I have zero coding background so I haven't been successful. Help anyone? Thanks in advance.

Re: Fun with ThinkScript January 19, 2018 12:01AM |
Registered: 5 months ago Posts: 1 |

Re: Fun with ThinkScript January 19, 2018 09:27PM |
Registered: 3 years ago Posts: 54 |

Hi Tai,

I've been trying to come up with the thinkscript version of the Composite Index. There are a number of errors (highlighted in red), but here's what I have so far:

I'll keep trying to see if I can get past the outstanding errors, but I hope what I have proves helpful in some way...

I've been trying to come up with the thinkscript version of the Composite Index. There are a number of errors (highlighted in red), but here's what I have so far:

declare lower; def length_rsi = 14; def length_momentum = 9; def price = close; def averageType = AverageType.WILDERS; def NetChgAvg = MovingAverage(averageType, price - price[1], length_rsi); def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length_rsi); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def RSI = 50 * (ChgRatio + 1); def Momentum = price - price[length_momentum]; def RSIMO = Momentum(RSI(price, length_rsi), length_momentum); def RSI3 = ExpAverage(RSI(price, 3), 3); plot CompositeIndex = (RSIMO(RSI3)); plot avg13 = (ExpAverage(RSIMO, 13)); plot avg33 = (ExpAverage(RSIMO, 33));

I'll keep trying to see if I can get past the outstanding errors, but I hope what I have proves helpful in some way...

Re: Fun with ThinkScript January 21, 2018 01:11PM |
Registered: 3 years ago Posts: 54 |

Tai,

A fellow scripter on another forum provided the answer:

Hope that helps. Pay it forward

netarchitech

A fellow scripter on another forum provided the answer:

declare lower; def RSIDelta = RSI(14) - RSI(14)[9]; def RSIsma = simpleMovingAvg(rsi(3),3); plot plot1 = RSIDelta + RSIsma; plot plot2 = simpleMovingAvg(plot1,13); plot plot3 = simpleMovingAvg(plot1,33);

Hope that helps. Pay it forward

netarchitech

Hi all - new to TOS January 21, 2018 07:21PM |
Registered: 5 months ago Posts: 1 |

Hello everyone.... I am new to thinkscript and find it fascinating.

I program and do stats as biostatistician in clinical trials (R and SAS), but ThinkScript is a different animal.

I would like to become more proficient. I am reading the TOS Learning Center, but am open to advice on how to improve.

I think I have to work with simple examples and develop from there.

For example I was hoping to calculate the avg % move in the week after each of the last 5 earnings for given optionable stocks that come up in a scan as straddle candidates. I know for many of you here, this is child's play, but for me it is a challenge. Any suggestions.

Thanks

Denis

denbois@yahoo.com

Edited 1 time(s). Last edit at 01/21/2018 07:22PM by denbois.

I program and do stats as biostatistician in clinical trials (R and SAS), but ThinkScript is a different animal.

I would like to become more proficient. I am reading the TOS Learning Center, but am open to advice on how to improve.

I think I have to work with simple examples and develop from there.

For example I was hoping to calculate the avg % move in the week after each of the last 5 earnings for given optionable stocks that come up in a scan as straddle candidates. I know for many of you here, this is child's play, but for me it is a challenge. Any suggestions.

Thanks

Denis

denbois@yahoo.com

Edited 1 time(s). Last edit at 01/21/2018 07:22PM by denbois.

Re: Fun with ThinkScript January 25, 2018 04:24PM |
Registered: 1 year ago Posts: 3 |

Hi,

Can someone help me with a simple scan / script. I just want to do a scan for increasing volume for 3 consecutive bars(bar_0<bar_1<bar_2).

Thank you

Maybe like this?

input x = volume;

input length = 3;

plot scan = sum(x > x[1], length) == length;

Edited 1 time(s). Last edit at 01/25/2018 05:37PM by transiennt999.

Can someone help me with a simple scan / script. I just want to do a scan for increasing volume for 3 consecutive bars(bar_0<bar_1<bar_2).

Thank you

Maybe like this?

input x = volume;

input length = 3;

plot scan = sum(x > x[1], length) == length;

Edited 1 time(s). Last edit at 01/25/2018 05:37PM by transiennt999.

Re: Fun with ThinkScript January 27, 2018 07:13PM |
Registered: 5 months ago Posts: 1 |

Hey Robert,

I am looking to create a column just like this Custom Column using the simple moving average cross (2) above the (8) SMA.

Is there a way to have it continue past 1 and -1 to 15days? 1 2 3 , -1 -2 -3?

Please let me know or if you need something clarified! Thanks

I am looking to create a column just like this Custom Column using the simple moving average cross (2) above the (8) SMA.

Is there a way to have it continue past 1 and -1 to 15days? 1 2 3 , -1 -2 -3?

Please let me know or if you need something clarified! Thanks

session midpoint???? February 17, 2018 10:11AM |
Registered: 4 months ago Posts: 1 |

Hi all, and a big thank-you for looking at this....I am a newbie with programming so I have NO idea how the following script is NOT plotting the midpoint of today's session...The script is not mine and is publicly available. However, it plots something akin to the day's midline, but not really. Just to be clear I am defining midpoint of the session as ((highest high - lowest low)/2) + lowest low..... I would like to see where the plot has been during the day, much like one can see where the moving average has been throughout the day. Thanks to all..

input CapturePeriodStart = 0930;

input CapturePeriodEnd = 1615;

input StartPlotTime = 0930;

input EndPlotTime = 2359;

def CapturePeriodHasBegun = secondsFromTime(CapturePeriodStart) > 0;

def FirstBarOfCapturePeriod = !CapturePeriodHasBegun[1] and CapturePeriodHasBegun;

def PriorPeriod = secondsFromTime(CapturePeriodStart) > 0 or secondsFromTime(CapturePeriodEnd) < 0;

def PlotPeriod = secondsFromTime(StartPlotTime) > 0 && secondsTillTime(EndPlotTime) > 0;

rec PriorPeriodHigh = if IsNaN(PriorPeriodHigh[1]) or PriorPeriodHigh[1] < 2 then high

else if FirstBarOfCapturePeriod then high else if PriorPeriod && high > PriorPeriodHigh[1] then

high else PriorPeriodHigh[1];

rec PriorPeriodLow = if IsNaN(PriorPeriodLow[1]) or PriorPeriodLow[1] < 2 then low else

if FirstBarOfCapturePeriod then low else if PriorPeriod && low < PriorPeriodLow[1] then low else

PriorPeriodLow[1];

def TheHigh = if PlotPeriod && PriorPeriodHigh > 2 then PriorPeriodHigh else

double.nan;

def TheLow = if PlotPeriod && PriorPeriodLow > 2 then PriorPeriodLow else

input CapturePeriodStart = 0930;

input CapturePeriodEnd = 1615;

input StartPlotTime = 0930;

input EndPlotTime = 2359;

def CapturePeriodHasBegun = secondsFromTime(CapturePeriodStart) > 0;

def FirstBarOfCapturePeriod = !CapturePeriodHasBegun[1] and CapturePeriodHasBegun;

def PriorPeriod = secondsFromTime(CapturePeriodStart) > 0 or secondsFromTime(CapturePeriodEnd) < 0;

def PlotPeriod = secondsFromTime(StartPlotTime) > 0 && secondsTillTime(EndPlotTime) > 0;

rec PriorPeriodHigh = if IsNaN(PriorPeriodHigh[1]) or PriorPeriodHigh[1] < 2 then high

else if FirstBarOfCapturePeriod then high else if PriorPeriod && high > PriorPeriodHigh[1] then

high else PriorPeriodHigh[1];

rec PriorPeriodLow = if IsNaN(PriorPeriodLow[1]) or PriorPeriodLow[1] < 2 then low else

if FirstBarOfCapturePeriod then low else if PriorPeriod && low < PriorPeriodLow[1] then low else

PriorPeriodLow[1];

def TheHigh = if PlotPeriod && PriorPeriodHigh > 2 then PriorPeriodHigh else

double.nan;

def TheLow = if PlotPeriod && PriorPeriodLow > 2 then PriorPeriodLow else

Re: Fun with ThinkScript February 17, 2018 07:38PM |
Registered: 5 months ago Posts: 8 |

Actually was wondering how i can change them both to SMAperiod since the CC is simple moving averages and i have to change the length to you know what they are. . Could anyone expound on this ?? Thanks hope this could help out someone .

input EMAPeriod = 10;

input SMAPeriod = 20;

input price = close;

def na = double.nan;

plot fastema = ExpAverage(price, EMAPeriod);

plot slowema = Average(price, SMAPeriod);

def crossover = if fastema > slowema AND fastema[1] <= slowema[1] then 1 else 0;

def crossunder = if fastema < slowema AND fastema[1] >= slowema[1] then 1 else 0;

#Plot arrows

Plot up = if crossover then low - tickSize() else na;

Plot down = if crossunder then high + tickSize() else na;

up.SetPaintingStrategy(paintingStrategy.ARROW_UP);

down.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);

#Trigger alerts

alert(crossover[1], "Crossover", Alert.Bar, Sound.Ding);

alert(crossunder[1], "Crossunder", Alert.Bar, Sound.Ding);

Edited 2 time(s). Last edit at 02/17/2018 11:47PM by Chris M.

input EMAPeriod = 10;

input SMAPeriod = 20;

input price = close;

def na = double.nan;

plot fastema = ExpAverage(price, EMAPeriod);

plot slowema = Average(price, SMAPeriod);

def crossover = if fastema > slowema AND fastema[1] <= slowema[1] then 1 else 0;

def crossunder = if fastema < slowema AND fastema[1] >= slowema[1] then 1 else 0;

#Plot arrows

Plot up = if crossover then low - tickSize() else na;

Plot down = if crossunder then high + tickSize() else na;

up.SetPaintingStrategy(paintingStrategy.ARROW_UP);

down.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);

#Trigger alerts

alert(crossover[1], "Crossover", Alert.Bar, Sound.Ding);

alert(crossunder[1], "Crossunder", Alert.Bar, Sound.Ding);

Edited 2 time(s). Last edit at 02/17/2018 11:47PM by Chris M.

Re: Fun with ThinkScript February 17, 2018 11:25PM |
Registered: 4 years ago Posts: 334 |

Re: Fun with ThinkScript February 17, 2018 11:48PM |
Registered: 5 months ago Posts: 8 |

Re: Fun with ThinkScript March 04, 2018 09:03AM |
Registered: 4 months ago Posts: 1 |

Hello

I wrote a simple script which adds a label several pivot values. I want to show this labels on a 5 Min /5 day chart. Since the chart doesn't provide enough information, the Monthly pivot cant calculate its value. For 1hour pivot this works.

Here the script:

input timeFrame = {default DAY, WEEK, MONTH};

def PP = (high(period = timeFrame)[1] + low(period = timeFrame)[1] + close(period=timeframe)[1]) / 3;

AddLabel (yes, "Pivot M = " + round(PP),Color.WHITE);

input period = {Month, default MONTH};

Now; Is there a way that the script get data from the daily chart to calculate correct the value?

This would help me also for other scripts I would like to use on a 5min timeframe.

I wrote a simple script which adds a label several pivot values. I want to show this labels on a 5 Min /5 day chart. Since the chart doesn't provide enough information, the Monthly pivot cant calculate its value. For 1hour pivot this works.

Here the script:

input timeFrame = {default DAY, WEEK, MONTH};

def PP = (high(period = timeFrame)[1] + low(period = timeFrame)[1] + close(period=timeframe)[1]) / 3;

AddLabel (yes, "Pivot M = " + round(PP),Color.WHITE);

input period = {Month, default MONTH};

Now; Is there a way that the script get data from the daily chart to calculate correct the value?

This would help me also for other scripts I would like to use on a 5min timeframe.

Re: Fun with ThinkScript March 04, 2018 11:44PM |
Registered: 4 months ago Posts: 15 |

Re: Fun with ThinkScript March 04, 2018 11:48PM |
Registered: 4 months ago Posts: 15 |

Been reading this board for over a week, great stuff everyone!

My question is regarding this alert, can someone help me out pls...

1. Is it possible to make a column on a watchlist that turns the column green when a alert comes in?

2. Tanman you mentioned that you use two closes under the 8ema for an exit, if one starts with 1,000 shares, takes profit at first target with 500. and then takes profit 300 shares at 2 closes below 8 ema, and decides to swing the last 200 shares. What would be a good exit stratghy in this case?

Thanks

robert Wrote:

-------------------------------------------------------

> I've been trading intraday momentum / breakout

> moves for the past several months; so I really

> appreciated the very detailed post that tanman

> made the other day describing how he uses ATR as a

> filter to avoid false breakouts.

>

> I recommend reading his post here.

>

> I wrote the following script to go along with the

> breakout rules that he detailed. (I love rules

> )

>

> This script will calculate and plot the stop loss

> and first profit target when the stock breaks out

> above the previous day's high or opening range

> high (whichever is higher) or vice versa to the

> low-side. This may be used with a 2 min chart as

> he described in his original post for a more

> aggressive entry point, or, as he recommended to

> me, on a 5 min chart for a more conservative entry

> point.

>

> [i.imgur.com]

>

> red -- stop loss

> white -- entry point

> green -- first profit target for scaling out

> yellow -- opening range

> orange -- ATR breakout confirmation level

>

>

> cyan -- yesterday's high

> pink -- yesterday's low

>

>

> script OpenRange {

> input ORtime = 5;

>

> def FirstBar = GetDay() != GetDay()[1];

> def RangeTime = SecondsFromTime(0930) >= 0 and

> SecondsFromTime(0930) < 60 * ORtime;

> def Rhigh = if FirstBar then high else if

> RangeTime and high > Rhigh[1] then high else

> Rhigh[1];

> def Rlow = if FirstBar then low else if

> RangeTime and low < Rlow[1] then low else

> Rlow[1];

>

> plot h = if RangeTime then Double.NaN else

> Rhigh;

> plot l = if RangeTime then Double.NaN else

> Rlow;

> }

>

> def first30 = SecondsFromTime(0930) >= 0 and

> SecondsTillTime(1000) >= 0;

> def today = GetLastDay() == GetDay();

> def ATR = AvgTrueRange(high, close, low, 10);

>

> plot yHigh = if !today then Double.NaN else

> high(period = "day" )[1];

> yHigh.SetDefaultColor(Color.CYAN);

> plot yLow = if !today then Double.NaN else

> low(period = "day" )[1];

> yLow.SetDefaultColor(Color.PINK);

>

> plot h5 = if !today then Double.NaN else if

> !first30 then Double.NaN else OpenRange(5).h;

> h5.SetDefaultColor(Color.YELLOW);

> plot l5 = if !today then Double.NaN else if

> !first30 then Double.NaN else OpenRange(5).l;

> l5.SetDefaultColor(Color.YELLOW);

> plot h30 = if !today then Double.NaN else

> OpenRange(30).h;

> h30.SetDefaultColor(Color.YELLOW);

> plot l30 = if !today then Double.NaN else

> OpenRange(30).l;

> l30.SetDefaultColor(Color.YELLOW);

>

> def lowConf = if first30 then Min(yLow, l5) - ATR

> else Min(yLow, l30) - ATR;

> def highConf = if first30 then Max(yHigh, h5) +

> ATR else Max(yHigh, h30) + ATR;

>

> plot lc1 = if first30 then lowConf else

> Double.NaN;

> lc1.SetDefaultColor(Color.ORANGE);

> plot lc2 = if !first30 then lowConf else

> Double.NaN;

> lc2.SetDefaultColor(Color.ORANGE);

> plot hc1 = if first30 then highConf else

> Double.NaN;

> hc1.SetDefaultColor(Color.ORANGE);

> plot hc2 = if !first30 then highConf else

> Double.NaN;

> hc2.SetDefaultColor(Color.ORANGE);

>

> def decisionL = if close > lowConf then Double.NaN

> else if close crosses below lowConf then low else

> decisionL[1];

> def decisionH = if close < highConf then

> Double.NaN else if close crosses above highConf

> then high else decisionH[1];

>

> plot dL = if !today then Double.NaN else

> decisionL;

> dL.SetDefaultColor(Color.WHITE);

> plot dH = if !today then Double.NaN else

> decisionH;

> dH.SetDefaultColor(Color.WHITE);

>

> def TL = CompoundValue(1, if IsNaN(dL) then

> Double.NaN else if !IsNaN(TL[1]) then TL[1] else

> if close crosses below dL then dL - 2 * ATR else

> Double.NaN, Double.NaN);

> def SL = CompoundValue(1, if IsNaN(dL) then

> Double.NaN else if !IsNaN(SL[1]) then SL[1] else

> if close crosses below dL then dL + 2 * ATR else

> Double.NaN, Double.NaN);

>

> plot Target1Low = if !today then Double.NaN else

> TL;

> Target1Low.SetDefaultColor(Color.GREEN);

> Target1Low.SetStyle(Curve.SHORT_DASH);

> plot Stop1Low = if !today then Double.NaN else

> SL;

> Stop1Low.SetDefaultColor(Color.RED);

> Stop1Low.SetLineWeight(2);

>

> AddChartBubble(IsNaN(TL[1]) and !IsNaN(TL), TL,

> "Target 1\n" + Round(TL, 2), Color.GREEN, no);

> AddChartBubble(IsNaN(SL[1]) and !IsNaN(SL), SL,

> "Stop\n" + Round(SL, 2), Color.RED);

>

> def TH = CompoundValue(1, if IsNaN(dH) then

> Double.NaN else if !IsNaN(TH[1]) then TH[1] else

> if close crosses above dH then dH + 2 * ATR else

> Double.NaN, Double.NaN);

> def SH = CompoundValue(1, if IsNaN(dH) then

> Double.NaN else if !IsNaN(SH[1]) then SH[1] else

> if close crosses above dH then dH - 2 * ATR else

> Double.NaN, Double.NaN);

>

> plot Target1High = if !today then Double.NaN else

> TH;

> Target1High.SetDefaultColor(Color.GREEN);

> Target1High.SetStyle(Curve.SHORT_DASH);

> plot Stop1High = if !today then Double.NaN else

> SH;

> Stop1High.SetDefaultColor(Color.RED);

> Stop1High.SetLineWeight(2);

>

> AddChartBubble(IsNaN(TH[1]) and !IsNaN(TH), TH,

> "Target 1\n" + Round(TH, 2), Color.GREEN);

> AddChartBubble(IsNaN(SH[1]) and !IsNaN(SH), SH,

> "Stop\n" + Round(SH, 2), Color.RED, no);

>

My question is regarding this alert, can someone help me out pls...

1. Is it possible to make a column on a watchlist that turns the column green when a alert comes in?

2. Tanman you mentioned that you use two closes under the 8ema for an exit, if one starts with 1,000 shares, takes profit at first target with 500. and then takes profit 300 shares at 2 closes below 8 ema, and decides to swing the last 200 shares. What would be a good exit stratghy in this case?

Thanks

robert Wrote:

-------------------------------------------------------

> I've been trading intraday momentum / breakout

> moves for the past several months; so I really

> appreciated the very detailed post that tanman

> made the other day describing how he uses ATR as a

> filter to avoid false breakouts.

>

> I recommend reading his post here.

>

> I wrote the following script to go along with the

> breakout rules that he detailed. (I love rules

> )

>

> This script will calculate and plot the stop loss

> and first profit target when the stock breaks out

> above the previous day's high or opening range

> high (whichever is higher) or vice versa to the

> low-side. This may be used with a 2 min chart as

> he described in his original post for a more

> aggressive entry point, or, as he recommended to

> me, on a 5 min chart for a more conservative entry

> point.

>

> [i.imgur.com]

>

> red -- stop loss

> white -- entry point

> green -- first profit target for scaling out

> yellow -- opening range

> orange -- ATR breakout confirmation level

>

>

> cyan -- yesterday's high

> pink -- yesterday's low

>

>

> script OpenRange {

> input ORtime = 5;

>

> def FirstBar = GetDay() != GetDay()[1];

> def RangeTime = SecondsFromTime(0930) >= 0 and

> SecondsFromTime(0930) < 60 * ORtime;

> def Rhigh = if FirstBar then high else if

> RangeTime and high > Rhigh[1] then high else

> Rhigh[1];

> def Rlow = if FirstBar then low else if

> RangeTime and low < Rlow[1] then low else

> Rlow[1];

>

> plot h = if RangeTime then Double.NaN else

> Rhigh;

> plot l = if RangeTime then Double.NaN else

> Rlow;

> }

>

> def first30 = SecondsFromTime(0930) >= 0 and

> SecondsTillTime(1000) >= 0;

> def today = GetLastDay() == GetDay();

> def ATR = AvgTrueRange(high, close, low, 10);

>

> plot yHigh = if !today then Double.NaN else

> high(period = "day" )[1];

> yHigh.SetDefaultColor(Color.CYAN);

> plot yLow = if !today then Double.NaN else

> low(period = "day" )[1];

> yLow.SetDefaultColor(Color.PINK);

>

> plot h5 = if !today then Double.NaN else if

> !first30 then Double.NaN else OpenRange(5).h;

> h5.SetDefaultColor(Color.YELLOW);

> plot l5 = if !today then Double.NaN else if

> !first30 then Double.NaN else OpenRange(5).l;

> l5.SetDefaultColor(Color.YELLOW);

> plot h30 = if !today then Double.NaN else

> OpenRange(30).h;

> h30.SetDefaultColor(Color.YELLOW);

> plot l30 = if !today then Double.NaN else

> OpenRange(30).l;

> l30.SetDefaultColor(Color.YELLOW);

>

> def lowConf = if first30 then Min(yLow, l5) - ATR

> else Min(yLow, l30) - ATR;

> def highConf = if first30 then Max(yHigh, h5) +

> ATR else Max(yHigh, h30) + ATR;

>

> plot lc1 = if first30 then lowConf else

> Double.NaN;

> lc1.SetDefaultColor(Color.ORANGE);

> plot lc2 = if !first30 then lowConf else

> Double.NaN;

> lc2.SetDefaultColor(Color.ORANGE);

> plot hc1 = if first30 then highConf else

> Double.NaN;

> hc1.SetDefaultColor(Color.ORANGE);

> plot hc2 = if !first30 then highConf else

> Double.NaN;

> hc2.SetDefaultColor(Color.ORANGE);

>

> def decisionL = if close > lowConf then Double.NaN

> else if close crosses below lowConf then low else

> decisionL[1];

> def decisionH = if close < highConf then

> Double.NaN else if close crosses above highConf

> then high else decisionH[1];

>

> plot dL = if !today then Double.NaN else

> decisionL;

> dL.SetDefaultColor(Color.WHITE);

> plot dH = if !today then Double.NaN else

> decisionH;

> dH.SetDefaultColor(Color.WHITE);

>

> def TL = CompoundValue(1, if IsNaN(dL) then

> Double.NaN else if !IsNaN(TL[1]) then TL[1] else

> if close crosses below dL then dL - 2 * ATR else

> Double.NaN, Double.NaN);

> def SL = CompoundValue(1, if IsNaN(dL) then

> Double.NaN else if !IsNaN(SL[1]) then SL[1] else

> if close crosses below dL then dL + 2 * ATR else

> Double.NaN, Double.NaN);

>

> plot Target1Low = if !today then Double.NaN else

> TL;

> Target1Low.SetDefaultColor(Color.GREEN);

> Target1Low.SetStyle(Curve.SHORT_DASH);

> plot Stop1Low = if !today then Double.NaN else

> SL;

> Stop1Low.SetDefaultColor(Color.RED);

> Stop1Low.SetLineWeight(2);

>

> AddChartBubble(IsNaN(TL[1]) and !IsNaN(TL), TL,

> "Target 1\n" + Round(TL, 2), Color.GREEN, no);

> AddChartBubble(IsNaN(SL[1]) and !IsNaN(SL), SL,

> "Stop\n" + Round(SL, 2), Color.RED);

>

> def TH = CompoundValue(1, if IsNaN(dH) then

> Double.NaN else if !IsNaN(TH[1]) then TH[1] else

> if close crosses above dH then dH + 2 * ATR else

> Double.NaN, Double.NaN);

> def SH = CompoundValue(1, if IsNaN(dH) then

> Double.NaN else if !IsNaN(SH[1]) then SH[1] else

> if close crosses above dH then dH - 2 * ATR else

> Double.NaN, Double.NaN);

>

> plot Target1High = if !today then Double.NaN else

> TH;

> Target1High.SetDefaultColor(Color.GREEN);

> Target1High.SetStyle(Curve.SHORT_DASH);

> plot Stop1High = if !today then Double.NaN else

> SH;

> Stop1High.SetDefaultColor(Color.RED);

> Stop1High.SetLineWeight(2);

>

> AddChartBubble(IsNaN(TH[1]) and !IsNaN(TH), TH,

> "Target 1\n" + Round(TH, 2), Color.GREEN);

> AddChartBubble(IsNaN(SH[1]) and !IsNaN(SH), SH,

> "Stop\n" + Round(SH, 2), Color.RED, no);

>

Re: Fun with ThinkScript March 06, 2018 12:49PM |
Registered: 4 months ago Posts: 1 |

Re: Robert's Rising Tide March 06, 2018 07:42PM |
Registered: 4 months ago Posts: 2 |

Mntman,

II really like what you did with the Rising Tide style indicafor that you created. I just stuimbled across it. The screen shot you posted looks fantastic. Would you mind sharing your verson of the indicator/TOS script? I think the approach to judging the overal market strength is brilliant and makes perfect sense. Best Drew

II really like what you did with the Rising Tide style indicafor that you created. I just stuimbled across it. The screen shot you posted looks fantastic. Would you mind sharing your verson of the indicator/TOS script? I think the approach to judging the overal market strength is brilliant and makes perfect sense. Best Drew

Re: Fun with ThinkScript March 07, 2018 05:25PM |
Registered: 3 years ago Posts: 4 |

Re: Robert's Rising Tide March 09, 2018 09:26PM |
Registered: 4 months ago Posts: 2 |

Thinkscript for Close value for different Stock March 13, 2018 09:10PM |
Registered: 4 months ago Posts: 1 |

After a week of searching, I've come to the oracle of ThinkScript knowledge.

I have stock ABC plotted on the chart, in a custom study I need to use the close value for stock DEF for a prior day.

I thought Close("DEF)[1] or some variation would work but apparently not...

Any ideas?

thanks

I have stock ABC plotted on the chart, in a custom study I need to use the close value for stock DEF for a prior day.

I thought Close("DEF)[1] or some variation would work but apparently not...

Any ideas?

thanks

Re: Fun with ThinkScript March 17, 2018 06:25PM |
Registered: 4 months ago Posts: 1 |

Hi Robert, I see this script is a few years old, but I think I can use it.

I am fairly new to trading and TOS.

I just want an alert when moving averages cross, one maybe Exponential, one may be Simple.

I am trying to understand how the script will alert. Would I need to have a chart open for a symbol, with the custom study attached, or would I need to place an alert on each chart for each symbol that I want to be alerted for, and attach the custom study to it?

This forum looks so helpful!

I am fairly new to trading and TOS.

I just want an alert when moving averages cross, one maybe Exponential, one may be Simple.

I am trying to understand how the script will alert. Would I need to have a chart open for a symbol, with the custom study attached, or would I need to place an alert on each chart for each symbol that I want to be alerted for, and attach the custom study to it?

This forum looks so helpful!

Re: Fun with ThinkScript / counting winners March 19, 2018 02:19PM |
Registered: 3 months ago Posts: 1 |

Re: Fun with ThinkScript March 21, 2018 01:55PM |
Registered: 4 months ago Posts: 2 |

Hello Robert,

I am a newbie here and im hoping you can help me with this script. I just want a arrow plotted on this script whenever a trend changes(green to blue, blue to green) on this moving average and at the same time it will alert me, can you help? Thanks

input displace = 0;

input length =50;

input price = close;

input movingAverageType = {default Simple, Exponential, Weighted, Hull, Variable};

rec data;

switch (movingAverageType) {

case Simple:

data = compoundValue(1, Average(price[-displace], length), price);

case Exponential:

data = compoundValue(1, ExpAverage(price[-displace], length), price);

case Weighted:

data = compoundValue(1, wma(price[-displace], length), price);

Case Hull:

data = compoundValue(1, hullMovingAvg(price[-displace], length), price);

case variable:

data = VariableMA(price=price, length=length);

}

plot ave = data;

ave.SetLineWeight(2);

ave.AssignValueColor(if ave > ave[1] then color.light_orange else color.blue);

ave.HideBubble();

Nathan

I am a newbie here and im hoping you can help me with this script. I just want a arrow plotted on this script whenever a trend changes(green to blue, blue to green) on this moving average and at the same time it will alert me, can you help? Thanks

input displace = 0;

input length =50;

input price = close;

input movingAverageType = {default Simple, Exponential, Weighted, Hull, Variable};

rec data;

switch (movingAverageType) {

case Simple:

data = compoundValue(1, Average(price[-displace], length), price);

case Exponential:

data = compoundValue(1, ExpAverage(price[-displace], length), price);

case Weighted:

data = compoundValue(1, wma(price[-displace], length), price);

Case Hull:

data = compoundValue(1, hullMovingAvg(price[-displace], length), price);

case variable:

data = VariableMA(price=price, length=length);

}

plot ave = data;

ave.SetLineWeight(2);

ave.AssignValueColor(if ave > ave[1] then color.light_orange else color.blue);

ave.HideBubble();

Nathan

Re: Fun with ThinkScript March 22, 2018 04:08AM |
Registered: 3 months ago Posts: 22 |

Hi my friend.... try this up!!!

# Custom_TrendHunter by ncastrinos

# Verison 1.0 11/10/2011 @ 0800 HRS

# Place study in lower pane

declare lower;

#User inputs:

input length1 = 20;

input trendabove = 7.5;

input trendbelow = -7.5;

plot line7 = 7.5;

line7.setDefaultColor(color.red);

plot line75 = -7.5;

line75.setDefaultColor(color.green);

#Aggregate data for a linear regression over the length above

rec Regression = Inertia(close,length1);

#Determine the angle of the lower end of the line and plot it in an oscillator

plot Data = Atan((Regression-Regression[(length1-1)])/(length1-1))* 180 / Double.Pi;

data.setDefaultColor(color.yellow);

#Plot your indicator lines

plot above = trendabove;

plot below = trendbelow;

input price = close;

input length = 10;

input averageLength = 3;

input over_bought = 80;

input over_sold = -80;

assert(length >= 2, "'length' must be greater than or equal to 2: " + length);

def sumSqr = fold i = 0 to length with sum do

sum + Sqr((length - i) - fold j = 0 to length with rank

do rank + if GetValue(price, i, length - 1) > GetValue(price, length - j - 1) or GetValue(price, i) == GetValue(price, length - j - 1) and i <= length - j - 1 then 1 else 0);

plot Spearman = 30 * (1 - 6 * sumSqr / (length * (Sqr(length) - 1)));

plot SpearmanAverage = Average(Spearman, averageLength);

AddLabel( data> data[3], " data> ", Color.CYAN);

AddLabel( data < data[3], " data< ", Color.PINK);

AddLabel (yes, "/", Color.GRAY);

AddLabel( SpearmanAverage> SpearmanAverage[2], " avg> ", Color.CYAN);

AddLabel( SpearmanAverage < SpearmanAverage[2], " avg< ", Color.PINK);

AddLabel (yes, "/", Color.GRAY);

AddLabel( Spearman> Spearman[2] and data >data [2], " S.D> ", Color.CYAN);

AddLabel( Spearman < Spearman[2] and data <data [2], " S.D< ", Color.PINK);

AddLabel (yes, (("All>"), if Spearman> Spearman[2] AND data >data [2] then Color.green else IF Spearman < Spearman[2] and data <data [2] then Color.pink ELSE COLOR.light_GRAY );

plot combo = if data>= 0 then -20 else Double.NaN;

combo.SetPaintingStrategy (PaintingStrategy.SQUARES);

###upsugnal.SetDefaultColor(Color.green);

combo.SetLineWeight (3);

combo.AssignValueColor(if data > data[1] then Color.green else if Spearman > Spearman[1] then Color.dark_green else if data < data[1] and Spearman < Spearman[1] then color.RED else Color.WHITE);

#########

plot combo2 = if data>= 0 then -26 else Double.NaN;

combo2.SetPaintingStrategy (PaintingStrategy.SQUARES);

###upsugnal.SetDefaultColor(Color.green);

combo2.SetLineWeight (3);

combo2.AssignValueColor(if data > data[1] and Spearman > Spearman[1] then Color.dark_green else if data < data[1] and Spearman < Spearman[1] then color.RED else Color.WHITE);

#########

###END

# Custom_TrendHunter by ncastrinos

# Verison 1.0 11/10/2011 @ 0800 HRS

# Place study in lower pane

declare lower;

#User inputs:

input length1 = 20;

input trendabove = 7.5;

input trendbelow = -7.5;

plot line7 = 7.5;

line7.setDefaultColor(color.red);

plot line75 = -7.5;

line75.setDefaultColor(color.green);

#Aggregate data for a linear regression over the length above

rec Regression = Inertia(close,length1);

#Determine the angle of the lower end of the line and plot it in an oscillator

plot Data = Atan((Regression-Regression[(length1-1)])/(length1-1))* 180 / Double.Pi;

data.setDefaultColor(color.yellow);

#Plot your indicator lines

plot above = trendabove;

plot below = trendbelow;

input price = close;

input length = 10;

input averageLength = 3;

input over_bought = 80;

input over_sold = -80;

assert(length >= 2, "'length' must be greater than or equal to 2: " + length);

def sumSqr = fold i = 0 to length with sum do

sum + Sqr((length - i) - fold j = 0 to length with rank

do rank + if GetValue(price, i, length - 1) > GetValue(price, length - j - 1) or GetValue(price, i) == GetValue(price, length - j - 1) and i <= length - j - 1 then 1 else 0);

plot Spearman = 30 * (1 - 6 * sumSqr / (length * (Sqr(length) - 1)));

plot SpearmanAverage = Average(Spearman, averageLength);

AddLabel( data> data[3], " data> ", Color.CYAN);

AddLabel( data < data[3], " data< ", Color.PINK);

AddLabel (yes, "/", Color.GRAY);

AddLabel( SpearmanAverage> SpearmanAverage[2], " avg> ", Color.CYAN);

AddLabel( SpearmanAverage < SpearmanAverage[2], " avg< ", Color.PINK);

AddLabel (yes, "/", Color.GRAY);

AddLabel( Spearman> Spearman[2] and data >data [2], " S.D> ", Color.CYAN);

AddLabel( Spearman < Spearman[2] and data <data [2], " S.D< ", Color.PINK);

AddLabel (yes, (("All>"), if Spearman> Spearman[2] AND data >data [2] then Color.green else IF Spearman < Spearman[2] and data <data [2] then Color.pink ELSE COLOR.light_GRAY );

plot combo = if data>= 0 then -20 else Double.NaN;

combo.SetPaintingStrategy (PaintingStrategy.SQUARES);

###upsugnal.SetDefaultColor(Color.green);

combo.SetLineWeight (3);

combo.AssignValueColor(if data > data[1] then Color.green else if Spearman > Spearman[1] then Color.dark_green else if data < data[1] and Spearman < Spearman[1] then color.RED else Color.WHITE);

#########

plot combo2 = if data>= 0 then -26 else Double.NaN;

combo2.SetPaintingStrategy (PaintingStrategy.SQUARES);

###upsugnal.SetDefaultColor(Color.green);

combo2.SetLineWeight (3);

combo2.AssignValueColor(if data > data[1] and Spearman > Spearman[1] then Color.dark_green else if data < data[1] and Spearman < Spearman[1] then color.RED else Color.WHITE);

#########

###END

Re: Fun with ThinkScript March 22, 2018 07:46AM |
Registered: 4 years ago Posts: 334 |

Don't let that Smiley face trip you up. This forum messes with the script that get posted sometimes and puts in a nice smiley face. It interprets the semi-colon and the close parentheses as a winky smiley. Can't remember for certain, but I think that's right. Someone correct me if I"m wrong.

Re: Fun with ThinkScript March 22, 2018 09:39AM |
Registered: 3 months ago Posts: 22 |

Re: Fun with ThinkScript March 22, 2018 11:59AM |
Registered: 3 months ago Posts: 22 |

HI, I LIKE THIS PLACE.

Anyone who could help me merging these 2 indicators please?!

I tried and tried but impossible so far, i am lost!

# Place study in lower pane

declare lower;

#User inputs:

input length1 = 20;

input trendabove = 7.5;

input trendbelow = -7.5;

plot line7 = 7.5;

line7.setDefaultColor(color.red);

plot line75 = -7.5;

line75.setDefaultColor(color.green);

#Aggregate data for a linear regression over the length above

rec Regression = Inertia(close,length1);

#Determine the angle of the lower end of the line and plot it in an oscillator

plot Data = Atan((Regression-Regression[(length1-1)])/(length1-1))* 180 / Double.Pi;

data.setDefaultColor(color.yellow);

#Plot your indicator lines

plot above = trendabove;

plot below = trendbelow;

###END

declare lower;

input price = close;

input length = 8;

input displace = 0;

input StochLong = 30; #20

input StochShort = 60; #80

# return %k for going long or short on stochastics

def Stoch = StochasticFull(80,20,14,3,High,Low,Close,3, "SMA" ).FullK;

def longFilter = Stoch < StochLong;

def shortFilter = Stoch > StochShort;

plot AvgExp = ExpAverage(price[displace], length);

AvgExp.SetDefaultColor(GetColor(5));

AddLabel( AvgExp> AvgExp[3], " exp> ", Color.CYAN);

AddLabel( AvgExp < AvgExp[3], " exp< ", Color.PINK);

AddLabel (yes, "/", Color.GRAY);

#END

Anyone who could help me merging these 2 indicators please?!

I tried and tried but impossible so far, i am lost!

# Place study in lower pane

declare lower;

#User inputs:

input length1 = 20;

input trendabove = 7.5;

input trendbelow = -7.5;

plot line7 = 7.5;

line7.setDefaultColor(color.red);

plot line75 = -7.5;

line75.setDefaultColor(color.green);

#Aggregate data for a linear regression over the length above

rec Regression = Inertia(close,length1);

#Determine the angle of the lower end of the line and plot it in an oscillator

plot Data = Atan((Regression-Regression[(length1-1)])/(length1-1))* 180 / Double.Pi;

data.setDefaultColor(color.yellow);

#Plot your indicator lines

plot above = trendabove;

plot below = trendbelow;

###END

declare lower;

input price = close;

input length = 8;

input displace = 0;

input StochLong = 30; #20

input StochShort = 60; #80

# return %k for going long or short on stochastics

def Stoch = StochasticFull(80,20,14,3,High,Low,Close,3, "SMA" ).FullK;

def longFilter = Stoch < StochLong;

def shortFilter = Stoch > StochShort;

plot AvgExp = ExpAverage(price[displace], length);

AvgExp.SetDefaultColor(GetColor(5));

AddLabel( AvgExp> AvgExp[3], " exp> ", Color.CYAN);

AddLabel( AvgExp < AvgExp[3], " exp< ", Color.PINK);

AddLabel (yes, "/", Color.GRAY);

#END

Re: TTM WAVE B,C March 22, 2018 01:17PM |
Registered: 3 months ago Posts: 1 |

Re: Fun with ThinkScript March 24, 2018 03:08PM |
Registered: 4 months ago Posts: 2 |

Sorry, only registered users may post in this forum.

Trade with Knowledge, Trade with Power - ResearchTrade.com.