Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

Fun with ThinkScript

Posted by robert 
Re: Fun with ThinkScript
March 25, 2018 11:31AM
Hi Robert, i am glad i four this site, it is amazing!

I am having trouble adding aggregation period to ADX study, could you help me please, i appreciate it.
Below is the code...

plot ADX = wildersAverage(CLOSE(period = aggregationPeriod), DX, adx_length);

I don't know what am doing wrong!
five min aggregation period
March 25, 2018 11:33AM
Hi Robert, i am glad i four this site, it is amazing!

I am having trouble adding aggregation period to ADX study, could you help me please, i appreciate it.
Below is the code...

plot ADX = wildersAverage(CLOSE(period = aggregationPeriod), DX, adx_length);

I don't know what am doing wrong!
Re: Fun with ThinkScript
April 08, 2018 11:49AM
Hi Mobile

You are not explaining at all what your problem is or what you want to do... but I guess from the title that you would like to have the indicator working with 5 min charts... is that right?
Then:

def adx_length=12;
plot ADX = wildersAverage(CLOSE(period = AggregationPeriod.FIVE_MIN), adx_length);

please notice that wildersaverage needs 2 parameters not 3
Is that what you want?
Re: Fun with ThinkScript
April 08, 2018 11:57AM
Hi, Rigel

Yes i want to add aggregation period of five minutes to the ADX STUDY. winking smiley
Do you know how to do this?
Help please!

Thank you!
Re: Fun with ThinkScript
April 08, 2018 03:09PM
Mobil, I already indicated it in my reply how to referece 5 min in your studies. Try it.

If that is no what you are trying to do, then please post your code and explain what is not working.

When you say ADX study, that is already available in TOS. When you change the chart to 5 min, the study changes accordingly.

So again, explain in more detail what you want.
Re: Fun with ThinkScript
April 09, 2018 04:18PM
looking for an easier way to display signals or to tighten it up for better signals

uses a couple different indicators rolled into one for "chop trading"
##GW RSI
input over_bought = 80;
input half_way = 50;
input over_sold = 20;
def trin_c = close("$TRIN"winking smiley;
def trin_cSP = close("$TRINSP"winking smiley;
def trin_cNAS = close("$TRIN/Q"winking smiley;

## GW RSI
def RSI = reference RSI(length = 13).RSI;
def highestRSI = Highest(RSI, 21);
def lowestRSI = Lowest(RSI, 21);

def RSIS = 100 * (RSI - lowestRSI) / (highestRSI - lowestRSI);

def "%K" = Average(RSIS, 3);
def "%D" = Average("%K", 5);


##END GW RSI

##TD RSI

def length = 14;
def over_BoughtTD = 70;
def over_SoldTD = 30;
def price = close;
def averageType = AverageType.WILDERS;
def showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSITD = 50 * (ChgRatio + 1);
def OverSold = over_sold;
def OverBought = over_bought;


## TD RSI


# DI Indicator

def DI_length = 5;
def "DI+" = DIPlus(DI_length);
def "DI-" = DIMinus(DI_length);
def "10" = 10;
def "5" = 5;
def "60" = 60;
def "80" = 80;
def "2" = 2;

##VOL BAND

def priceVOL = hlc3;
def averageLength = 8;
def volatilityLength = 13;
def deviationFactor = 3.55;
def lowBandAdjust = 0.9;

def typical = if priceVOL >= priceVOL[1] then priceVOL - low[1] else priceVOL[1] - low;
def deviation = deviationFactor * Average(typical, volatilityLength);
def devHigh = ExpAverage(deviation, averageLength);
def devLow = lowBandAdjust * devHigh;
def medianAvg = ExpAverage(priceVOL, averageLength);

def MidLine = Average(medianAvg, averageLength);
def UpperBand = ExpAverage(medianAvg, averageLength) + devHigh;
def LowerBand = ExpAverage(medianAvg, averageLength) - devLow;

##VOL BAND END

##DEF BOTTOM SIGNALS
def GWRSIBOTTOM3 = if ("%K" <= 1 && "%D" <= 1) then 3 else 0;

def GWRSIBOTTOM2 = if GWRSIBOTTOM3 == 3 then 0 else if ("%K" <= 5 && "%D" <= 5) then 2 else 0;
def GWRSIBOTTOM1 = if GWRSIBOTTOM2 == 2 then 0 else if GWRSIBOTTOM3 == 3 then 0 else if ("%K" <= 0) then 1 else if ("%K" <= 10 && "%D" <= 10) then 1 else if ("%D" <= 0) then 1 else 0;
def TDRSI3 = if (RSITD <= 27) then 3 else 0;
def TDRSI2 = if TDRSI3 == 3 then 0 else if (RSITD <= 30) then 2 else 0;
def TDRSI1 = if TDRSI2 == 2 then 0 else if TDRSI3 == 3 then 0 else if (RSITD <= 33) then 1 else 0;
def "DI-3" = if ("DI-" <= 2 ) then 3 else 0;
def "DI-1" = if ("DI-" >= 75 ) then 2 else 0;
def "DI-2" = if "DI-3" == 3 then 0 else if ("DI-" <= 8 ) then 1 else 0;
def VolBandBottom3 = if (open <= LowerBand && close <= LowerBand) then 3 else 0;
def VolBandBottom2 = if VolBandBottom3  == 3 then 0 else if (close <= LowerBand) then 2 else 0;
def VolBandBottom1 = if VolBandBottom2  == 2 then 0 else if VolBandBottom3  == 3 then 0 else if (low <= LowerBand) then 1 else 0;

##DEF TOP SIGNALS
def GWRSITOP3 = if ("%K" >= 99 && "%D" >= 99) then 3 else 0;
def GWRSITOP2 = if GWRSITOP3 == 3 then 0 else if ("%K" >= 95 && "%D" >= 95) then 2 else 0;
def GWRSITOP1 = if GWRSITOP2 == 2 then 0 else if GWRSITOP3 == 3 then 0 else if ("%K" >= 100) then 1 else if ("%K" >= 90 && "%D" >= 90) then 1 else if ("%D" >= 100) then 1 else 0;
def TDRSIT3 = if (RSITD >= 73) then 3 else 0;
def TDRSIT2 = if TDRSIT3 == 3 then 0 else if (RSITD >= 70) then 2 else 0;
def TDRSIT1 = if TDRSIT2 == 2 then 0 else if TDRSIT3 == 3 then 0 else if (RSITD >= 67) then 1 else 0;
def "DI+3" = if ("DI+" <= 2 ) then 3 else 0;
def "DI+1" = if ("DI+" >= 75 ) then 2 else 0;
def "DI+2" = if "DI+3" == 3 then 0 else if ("DI+" <= 8 ) then 1 else 0;
def VolBandTOP3 = if (open >= UpperBand && close >= UpperBand) then 3 else 0;
def VolBandTOP2 = if VolBandTOP3 == 3 then 0 else if (close >= UpperBand) then 2 else 0;
def VolBandTOP1 = if VolBandTOP2 == 2 then 0 else if VolBandTOP3 == 3 then 0 else if (high >= UpperBand) then 1 else 0;
###TRIN CHOP SIGNALS
def TRINSP =  if (trin_cSP <= .70 or trin_cSP >= 1.40) then 0 else 1;
def TRINNAS = if (trin_cNAS <= .70 or trin_cNAS >= 1.40) then 0 else 1;
def TRINNY =  if  (trin_c <= .70 or trin_c >= 1.40) then 0 else 1;

def TRINSignal = if (TRINSP == 1 && TRINNAS == 1 && TRINNY == 1) then 3 else  if (TRINSP == 1 or TRINNAS == 1 or TRINNY == 1) then 1 else 0;


def TOPCount = GWRSITOP1 + GWRSITOP2 + GWRSITOP3 + TDRSIT1 + TDRSIT2 + TDRSIT3  + "DI+1" + "DI+2" + "DI+3" + VolBandTOP1 + VolBandTOP2 + VolBandTOP3;
def BottomCount = GWRSIBOTTOM1 + GWRSIBOTTOM2 + GWRSIBOTTOM3 + TDRSI1 + TDRSI2 + TDRSI3 + "DI-1" + "DI-2" + "DI-3" + VolBandBottom1 + VolBandBottom2 + VolBandBottom3;

def toppercent = TRINSignal + TOPCount;
def bottompercent = TRINSignal + BottomCount;

def topsignal = if toppercent >4 then toppercent/13*100 else 0 ;
def bottomsignal = if bottompercent >4 then bottompercent/13*100 else 0 ;

def topsignalfinl =round(topsignal,0) ;
def bottomsignalfinl =round(bottomsignal,0) ;


###### SIGNAL
AddChartBubble(bottomsignalfinl,low, bottomsignalfinl+"%", Color.green,No);
AddChartBubble("time condition" = topsignalfinl, "price location" = high, text = topsignalfinl + "%", color = Color.RED);
Re: Fun with ThinkScript
April 09, 2018 04:44PM
Thank you much RIGEL. I WILL TRY.

rigel [ PM ]
Re: Fun with ThinkScript

Mobil, I already indicated it in my reply how to referece 5 min in your studies. Try it.
Re: Fun with ThinkScript
April 12, 2018 10:23AM
hi all.

does anyone (or tanman) have Robert's rising tide script? i changed computers and lost most of my thinkscripts.. thanks!
Re: Fun with ThinkScript
April 17, 2018 08:16AM
I’m trying to create a previous inside bar scan for a 60min time frame and I want aggregation to start at market open 9:30am. Below is my code and it’s starting aggregation at the top of the hour 9:00am. How can I change that?

#code
def inside_bar = high[1] <=high[2] and low[1] >= low[2];
plot s = inside_bar ;

Thank you!
Re: Fun with ThinkScript
April 20, 2018 04:46PM
mikew

It seems to work well, are u sure you have selected the 1 hour time in the inputs below? Am I missing something in your question? What time zone are u using in your settings ? New York (Eastern Standard time)?





Edited 1 time(s). Last edit at 04/20/2018 04:51PM by rigel.
Re: Fun with ThinkScript
April 24, 2018 02:28AM
Rigel - Unfortunately that wasn't the solution. I believe those check boxes just allow the scan to look at after hours, it doesn't effect the aggregation. Even when those boxes are check it still starts the hourly candle at 9:00am instead of 9:30am.

To answer your question, yes EST. To get to the aggregation settings on the chart screen you go to layout > settings > equities > and at the bottom of that screen you have the option to start aggregation at market open. That is my preference, I just don't know how to make that happen with a scan.

Here is an example.

def inside_bar = high[1] <=high[2] and low[1] >= low[2];
plot s = inside_bar;

The scan brought up DGX, the pic below shows bars that aggregate at market open (9:30am). I added the red arrow to show the bar that got falsely signaled.



The picture below is with aggregation at the top of the hour 9:00am. Again I added the red arrow to show the bar that is triggering the scan, this time it's correct. Anyone have a solution for forcing a scan to aggregate at market open?





Edited 2 time(s). Last edit at 04/24/2018 02:59AM by mikew.
Re: Fun with ThinkScript
April 24, 2018 09:09AM
Hi you all, any one who wants to tune up this thing for day trading is welcome, and thanks!




#EXP_LINE_W_PAINT_v2####
#Developed by m0biledev (m0biledev#yahoo.com) 4-4-18
#TradeMark under way!
# you can not sell or distribute #
declare lower;

input price = close;
input length = 7; #8
input displace = 0;
input StochLong = 30; #20
input StochShort = 60; #80
PLOT LINE = 38;
PLOT LINE26 = 24;

##############
input lengthADX = 14;
input averageType = AverageType.WILDERS;

DEF ADX = DMI(lengthADX, averageType).ADX;

input lengthF = 13;
DEF FI = ExpAverage(data = (CLOSE - close[1]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI3 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.THREE_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.THREE_MIN)[3]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI5 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.FIVE_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.FIVE_MIN)[5]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI10 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.TEN_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.TEN_MIN)[10]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI30 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.THIRTY_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.THIRTY_MIN)[30]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FIH = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.HOUR) - CLOSE(PERIOD = AGGREGATIONPERIOD.HOUR)[10]) * volume, lengthF);
##############

########## STOCH_EXP LINE########################
# 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;
#########AvgExp.setLineWeight(2);
##########AvgExp.setDefaultColor(color.orange);

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

DEF AvgExp3 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.THREE_MIN)[displace], length);

DEF AvgExp5 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.FIVE_MIN)[displace], length);

DEF AvgExp10 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.TEN_MIN)[displace], length);

DEF AvgExp15 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.FIFTEEN_MIN)[displace], length);

DEF AvgExp20 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.TWENTY_MIN)[displace], length);

DEF AvgExp30 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.THIRTY_MIN)[displace], length);

DEF AvgExp1H = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.HOUR)[displace], length);

DEF AvgExpD = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.DAY)[displace], length);


###################
###add labels#######

AddLabel (yes, (("0"winking smiley), if AvgExp> AvgExp[1] then Color.cyan else IF AvgExp < AvgExp[1] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("3"winking smiley), if AvgExp3> AvgExp3[3] then Color.cyan else IF AvgExp3 < AvgExp3[3] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("5"winking smiley), if AvgExp5> AvgExp5[5] then Color.cyan else IF AvgExp5 < AvgExp5[5] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("10"winking smiley), if AvgExp10> AvgExp10[10] then Color.cyan else IF AvgExp10 < AvgExp10[10] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("15"winking smiley), if AvgExp15> AvgExp15[15] then Color.cyan else IF AvgExp15 < AvgExp15[15] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("20"winking smiley), if AvgExp20> AvgExp20[20] then Color.cyan else IF AvgExp20 < AvgExp20[20] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, (("30"winking smiley), if AvgExp30> AvgExp30[30] then Color.cyan else IF AvgExp30 < AvgExp30[30] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, (("1H"winking smiley), if AvgExp1H> AvgExp1H[60] then Color.cyan else IF AvgExp1H < AvgExp1H[60] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("EXPD"winking smiley), if AvgExpD> AvgExpD[1] then Color.cyan else IF AvgExpD < AvgExpD[1] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("XD"winking smiley), if AvgExpD> AvgExpD[1] then Color.cyan else IF AvgExpD < AvgExpD[1] then Color.pink ELSE COLOR.light_GRAY );

####################################################################
AssignPriceColor( if AvgExp> AvgExp[1] then CreateColor(0, 205, 250) else IF AvgExp< AvgExp[1] then Color.YELLOW ELSE COLOR.CURRENT );
################################################################


################################################################
plot X= if close >= 0 then 36 else Double.NaN;
X.HideBubble();
X.SetPaintingStrategy (PaintingStrategY.DASHES);
###upsugnal.SetDefaultColor(Color.green);
X.SetLineWeight (5);
X.AssignValueColor( if AVGEXP > AVGEXP[1] AND AVGEXP3>AVGEXP3[3] AND AVGEXP>AVGEXP5[5] AND AVGEXP10>AVGEXP10[10] then Color.GREEN else IF AVGEXP < AVGEXP[1] AND AVGEXP3<AVGEXP3[3] AND AVGEXP5<AVGEXP5[5] AND AVGEXP10<AVGEXP10[10] then Color.RED ELSE COLOR.light_GRAY );

########## EXP SQUARES #############################
plot EXP0 = if close >= 0 then 34 else Double.NaN;
EXP0.HideBubble();
EXP0.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP0.SetLineWeight (4);
EXP0.AssignValueColor(if AVGEXP > AVGEXP[1] then Color.CYAN else if AVGEXP < AVGEXP[1] then COLOR.PINK else Color.GRAY);


plot EXP3 = if close >= 0 then 32 else Double.NaN;
EXP3.HideBubble();
EXP3.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP3.SetLineWeight (4);
EXP3.AssignValueColor(if AVGEXP3 > AVGEXP3[3] then Color.CYAN else if AVGEXP3 < AVGEXP3[3] then COLOR.PINK else Color.GRAY);

plot EXP5 = if close >= 0 then 30 else Double.NaN;
EXP5.HideBubble();
EXP5.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP5.SetLineWeight (4);
EXP5.AssignValueColor(if AVGEXP5 > AVGEXP5[5] then Color.CYAN else if AVGEXP5 < AVGEXP5[5] then COLOR.PINK else Color.GRAY);

plot EXP10 = if close >= 0 then 28 else Double.NaN;
EXP10.HideBubble();
EXP10.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP10.SetLineWeight (4);
EXP10.AssignValueColor(if AVGEXP10 > AVGEXP10[10] then Color.CYAN else if AVGEXP10 < AVGEXP10[10] then COLOR.PINK else Color.GRAY);


plot FE5= if close >= 0 then 26 else Double.NaN;
FE5.HideBubble();
FE5.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
FE5.SetLineWeight (5);
FE5.AssignValueColor(if AVGExp3>AVGExp3[3] AND AVGExp5>AVGExp5[5] AND AVGExp10>AVGExp10[10] then Color.GREEN else IF AVGExp3<AVGExp3[3] AND AVGExp5<AVGExp5[5] AND AVGExp10<AVGExp10[10] then COLOR.DARK_ORANGE else Color.GRAY);


####################################################
######### FI PLOTS ###############################
plot FI0= if close >= 0 then 22 else Double.NaN;
FI0.HideBubble();
FI0.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
FI0.SetLineWeight (2);
FI0.AssignValueColor(if FI > FI[3] then Color.CYAN else if FI < FI[3] then COLOR.RED else Color.GRAY);

plot FI_3= if close >= 0 then 20 else Double.NaN;
FI_3.HideBubble();
FI_3.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
FI_3.SetLineWeight (2);
FI_3.AssignValueColor(if FI3 > FI3[6] then Color.CYAN else if FI3 < FI3[6] then COLOR.RED else Color.GRAY);

plot FI_5= if close >= 0 then 18 else Double.NaN;
FI_5.HideBubble();
FI_5.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
FI_5.SetLineWeight (2);
FI_5.AssignValueColor(if FI5 > FI5[5] then Color.CYAN else if FI5 < FI5[5] then COLOR.RED else Color.GRAY);

plot FI_10= if close >= 0 then 16 else Double.NaN;
FI_10.HideBubble();
FI_10.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
FI_10.SetLineWeight (5);
FI_10.AssignValueColor(if FI10 > FI10[10] then Color.GREEN else if FI10 < FI10[10] then COLOR.DARK_ORANGE else Color.GRAY);

#plot FI_30= if close >= 0 then 14 else Double.NaN;
#FI_30.HideBubble();
#FI_30.SetPaintingStrategy (PaintingStrategy.POINTS);

#FI_30.SetLineWeight (2);
#FI_30.AssignValueColor(if FI30 > FI30[30] then Color.CYAN else if FI30 < FI30[30] then COLOR.RED else Color.GRAY);

#plot FI_H= if close >= 0 then 14 else Double.NaN;
#FI_H.HideBubble();
#FI_H.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
#FI_H.SetLineWeight (2);
#FI_H.AssignValueColor(if FIH > FIH[60] then Color.CYAN else if FIH < FIH[60] then COLOR.RED else Color.GRAY);


AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, ((" F5 "winking smiley), if FI> FI[2] AND FI3>FI3[3] AND FI5>FI5[5] then Color.GREEN else IF FI< FI[3] AND FI3<FI3[3] AND FI5<FI5[5] then Color.RED ELSE COLOR.light_GRAY );
AddLabel (yes, "/", Color.GRAY);

AddLabel (yes, ((" F10 "winking smiley), if FI> FI[2] AND FI3>FI3[3] AND FI5>FI5[5] AND FI10>FI10[10] then Color.GREEN else IF FI< FI[3] AND FI3<FI3[3] AND FI5<FI5[5] AND FI10<FI10[10] then Color.RED ELSE COLOR.light_GRAY );

AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, ((" EXP "winking smiley), if AVGEXP > AVGEXP[1] AND AVGEXP3>AVGEXP3[3] AND AVGEXP>AVGEXP5[5] AND AVGEXP10>AVGEXP10[10] then Color.GREEN else IF AVGEXP < AVGEXP[1] AND AVGEXP3<AVGEXP3[3] AND AVGEXP5<AVGEXP5[5] AND AVGEXP10<AVGEXP10[10] then Color.RED ELSE COLOR.light_GRAY );
AddLabel (yes, "/", Color.GRAY);
#############
AddLabel (yes, ((" "winking smiley), if AVGExp3>AVGExp3[3] AND AVGExp5>AVGExp5[5] AND AVGExp10>AVGExp10[10] then ColoR.Dark_green else IF AVGExp3<AVGExp3[3] AND AVGExp5<AVGExp5[5] AND AVGExp10<AVGExp10[10] then COLOR.DARK_ORANGE else Color.GRAY);


###Alert(AVGExp3>AVGExp3[3] AND AVGExp5>AVGExp5[5] AND AVGExp10>AVGExp10[10], text = "BUY", sound = Sound.bell, "alert type" = Alert.BAR);

###Alert( AVGExp3<AVGExp3[3] AND AVGExp5<AVGExp5[5] AND AVGExp10<AVGExp10[10], text = "SELL", sound = Sound.ding, "alert type" = Alert.BAR);

##plot x1 = cross1;
## x1.SetPaintingStrategy(PaintingStrategY.BOOLEAN_ARROW_UP);
## x1.SetLineWeight(4);
## x1.SetDefaultColor(color.DARK_GREEN);




##CODE END…
under construction mtf indicator
April 24, 2018 09:10AM
Hi you all, any one who wants to tune up this thing for day trading is welcome, and thanks!




#EXP_LINE_W_PAINT_v2####


declare lower;

input price = close;
input length = 7; #8
input displace = 0;
input StochLong = 30; #20
input StochShort = 60; #80
PLOT LINE = 38;
PLOT LINE26 = 24;

##############
input lengthADX = 14;
input averageType = AverageType.WILDERS;

DEF ADX = DMI(lengthADX, averageType).ADX;

input lengthF = 13;
DEF FI = ExpAverage(data = (CLOSE - close[1]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI3 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.THREE_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.THREE_MIN)[3]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI5 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.FIVE_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.FIVE_MIN)[5]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI10 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.TEN_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.TEN_MIN)[10]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FI30 = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.THIRTY_MIN) - CLOSE(PERIOD = AGGREGATIONPERIOD.THIRTY_MIN)[30]) * volume, lengthF);
##############

#input lengthF = 13;
DEF FIH = ExpAverage(data = (CLOSE(PERIOD = AGGREGATIONPERIOD.HOUR) - CLOSE(PERIOD = AGGREGATIONPERIOD.HOUR)[10]) * volume, lengthF);
##############

########## STOCH_EXP LINE########################
# 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;
#########AvgExp.setLineWeight(2);
##########AvgExp.setDefaultColor(color.orange);

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

DEF AvgExp3 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.THREE_MIN)[displace], length);

DEF AvgExp5 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.FIVE_MIN)[displace], length);

DEF AvgExp10 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.TEN_MIN)[displace], length);

DEF AvgExp15 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.FIFTEEN_MIN)[displace], length);

DEF AvgExp20 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.TWENTY_MIN)[displace], length);

DEF AvgExp30 = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.THIRTY_MIN)[displace], length);

DEF AvgExp1H = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.HOUR)[displace], length);

DEF AvgExpD = ExpAverage(CLOSE(PERIOD = AGGREGATIONPERIOD.DAY)[displace], length);


###################
###add labels#######

AddLabel (yes, (("0"winking smiley), if AvgExp> AvgExp[1] then Color.cyan else IF AvgExp < AvgExp[1] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("3"winking smiley), if AvgExp3> AvgExp3[3] then Color.cyan else IF AvgExp3 < AvgExp3[3] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("5"winking smiley), if AvgExp5> AvgExp5[5] then Color.cyan else IF AvgExp5 < AvgExp5[5] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("10"winking smiley), if AvgExp10> AvgExp10[10] then Color.cyan else IF AvgExp10 < AvgExp10[10] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("15"winking smiley), if AvgExp15> AvgExp15[15] then Color.cyan else IF AvgExp15 < AvgExp15[15] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("20"winking smiley), if AvgExp20> AvgExp20[20] then Color.cyan else IF AvgExp20 < AvgExp20[20] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, (("30"winking smiley), if AvgExp30> AvgExp30[30] then Color.cyan else IF AvgExp30 < AvgExp30[30] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, (("1H"winking smiley), if AvgExp1H> AvgExp1H[60] then Color.cyan else IF AvgExp1H < AvgExp1H[60] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("EXPD"winking smiley), if AvgExpD> AvgExpD[1] then Color.cyan else IF AvgExpD < AvgExpD[1] then Color.pink ELSE COLOR.light_GRAY );

AddLabel (yes, (("XD"winking smiley), if AvgExpD> AvgExpD[1] then Color.cyan else IF AvgExpD < AvgExpD[1] then Color.pink ELSE COLOR.light_GRAY );

####################################################################
AssignPriceColor( if AvgExp> AvgExp[1] then CreateColor(0, 205, 250) else IF AvgExp< AvgExp[1] then Color.YELLOW ELSE COLOR.CURRENT );
################################################################


################################################################
plot X= if close >= 0 then 36 else Double.NaN;
X.HideBubble();
X.SetPaintingStrategy (PaintingStrategY.DASHES);
###upsugnal.SetDefaultColor(Color.green);
X.SetLineWeight (5);
X.AssignValueColor( if AVGEXP > AVGEXP[1] AND AVGEXP3>AVGEXP3[3] AND AVGEXP>AVGEXP5[5] AND AVGEXP10>AVGEXP10[10] then Color.GREEN else IF AVGEXP < AVGEXP[1] AND AVGEXP3<AVGEXP3[3] AND AVGEXP5<AVGEXP5[5] AND AVGEXP10<AVGEXP10[10] then Color.RED ELSE COLOR.light_GRAY );

########## EXP SQUARES #############################
plot EXP0 = if close >= 0 then 34 else Double.NaN;
EXP0.HideBubble();
EXP0.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP0.SetLineWeight (4);
EXP0.AssignValueColor(if AVGEXP > AVGEXP[1] then Color.CYAN else if AVGEXP < AVGEXP[1] then COLOR.PINK else Color.GRAY);


plot EXP3 = if close >= 0 then 32 else Double.NaN;
EXP3.HideBubble();
EXP3.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP3.SetLineWeight (4);
EXP3.AssignValueColor(if AVGEXP3 > AVGEXP3[3] then Color.CYAN else if AVGEXP3 < AVGEXP3[3] then COLOR.PINK else Color.GRAY);

plot EXP5 = if close >= 0 then 30 else Double.NaN;
EXP5.HideBubble();
EXP5.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP5.SetLineWeight (4);
EXP5.AssignValueColor(if AVGEXP5 > AVGEXP5[5] then Color.CYAN else if AVGEXP5 < AVGEXP5[5] then COLOR.PINK else Color.GRAY);

plot EXP10 = if close >= 0 then 28 else Double.NaN;
EXP10.HideBubble();
EXP10.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
EXP10.SetLineWeight (4);
EXP10.AssignValueColor(if AVGEXP10 > AVGEXP10[10] then Color.CYAN else if AVGEXP10 < AVGEXP10[10] then COLOR.PINK else Color.GRAY);


plot FE5= if close >= 0 then 26 else Double.NaN;
FE5.HideBubble();
FE5.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
FE5.SetLineWeight (5);
FE5.AssignValueColor(if AVGExp3>AVGExp3[3] AND AVGExp5>AVGExp5[5] AND AVGExp10>AVGExp10[10] then Color.GREEN else IF AVGExp3<AVGExp3[3] AND AVGExp5<AVGExp5[5] AND AVGExp10<AVGExp10[10] then COLOR.DARK_ORANGE else Color.GRAY);


####################################################
######### FI PLOTS ###############################
plot FI0= if close >= 0 then 22 else Double.NaN;
FI0.HideBubble();
FI0.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
FI0.SetLineWeight (2);
FI0.AssignValueColor(if FI > FI[3] then Color.CYAN else if FI < FI[3] then COLOR.RED else Color.GRAY);

plot FI_3= if close >= 0 then 20 else Double.NaN;
FI_3.HideBubble();
FI_3.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
FI_3.SetLineWeight (2);
FI_3.AssignValueColor(if FI3 > FI3[6] then Color.CYAN else if FI3 < FI3[6] then COLOR.RED else Color.GRAY);

plot FI_5= if close >= 0 then 18 else Double.NaN;
FI_5.HideBubble();
FI_5.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
FI_5.SetLineWeight (2);
FI_5.AssignValueColor(if FI5 > FI5[5] then Color.CYAN else if FI5 < FI5[5] then COLOR.RED else Color.GRAY);

plot FI_10= if close >= 0 then 16 else Double.NaN;
FI_10.HideBubble();
FI_10.SetPaintingStrategy (PaintingStrategy.DASHES);
###upsugnal.SetDefaultColor(Color.green);
FI_10.SetLineWeight (5);
FI_10.AssignValueColor(if FI10 > FI10[10] then Color.GREEN else if FI10 < FI10[10] then COLOR.DARK_ORANGE else Color.GRAY);

#plot FI_30= if close >= 0 then 14 else Double.NaN;
#FI_30.HideBubble();
#FI_30.SetPaintingStrategy (PaintingStrategy.POINTS);

#FI_30.SetLineWeight (2);
#FI_30.AssignValueColor(if FI30 > FI30[30] then Color.CYAN else if FI30 < FI30[30] then COLOR.RED else Color.GRAY);

#plot FI_H= if close >= 0 then 14 else Double.NaN;
#FI_H.HideBubble();
#FI_H.SetPaintingStrategy (PaintingStrategy.POINTS);
###upsugnal.SetDefaultColor(Color.green);
#FI_H.SetLineWeight (2);
#FI_H.AssignValueColor(if FIH > FIH[60] then Color.CYAN else if FIH < FIH[60] then COLOR.RED else Color.GRAY);


AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, ((" F5 "winking smiley), if FI> FI[2] AND FI3>FI3[3] AND FI5>FI5[5] then Color.GREEN else IF FI< FI[3] AND FI3<FI3[3] AND FI5<FI5[5] then Color.RED ELSE COLOR.light_GRAY );
AddLabel (yes, "/", Color.GRAY);

AddLabel (yes, ((" F10 "winking smiley), if FI> FI[2] AND FI3>FI3[3] AND FI5>FI5[5] AND FI10>FI10[10] then Color.GREEN else IF FI< FI[3] AND FI3<FI3[3] AND FI5<FI5[5] AND FI10<FI10[10] then Color.RED ELSE COLOR.light_GRAY );

AddLabel (yes, "/", Color.GRAY);
AddLabel (yes, ((" EXP "winking smiley), if AVGEXP > AVGEXP[1] AND AVGEXP3>AVGEXP3[3] AND AVGEXP>AVGEXP5[5] AND AVGEXP10>AVGEXP10[10] then Color.GREEN else IF AVGEXP < AVGEXP[1] AND AVGEXP3<AVGEXP3[3] AND AVGEXP5<AVGEXP5[5] AND AVGEXP10<AVGEXP10[10] then Color.RED ELSE COLOR.light_GRAY );
AddLabel (yes, "/", Color.GRAY);
#############
AddLabel (yes, ((" "winking smiley), if AVGExp3>AVGExp3[3] AND AVGExp5>AVGExp5[5] AND AVGExp10>AVGExp10[10] then ColoR.Dark_green else IF AVGExp3<AVGExp3[3] AND AVGExp5<AVGExp5[5] AND AVGExp10<AVGExp10[10] then COLOR.DARK_ORANGE else Color.GRAY);


###Alert(AVGExp3>AVGExp3[3] AND AVGExp5>AVGExp5[5] AND AVGExp10>AVGExp10[10], text = "BUY", sound = Sound.bell, "alert type" = Alert.BAR);

###Alert( AVGExp3<AVGExp3[3] AND AVGExp5<AVGExp5[5] AND AVGExp10<AVGExp10[10], text = "SELL", sound = Sound.ding, "alert type" = Alert.BAR);

##plot x1 = cross1;
## x1.SetPaintingStrategy(PaintingStrategY.BOOLEAN_ARROW_UP);
## x1.SetLineWeight(4);
## x1.SetDefaultColor(color.DARK_GREEN);




##CODE END…
Re: Fun with ThinkScript
April 25, 2018 07:15PM
Can anyone please help me turn this study into a scan



declare lower;

input n = 2;
input fastLength = 12;
input over_bought = 70;
input price = close;
input over_sold =30;
input averageType = AverageType.WILDERS;




def bar = barNumber();
plot Diff = rsi(fastLength, over_bought, over_sold,close, averageType);
# Diff.SetDefaultColor(GetColor(5));
# Diff.SetPaintingStrategy(PaintingStrategy.LINE);
# Diff.SetLineWeight(3);
# Diff.DefineColor("Positive and Up", Color.GREEN);
# Diff.DefineColor("Positive and Down", #Color.DARK_GREEN);
# Diff.DefineColor("Negative and Down", Color.RED);
# Diff.DefineColor("Negative and Up", Color.DARK_RED);
# Diff.AssignValueColor(if Diff >= 0
# then if Diff > Diff[1]
# then Diff.color("Positive and Up"winking smiley
# else Diff.color("Positive and Down"winking smiley
# else if Diff < Diff[1]
# then Diff.color("Negative and Down"winking smiley
# else Diff.color("Negative and Up"winking smiley);



plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if diff crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if diff crosses below OverBought then OverBought else Double.NaN;


def CurrMACDh = if Diff > 70
then fold i = 1 to n + 1
with p = 1
while p
do Diff > getValue(Diff, -i)
else 0;
def CurrMACDPivotH = if (bar > n and
Diff == highest(Diff, n) and
CurrMACDh)
then Diff
else double.NaN;
def CurrMACDl = if Diff < 30
then fold j = 1 to n + 1
with q = 1
while q
do Diff < getValue(Diff, -j)
else 0;
def CurrMACDPivotL = if (bar > n and
Diff == lowest(Diff, n) and
CurrMACDl)
then Diff
else double.NaN;
def CurrPHBar = if !isNaN(CurrMACDPivotH)
then bar
else CurrPHBar[1];
def CurrPLBar = if !isNaN(CurrMACDPivotL)
then bar
else CurrPLBar[1];
def PHpoint = if !isNaN(CurrMACDPivotH)
then CurrMACDPivotH
else PHpoint[1];
def priorPHBar = if PHpoint != PHpoint[1]
then CurrPHBar[1]
else priorPHBar[1];
def PLpoint = if !isNaN(CurrMACDPivotL)
then CurrMACDPivotL
else PLpoint[1];
def priorPLBar = if PLpoint != PLpoint[1]
then CurrPLBar[1]
else priorPLBar[1];
def HighPivots = bar >= highestAll(priorPHBar);
def LowPivots = bar >= highestAll(priorPLBar);
def pivotHigh = if HighPivots
then CurrMACDPivotH
else double.NaN;

plot pivotLow = if LowPivots
then CurrMACDPivotL
else double.NaN;
pivotLow.enableApproximation();
pivotLow.SetDefaultColor(GetColor(1));
pivotLow.SetStyle(Curve.Short_DASH);
plot PivotDot = if !isNaN(pivotHigh)
then pivotHigh
else if !isNaN(pivotLow)
then pivotLow
else double.NaN;
pivotDot.SetDefaultColor(GetColor(1));
pivotDot.SetPaintingStrategy(PaintingStrategy.POINTS);
pivotDot.SetLineWeight(3);
#AssignPriceColor(Diff.TakeValueColor());

diff.DefineColor("OverBought", GetColor(5));
diff.DefineColor("Normal", GetColor(7));
diff.DefineColor("OverSold", GetColor(5));
diff.AssignValueColor(if diff > over_Bought then diff.color("OverBought"winking smiley else if diff < over_Sold then diff.color("OverSold"winking smiley else diff.color("Normal"winking smiley);




# End Code Pivots with Projections
Re: Fun with ThinkScript
April 25, 2018 08:31PM
Taz43 -

Try this:

def n = 2;
def fastLength = 12;
def over_bought = 70;
def price = close;
def over_sold =30;
def averageType = AverageType.WILDERS;


def bar = barNumber();
def Diff = rsi(fastLength, over_bought, over_sold,close, averageType);


def OverSold = over_Sold;
def OverBought = over_Bought;
def UpSignal = if diff crosses above OverSold then OverSold else Double.NaN;
def DownSignal = if diff crosses below OverBought then OverBought else Double.NaN;


def CurrMACDh = if Diff > 70 then fold i = 1 to n + 1 with p = 1 while p do Diff > getValue(Diff, -i) else 0;
def CurrMACDPivotH = if (bar > n and Diff == highest(Diff, n) and CurrMACDh) then Diff else double.NaN;
def CurrMACDl = if Diff < 30 then fold j = 1 to n + 1 with q = 1 while q do Diff < getValue(Diff, -j) else 0;
def CurrMACDPivotL = if (bar > n and Diff == lowest(Diff, n) and CurrMACDl) then Diff else double.NaN;
def CurrPHBar = if !isNaN(CurrMACDPivotH) then bar else CurrPHBar[1];
def CurrPLBar = if !isNaN(CurrMACDPivotL) then bar else CurrPLBar[1];
def PHpoint = if !isNaN(CurrMACDPivotH) then CurrMACDPivotH else PHpoint[1];
def priorPHBar = if PHpoint != PHpoint[1] then CurrPHBar[1] else priorPHBar[1];
def PLpoint = if !isNaN(CurrMACDPivotL) then CurrMACDPivotL else PLpoint[1];
def priorPLBar = if PLpoint != PLpoint[1] then CurrPLBar[1] else priorPLBar[1];
def HighPivots = bar >= highestAll(priorPHBar);
def LowPivots = bar >= highestAll(priorPLBar);
def pivotHigh = if HighPivots then CurrMACDPivotH else double.NaN;
def pivotLow = if LowPivots then CurrMACDPivotL else double.NaN;

plot PivotDot = if !isNaN(pivotHigh) then pivotHigh else if !isNaN(pivotLow) then pivotLow else double.NaN;

Hope that helps smiling smiley
Re: Fun with ThinkScript
April 25, 2018 09:54PM
those smileys are tough for someone that doesn't know how to fix them
Re: Fun with ThinkScript
April 25, 2018 10:07PM
Thank you for the quick reply

It may be working but I am not getting any results...
Re: Fun with ThinkScript
April 25, 2018 10:24PM
Taz43 Wrote:
-------------------------------------------------------
> Thank you for the quick reply
>
> It may be working but I am not getting any
> results...

I got error messages on install =. Will try again.
Re: Fun with ThinkScript
April 26, 2018 07:39AM
mikew, try this... didn't have the time to test it though.

def Begin = 0930;

def Active = if SecondsFromTime(Begin) > 0 then 1 else 0;
def inside_bar = high[1] <=high[2] and low[1] >= low[2];
plot s = Active == 1 and inside == 1;
Re: Fun with ThinkScript
April 26, 2018 09:35AM
rigel - Thanks for trying but unfortunately the scan is still starting the hourly candle at 9:00am instead of 9:30am.

I think I'm going to have to use a 30 minute time frame and figure out how get it from there. I'll be sure to post my findings if I find a solution.

Thanks!
Leavitt convolution
April 26, 2018 02:39PM
 I am thinkscript newbie although I've used TOS for years. Last year I published an article in TASC called Riding the Waves. It trades bull put spreads utilizing multiple probabilities. Since then I published in TASC several more articles about futures. All these articles are based on the Leavitt convolution. I've made the code for this function and several related indicators available in Easylanguage. However, I've received numerous requests for them in thinkscript. The code immediately below is incorrect but it's the right idea. It uses the script, Inertia, which plots the leading edge of the linear regression at the current value.
def price = Close;
input length = 9;
def intLength = Floor(Sqrt(length));
plot lc = inertia(inertia(price, length), intLength);
lc.AssignValueColor(if lc > lc[1] then Color.GREEN else Color.RED);
The function, inertia, needs to be replaced buy a new function called LeavittProjection. It uses the same a & b as inertia. while inertia plots ax + b my function should plot a(x-1)+b. I presume this is one bar ahead of the close.
I tried  
script LeavittProjection{ 
input y = close; 
input n = 20; 
rec x = x[1] + 1; 
def a = (n * sum(x * y, n) - sum(x, n) * sum(y, n) ) / ( n *sum(Sqr(x), n) - Sqr(sum(x, n))); 
def b = (sum(Sqr(x), n) * sum(y, n) - sum(x, n) * sum(x *y, n) ) / ( n * sum(Sqr(x), n) - Sqr(sum(x, n))); 
plot LeavittProjection= a * (x - 1) + b;

but it only generated an error.
Re: Fun with ThinkScript
April 26, 2018 08:16PM
Does anyone have any rsi divergence scans they'd be willing to share?
Re: Fun with ThinkScript
April 26, 2018 09:12PM
this is exactly what I was looking for but the link isn't there anymore. does anyone have the script for this, that they could share with me?
Re: Fun with ThinkScript
April 26, 2018 09:24PM
this is exactly what I was looking for but the link isn't there anymore. does anyone have the script for this, that they could share with me?


I'm looking for the comment Robert made on page 19, about writing a code that will mark the high and low of a candle.
(here is the link to the page that I'm talking about)
page 19 on researchtrade.com

the one Robert directed was for RobertPayne_Mark_High_Low_x_Days_Ago customizing script.
Quote
robert
Based on user input, this script will mark the high and low from the previous x number of days. it will work for any charting time frame from 1 minute up to and including a daily chart.

(here is the link to the video)
mark high/low from previous x number of days



Edited 1 time(s). Last edit at 04/26/2018 09:32PM by wichitawx.
Re: Leavitt convolution
April 27, 2018 05:57AM
jalea148

If I close your script with "{ " and then replace inertia by LeavittProjection I don't get an error but this plot


If that is what you are looking for then you only forgot to close the script.
Re: Fun with ThinkScript
April 28, 2018 07:26AM
mikew Wrote:
-------------------------------------------------------
Quote
mikew

rigel - Thanks for trying but unfortunately the
scan is still starting the hourly candle at 9:00am
instead of 9:30am.

I think I'm going to have to use a 30 minute time
frame and figure out how get it from there. I'll
be sure to post my findings if I find a solution.


Oh! now I got what you meant.... Indeed it seems that TOS needs to consider by definition 9:00 as starting time when your aggregation period is set to 1 hour, you can see that in the charts, if you select in settings show extended hours, that half the first bar is in pre-market. Certainly moving to lower time frames should have you started at 9:30



Edited 2 time(s). Last edit at 04/28/2018 03:54PM by rigel.
Re: Fun with ThinkScript
April 29, 2018 08:35AM
wichitawx

I don't have Robert's code but I modified some basic code found in Internet (no author to give credit for) which produces what you are looking for





# Plot the high and low of X days ago
# Don't know the author of original code to give proper credit
# Basic code modified to produce similar results to Robert Payne's solution
# by Rigel April 2018
#

declare upper;
input LastBubble = No; 
Input DaysAgo = 1;#hint DaysAgo: Excludes today
def AdjDaysAgo = DaysAgo + 1;#Adjusted to match a true LastDate which includes today 
def day = GetDay();
def lastDay = GetLastDay();
def year = GetYear();
def lastYear = GetLastYear();
def yyyymmdd = GetYYYYMMDD();
def agg=aggregationPeriod.DAY;

As the author of the request seems not interested the rest of the code has been deleted



Edited 1 time(s). Last edit at 05/12/2018 04:35AM by rigel.
Re: Leavitt convolution
April 29, 2018 09:33AM
That works, thank you. The next step is to make the LeavittProjection into a function. How is that done? That will be the final step for the creation of the LeavittConvolution both as an indicator and as a function.
Re: Leavitt convolution
April 29, 2018 10:02AM
Jalea

the "script" reserved word acts as a function as you already know and it is possible to reference a study (like the projection) from another study (that possibly is what you mean), but I need you to show me what you want (article I can read, pseudo code, formula, excel spreadsheet or maybe in another programming language?) as it is not clear to me what would be the convolution you are talking about.



Edited 3 time(s). Last edit at 04/29/2018 10:23AM by rigel.
Re: Fun with ThinkScript
April 29, 2018 02:40PM
I was wondering if it was possible to make a custom watch list. I place the study "universaloscillator" on my thinkorswim watchlist, i was hoping to make 4 columns for the time ranges 1 min, 5, 15, and daily. I'd like the column to turn Red when the value equals -1.

Is this possible or very difficult?
Sorry, only registered users may post in this forum.

Click here to login