Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

Fun with ThinkScript

Posted by robert 
Re: Help with alert message
November 12, 2020 03:50PM
try:

Alert(!IsNaN(condition1), "MA Min buy", Alert.Bar, Sound.Chimes);
ThinkScript help with HMA alert message
November 12, 2020 03:42PM
Hello forum,

Below is a script that has an alert that for some reason is not working(e.g. no message when condition is met). What am I missing? Thanks.

Code:
declare upper;

input price = CLOSE;
input HMA_Length = 55;
input lookback = 2;
input labels=no;

plot HMA = HullMovingAvg(price = price, length = HMA_Length);

def delta = HMA[1] - HMA[lookback + 1];
def delta_per_bar = delta / lookback;

def next_bar = HMA[1] + delta_per_bar;

def concavity = if HMA > next_bar then 1 else -1;

plot turning_point = if concavity[1] != concavity then HMA else double.nan;

HMA.AssignValueColor(Color = if concavity[1] == -1 then
if HMA > HMA[1] then color.yellow else color.blue else
if HMA < HMA[1] then color.yellow else color.orange);

HMA.SetLineWeight(4);

turning_point.SetLineWeight(4);
turning_point.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
turning_point.SetDefaultColor(color.white);

plot MA_Max = if HMA[-1] < HMA and HMA > HMA[1] then HMA else Double.NaN;
MA_Max.SetDefaultColor(Color.WHITE);
MA_Max.SetPaintingStrategy(PaintingStrategy.SQUARES);
MA_Max.SetLineWeight(3);

plot MA_Min = if HMA[-1] > HMA and HMA < HMA[1] then HMA else Double.Nan;
MA_Min.SetDefaultColor(Color.WHITE);
MA_Min.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
MA_Min.SetLineWeight(3);

plot sell = if turning_point and concavity == -1 then high else double.nan;
sell.SetDefaultColor(Color.blue);
sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sell.SetLineWeight(1);

plot buy = if turning_point and concavity == 1 then low else double.nan;
buy.SetDefaultColor(Color.orange);
buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buy.SetLineWeight(1);

def ROC = HMA - next_bar;

addLabel(yes and labels, concat("ROC: " , ROC), color = if concavity < 0 then if ROC[1] > ROC then Color.blue else color.black else if ROC[1] < ROC then color.orange else color.red);

def arrow_plots = high-low;
def plothigh = high + arrow_plots * 0.5;
def plotlow = low - arrow_plots * 0.5;

plot arrowUP = if MA_Min then plotlow else double.nan;
ArrowUP.setpaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUP.SetLineWeight(3);
ArrowUP.SetDefaultColor(Color.ORANGE);

plot arrowdown = if MA_Max then plothigh else double.nan;
ArrowDown.setpaintingStrategy(PaintingStrategy.ARROW_Down);
ArrowDown.SetLineWeight(3);
ArrowDown.SetDefaultColor(Color.BLUE);

def condition1 = MA_Min;
def condition2 = MA_Max;
Alert(condition1, "MA Min buy", Alert.Bar, Sound.Chimes);
Alert(condition2, "MA Max sell", Alert.Bar, Sound.Bell);
Re: Help with alert message
November 14, 2020 06:09PM
Thanks RAD10 for the script suggestion, it directed my attention to the use of isnan, it did not work as is however, as I researched isnan, i was able to create one that did trigger, however not sure if the below is still correct...will have to see when the market opens Monday...it currently is triggering a buy and sell message each time I open the chart, which doesn't make sense right now...I thought the condition would only look at the last met condition and trigger the message:buy or sell.

code:
def condition1 = if isnan(MA_Min) then 1 else 0;
def condition2 = if isnan(MA_Max) then 1 else 0;
Help with assignbackgroundcolor issue
November 16, 2020 07:50PM
Hi There Forum

I created a custom quote script that has 4 addlabel's. The ROCUp_slowing and the ROCdown_slowing are not getting the requested color in the script. Any assistance would be appreciated.

code:
def AO = Average(hl2, 5) - Average(hl2, 34);
def Zero = 0;

plot signalline = Average(AO, 5);

def ROCup_Accelerating = if AO > zero then 1 else 0;
def ROCup_Slowing = if AO > zero and AO < signalline then 1 else 0;
def ROCdown_Accelerating = if AO < zero then 1 else 0;
def ROCdown_Slowing = if AO < zero and AO > signalline then 1 else 0;

AddLabel(ROCup_Accelerating, "ROC Up & growing", color.black);
AddLabel(ROCup_Slowing, "ROC Up & slowing", color.black);
AddLabel(ROCdown_Accelerating, "ROC Down & growing", color.yellow);
AddLabel(ROCdown_Slowing, "ROC Down & slowing", color.yellow);

AssignBackgroundColor(if ROCup_accelerating then color.orange else if ROCup_Slowing then color.red else if ROCdown_Accelerating then color.blue else color.orange);



Edited 2 time(s). Last edit at 11/16/2020 07:58PM by liminaltrader.
THINKSCRIP TO PINESCRIPT help
November 26, 2020 12:16PM
hi, anybody could help me figuring out how to convert a thinkscript to pine script with a -[1] and [1] combined?
I am really thankful
in advance.


input fastLength60 = 3;
input slowLength60 = 17;
input averageType60 = AverageType.SIMPLE;

plot green = MovingAverage(averageType60, close[-1], fastLength60) - MovingAverage(averageType60, close[1], slowLength60) ;
Re: Fun with ThinkScript
December 03, 2020 11:57AM
Hello,

I am trying to find the highest close within the last 10 bars, then I am looking to find the low of the candle immediately before that. This is what I have so far, it is not working though, any help is appreciated.

def A = highest(close,10);
plot B = if A then getvalue(low[1],1) else double.NaN;
"P/L Day:" calculation in ThinkScript
December 08, 2020 07:15AM
Does anyone have code to calculate the P/L Day that appears in the TOS watchlist?
assignbackgroundcolor issue
December 19, 2020 07:02AM
The problem is that AssignBackgroundColor changes ALL the color of the background, not just a portion as you are trying to do.
What you want is to change dynamically portions of the background, you can do that using AddCloud

Somewhere in this thread Robert posted a solution to that.
Re: Buy and Sell lines on chart of zigzag
December 26, 2020 09:07PM
Works great! Can this "Buy" message also be displayed in a watchlist column with Green or Red background also? If so what would have to be added to the script please?
Scan stock crossing previous day hign
December 29, 2020 04:09PM
Hi,
I would like to scan for stock crossing yesterday high.I tried to write it many times but my scan come up empty.
Thanks
Aroon indicator alert
January 26, 2021 12:31AM
Hello everyone,
I have read many posts here but did not find anything about aroon indicator alert on here.
I have tried to code for Aroon indicator alert but never work. Can anybody help please?
I want Aroon down (red color) reach 100 = alert sms. How can we combine different time frames into one alert for example:

Aroon down (red color)= 100 in 5 mins chart and;
Aroon down (red color)= 100 in 15 mins chart

= alert sms

If it work, how can i scan market for stock has Aroon down/up = 100 in specific time frame, such as 15 mins chart on TOS.

Many thanks
Re: Aroon indicator alert
February 01, 2021 05:55AM
Hi

Your question is about how to create and alert OR have to be informed by sms?

Alerts in your programs can de sent to you by sms if you setup up it in the Notifications area:
[tlc.thinkorswim.com]

Youtube
Low before highest close
February 01, 2021 06:41AM


Try this
def A =  highest(close,10); 
def peak= if close==A then barnumber() else double.nan ;
plot mylow= getvalue(low,(barnumber()-peak+1)) ;


mylow.setPaintingStrategy(paintingStrategy.HORIZONTAL)  ;
Re: Fun with ThinkScript
February 04, 2021 02:37PM
Hi guys, new here. Maybe someone can assist in finding a script for TOS, identifying some of the common patterns- double or tripple top/bottom? Strange but Patterns in TOS charts don't find these accurately.
Re: Fun with ThinkScript
February 05, 2021 06:53AM
dtop
[www.sendspace.com]



Not sure how to attach pictures here, tried a link from sendspace, no luck.
So I'll try to explain what I am looking for:
Identifying the trade situation when after a price impulse up, there is a correction forming tripple top and then breaking up the resistance level formed by 3 tops.
Anyone may help with a sample code?





Edited 5 time(s). Last edit at 02/05/2021 11:58AM by nickolaustort.
Re: Fun with ThinkScript
February 07, 2021 02:21PM
Looks simple but I'm having a problem figuring out what it is being calculated based off of? I know this is a TOS forum but could someone help me understand this?

Thanks

// © blackcat1402
//@version=4

study("[blackcat] L1 Banker Entry Indicator", overlay=false)

//functions
xrf(values, length) =>
    r_val = float(na)
    if length >= 1
        for i = 0 to length by 1
            if na(r_val) or not na(values)
                r_val  :=  values
                r_val
    r_val
xsa(src,len,wei) =>
    sumf = 0.0
    ma = 0.0
    out = 0.0
    sumf  :=  nz(sumf[1]) - nz(src[len]) + src
    ma  :=  na(src[len]) ? na : sumf/len
    out  :=  na(out[1]) ? ma : (src*wei+out[1]*(len-wei))/len
    out


//model of banker model with customized input threshold
bankerthreshold = input(3, title="banker entry threshold", type=input.integer, minval = 1)
bankermodel = (3)*(xsa(((close - lowest(low,27))/(highest(high,27) - lowest(low,27)))*(100),5,1)) - (2)*(xsa(xsa(((close - lowest(low,27))/(highest(high,27) - lowest(low,27)))*(100),5,1),3,1))
pumpdumpsoon = iff(crossover(bankermodel,bankerthreshold),100,0)
longshortentry = iff((bankermodel <= 3),50,0)
bankermove = iff((bankermodel < 5),25,0)

//model banker pump or dump start soon
ppumpdumpsoon = plot(pumpdumpsoon,color=color.green, linewidth=3,style=plot.style_area, transp=30)
//model long short entry
plongshortentry = plot(longshortentry,color=color.orange, linewidth=3,style=plot.style_area, transp=30)
//model banker move
pbankermove = plot(bankermove,color=color.yellow, linewidth=3,style=plot.style_area, transp=70)




Edited 1 time(s). Last edit at 02/09/2021 02:26PM by Ken_Adams.
Why does red appear on my chart
February 08, 2021 12:19PM
I have the simple script below. When I view the chart anything not LIGHT_GREEN in color is colored RED. But I have not defined a default bg color of RED anywhere that I can find. What am I missing?

plot E40 = MovAvgExponential(close, 40);
E40.setDefaultColor(color.mAGENTA);
E40.setLineWeight(3);
def hiGLevel = if close > E40 then Double.POSITIVE_INFINITY else Double.NEGATIVE_INFINITY;
AddCloud(hiGLevel, -hiGLevel, Color.LIGHT_GREEN);
Re: Why does red appear on my chart
February 09, 2021 02:25PM
Because AddCloud expect two colors as parameters.
You only have one specified, the other, red, is assigned by default
Re: Why does red appear on my chart
February 25, 2021 07:13PM
Could someone help me break this down?

def Week2 = Round (AbsValue (high[44] - low[44]));
def Week1 = Round (AbsValue (high[43] - low[43]));

What do the number (43, and 44) represent? Is this a particular week of the year it's referring to or something like that?
Price open above Pivot point
April 05, 2021 03:06PM
Hi Friends - I trying to a screen all stocks where the price opens above weekly central pivot point and price has increased in the last 5 min candles consistently. I'm literally struggling ..to get this code. can someone help me.

Here is what I've.

def today = GetWeek() == GetLastWeek();
def mktOpen = SecondsFromTime(630) == 0 or GetWeek() <> GetWeek()[1];
def LweekOpen = if today then LweekOpen[1] else if mktOpen then open else LweekOpen[1]; #Last week open
def LweekHigh = if today then LweekHigh[1] else if mktOpen then high else if high > LweekHigh[1] then high else LweekHigh[1]; #Last week yesterday's high
def LweekLow = if today then LweekLow[1] else if mktOpen then low else if low < LweekLow[1] then low else LweekLow[1]; #Last weeks low
def LweekClose = if today then LweekClose[1] else close; #Last week close

def calc_PP = (LweekHigh + LweekLow + LweekClose) / 3;

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =

IsUp[3] and
IsUp[2] and
IsUp[1] and
calc_PP[0] and
high[1] <= high[0] and
open[1] <= low[0] and
high[2] <= high[1] and
open[2] <= low[1] and
high[3] <= high[2] and
open[3] <= low[2];
Re: Price open above Pivot point
April 07, 2021 04:27PM
Hi Experts - Can anyone help me on this, please.
Re: Price open above Pivot point
April 07, 2021 09:20PM
jaya.sai986@gmail.com Wrote:
-------------------------------------------------------
> Hi Experts - Can anyone help me on this, please.

Hello,

If scripting experts are what you're looking for you'll probably find it here. [usethinkscript.com]

R
Re: Fun with ThinkScript
April 08, 2021 09:54PM
Hi Robert

I believe this is an old thread but hopefully you can help me and the community with a pre-earning analyzer that is a top indicator (overlay on the price chart).
The analyzer look at the past 8 earnings (2 year) and create three zone:
> 21 days before earning
> 8 day before earnings
> 8 days after earning

It creates a vertical line (with indication) in each of these date, and paint clouds of dark green, if the price went up inside the zone or, dark red if price went down inside the zone. The zones are:
> Zone 1: 21 days to 8 days before earnings
> Zone 2: 8 days before earnings to earning date
> Zone 3: Earning date to 8 days past earnings

On each of the past 8 earning dates it create a balloon: dark red if price gapped down the day after earnings with indication of -xy% (the percentage of gap down); and a dark green balloon if gapped up the day after earning with +xy% (the percentage of gap up).

Then it also adds a bunch of balloons or frames at the top of the chart with the following earning statistics:
>Of the past 8 earnings analysis: X times beat earnings; Y times missed earnings
> Zone 1: average gain/loss % in zone one of the past 8 earnings
> Zone 2: average gain/loss % in zone two of the past 8 earnings
> Zone 3: average gain/loss % in zone three of the past 8 earnings

Using the above gain/loss percentage of each zone, it also creates forward looking pivot lines (target prices) in the 3 zone of the next or upcoming earnings (meaning if now we are 21 days before next earnings and the stock price is at $100, and the average Zone 1 (21 days to 8 days before earning) gain/loss was 10%, than it will create a price target line inside the upcoming zone one at $110. and alo in the same way the target price for zone two and three.

I think this could be quite a useful tool to the whole community helping to trade earnings. Hope this is not too much of trouble, and I want to thank you so much in advance. It would be truly appreciated

Many Thank
EastMan :-)

PS: I have an image of the analyzer but i don't know how to upload the picture from my computer to this post.



Edited 1 time(s). Last edit at 04/08/2021 10:00PM by EastMan.
Re: Fun with ThinkScript
April 08, 2021 10:12PM
Hi Robert

I believe this is an old thread but hopefully you can help me and the community with a pre-earning analyzer that is a top indicator (overlay on the price chart).
The analyzer look at the past 8 earnings (2 year) and create three zone:
> 21 days before earning
> 8 day before earnings
> 8 days after earning

It creates a vertical line (with indication) in each of these date, and paint clouds of dark green, if the price went up inside the zone or, dark red if price went down inside the zone. The zones are:
> Zone 1: 21 days to 8 days before earnings
> Zone 2: 8 days before earnings to earning date
> Zone 3: Earning date to 8 days past earnings

On each of the past 8 earning dates it create a balloon: dark red if price gapped down the day after earnings with indication of -xy% (the percentage of gap down); and a dark green balloon if gapped up the day after earning with +xy% (the percentage of gap up).

Then it also adds a bunch of balloons or frames at the top of the chart with the following earning statistics:
>Of the past 8 earnings analysis: X times beat earnings; Y times missed earnings
> Zone 1: average gain/loss % in zone one of the past 8 earnings
> Zone 2: average gain/loss % in zone two of the past 8 earnings
> Zone 3: average gain/loss % in zone three of the past 8 earnings

Using the above gain/loss percentage of each zone, it also creates forward looking pivot lines (target prices) in the 3 zone of the next or upcoming earnings (meaning if now we are 21 days before next earnings and the stock price is at $100, and the average Zone 1 (21 days to 8 days before earning) gain/loss was 10%, than it will create a price target line inside the upcoming zone one at $110. and alo in the same way the target price for zone two and three.

I think this could be quite a useful tool to the whole community helping to trade earnings. Hope this is not too much of trouble, and I want to thank you so much in advance. It would be truly appreciated

Many Thank
EastMan :-)

PS: I have an image of the analyzer but i don't know how to upload the picture from my computer to this post.
Re: Fun with ThinkScript
April 12, 2021 11:17AM
Hi All,

While I was waiting, I started writing my own code. Still doesn't do all of the above that I wanted, but may be a good starter to check Pre/Post Earning performance and use that to play earnings. At the start of each zone, there is a bubble with the Gain/Loss of that zone, and there is another bubble that shows the Gap (up or Down) on the day after Earnings. Will be happy to get comments and improvements :-)

input daysBefore1 = 21;
input daysBefore2 = 8;
input daysAfter = 8;

input showLines = yes;
input paintBackground = yes;
#------------------------------------------------
# Add Vertical Lines: 21, 8 daysAfter before ER, on ER date, and 8 days after ER 
DefineGlobalColor("21 Days Pre-ER", Color.WHITE);
DefineGlobalColor("8 Days Pre-ER", Color.WHITE);
DefineGlobalColor("Earnings Day", Color.YELLOW);
DefineGlobalColor("8 Days Post-ER", Color.WHITE);
DefineGlobalColor("Up", Color.GREEN);
DefineGlobalColor("Down", Color.RED);


AddVerticalLine(showLines and HasEarnings(), "Earnings Day", GlobalColor("Earnings Day" ), Curve.FIRM);
AddVerticalLine(showLines and HasEarnings()[-daysBefore1], "21 Days Pre-ER", GlobalColor("21 Days Pre-ER" ), Curve.FIRM);
AddVerticalLine(showLines and HasEarnings()[-daysBefore2], "8 Days Pre-ER", GlobalColor("8 Days Pre-ER" ), Curve.FIRM);
AddVerticalLine(showLines and HasEarnings()[daysAfter], "8 Days Post-ER", GlobalColor("8 Days Post-ER" ), Curve.FIRM);

#------------------------------------------------
#Create cloud in the pre and post earnings zones. 
def Zone1 = HasEarnings()[-daysBefore1]; #start of Zone 1
def Zone2 = HasEarnings()[-daysBefore2]; #start of Zone 2
def Zone3 = HasEarnings()[-daysBefore1]; #start of Zone 3 (post earning)
# Coloring Zone1
AddCloud(if Highest(Zone1, daysBefore1 - daysBefore2) > 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(Zone1, daysBefore1 - daysBefore2) > 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.DARK_GRAY, Color.CURRENT);
# Coloring Zone2
AddCloud(if Highest(Zone2, daysBefore2) > 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(Zone2, daysBefore2) > 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.DARK_GREEN, Color.CURRENT);
# Coloring Zone3
AddCloud(if Highest(HasEarnings(), daysAfter) > 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(HasEarnings(), daysAfter) > 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.GRAY, Color.CURRENT);

# Add Bubble with zones gain
def OZ1 = If (HasEarnings()[-21], close, Double.NaN);
def CZ1 = If (HasEarnings()[-21], close[-13], Double.NaN);
def Gain1 = CZ1 / OZ1 - 1;
AddChartBubble(HasEarnings()[-21], high, "Z1G:" + AsPercent(Gain1), Color.WHITE, yes);  # Add Bubble on 21 day PreER with gain from 21 days to 8 day pre ER

def OZ2 = If (HasEarnings()[-8], close, Double.NaN);
def CZ2 = If (HasEarnings()[-8], close[-8], Double.NaN);
def Gain2 = CZ2 / OZ2 - 1;
AddChartBubble(HasEarnings()[-8], high*1.1, "Z2G:" + AsPercent(Gain2), Color.WHITE, yes);  # Add Bubble on 8 day PreER with gain from 8 days pre ER to ER date

def OZ3 = If (HasEarnings()[8], open[7], Double.NaN);
def CZ3 = If (HasEarnings()[8], close, Double.NaN);
def Gain3 = CZ3 / OZ3 - 1;
AddChartBubble(HasEarnings()[8], high*1.1, "Z3G:" + AsPercent(Gain3), Color.WHITE, yes);  # Add Bubble on 8 day postER with gain from ER date to 8 days post ER


#Define Earning Day and Day After Earnings and calculate Gap and add Bubble on Earnimg day
def DayAfter = If (HasEarnings()[1], open, Double.NaN);
def ER_Day = If (HasEarnings()[1], close[1], Double.NaN);
def Gap = DayAfter / ER_Day - 1;
AddChartBubble(HasEarnings()[1], high * 1.2, "Gap:" + AsPercent(Gap), Color.GRAY, yes);



Edited 1 time(s). Last edit at 04/12/2021 11:20AM by EastMan.
TCB
Re: Fun with ThinkScript
April 13, 2021 12:27PM
Hi, I have started to write this script that plots rectangular boxes on the chart and it works but I want it to show only on the current intraday chart. As is stands now, if you scroll back it shows on previous days. I can't seem to figure this out. Does anyone know what I need to do to correct this problem? I would really appreciate any help, thanks! I have included the script below:

input ShowTodayOnly={"No", default "Yes"};
input alertPeriodStart = 930;
input alertPeriodEnd = 1130;
def Today = if GetLastDay() == GetDay() then 1 else 0;
def StartAlertPeriod = SecondsTillTime(alertPeriodStart);
def EndAlertPeriod = SecondsTillTime(alertPeriodEnd);
def AlertPeriod = If (StartAlertPeriod <= 0 and EndAlertPeriod > 0, close, 0);

input PutLevelStart = 0.0;
input CallLevelStart = 0.0;
input Range = 0.0;

input HideBoxLines = Yes;
input HideLabels = Yes;

def PutTopBox = PutLevelStart + Range;
def CallBottomBox = CallLevelStart - Range;

plot TopArea = HighestAll (if AlertPeriod then PutTopBox else Double.NaN);
TopArea.SetDefaultColor(Color.GRAY);
TopArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TopArea.SetHiding(HideBoxLines);

plot BottomArea = HighestAll (if AlertPeriod then CallBottomBox else Double.NaN);
BottomArea.SetDefaultColor(Color.GRAY);
BottomArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BottomArea.SetHiding(HideBoxLines);

plot PutBBox = LowestAll (if AlertPeriod then PutLevelStart else Double.NaN);
PutBBox.SetDefaultColor(Color.GRAY);
PutBBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PutBBox.SetHiding(HideBoxLines);

plot CallTBox = HighestAll (if AlertPeriod then CallLevelStart else Double.NaN);
CallTBox.SetDefaultColor(Color.GRAY);
CallTBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
CallTBox.SetHiding(HideBoxLines);

AddCloud(if AlertPeriod then TopArea else Double.NaN, if AlertPeriod then PutBBox else Double.NaN, Color.GRAY, Color.GRAY);
AddCloud(if AlertPeriod then BottomArea else Double.NaN, if AlertPeriod then CallTBox else Double.NaN, Color.GRAY, Color.GRAY);
TCB
Re: Fun with ThinkScript
April 13, 2021 02:30PM
Thanks I had to add a couple more lines to get it to work
Count price movement in percent and then cluster them?
May 06, 2021 08:38PM
I was wondering if there is a way to do the following -- (End result should be labels)

I want to calculate the % move of each candle for say 12 bars and then 3 labels based on that data

Label for All bars (The numbers below is just for example purposes)
Between 10% - 5% = 3 out of 12
Between 5% - 2% = 5 out of 12
Less Than 2% = 4 out of 12

The color of the bar or direction doesn't really matter if we could do another set of labels based on the direction on top of the cumulative that would be really cool

Label for Green Bar
Total Green Bars ( 5 out of 12)
Between 10% - 5% = 1 out of 5
Between 5% - 2% = 2 out of 5
Less Than 2% = 2 out of 5

Label for Red Bar
Total Red Bars ( 7 out of 12)
Between 10% - 5% = 2 out of 7
Between 5% - 2% = 2 out of 7
Less Than 2% = 3 out of 7

Any guidance will be very helpful. Thank You.
Re: Fun with ThinkScript
June 05, 2021 08:49PM
Hi...Does anyone how to add an AddOrder "Sell_To_Close at 15:55 PM" for this basic script? Or "Close All Trades At End Of Day" etc...

I want to day-trade backtest it, but it always gives me too many overnight closes. Thanks


###

def BuyCriteria =

TrueRange("high" = HIGH, "close" = hl2, "low" = LOW) is greater than ATR("length" = 22, "average type" = "HULL"winking smiley and close is greater than hl2 and MoneyFlowIndex("length" = 111)."MoneyFlowIndex" is greater than MoneyFlowIndex("length" = 14)."MoneyFlowIndex" from 1 bars ago;

AddOrder(OrderType.BUY_AUTO, BuyCriteria, tickcolor = Color.YELLOW, arrowcolor = Color.GREEN, name = "Buy", tradeSize = 100);

###



Edited 1 time(s). Last edit at 06/05/2021 09:20PM by toncuz.
Adding an AddOrder...Sell_To_Close by time
June 05, 2021 09:18PM
Hi....A few questions...

1...Can anyone add an AddOrder...to the script below...to "Close_To_Sell at 15:55". Or..."Close All Trades At End Of Day". I want to backtest it without all the overnight trades popping up.
2...Also...Is there a standalone script that does the same thing? For example, if I want to add a "stop-loss" when I back-test, TOS has in their "strategies" tab, a single script I simply run alongside my "buy" script.
3...Create buy / sell chart arrows for the script when written as a TOS "Study" and not just a "Strategy".


###

def BuyCriteria =

TrueRange("high" = HIGH, "close" = hl2, "low" = LOW) is greater than ATR("length" = 10, "average type" = "Wilder"winking smiley and close is greater than hl2 and MoneyFlowIndex("length" = 111)."MoneyFlowIndex" is greater than MoneyFlowIndex("length" = 14)."MoneyFlowIndex" from 1 bars ago;

AddOrder(OrderType.BUY_AUTO, BuyCriteria, tickcolor = Color.YELLOW, arrowcolor = Color.GREEN, name = "Buy", tradeSize = 100);

###



Edited 2 time(s). Last edit at 06/05/2021 09:59PM by toncuz.
Sorry, only registered users may post in this forum.

Click here to login