Offering to help with scripting

Status
Not open for further replies.
B

Bradford

New member
VIP
If you are stuck on something, perhaps I can help you figure it out.
I am stuck on a Watchlist Column that is 'looking forward'.
I want to run a scan End of Day and then place some of those tickers into a static watchlist.
The following 3 days i want the column to check for 3 stop-out conditions.
So the column will start with default 0, and end up with a 0, 1, 2, or 3.
Your previous examples were applied to solve almost everything .

But, how do i code the conditions:
def cond1 = is CCI < 0 on Day1 after scanX triggers, on Day2, on Day3
def cond2 =
def cond3 =
 
RobertPayne

RobertPayne

Member
I am stuck on a Watchlist Column that is 'looking forward'.
I want to run a scan End of Day and then place some of those tickers into a static watchlist.
The following 3 days i want the column to check for 3 stop-out conditions.
So the column will start with default 0, and end up with a 0, 1, 2, or 3.
Your previous examples were applied to solve almost everything .

But, how do i code the conditions:
def cond1 = is CCI < 0 on Day1 after scanX triggers, on Day2, on Day3
def cond2 =
def cond3 =
I'm not certain I understand, precisely, what you are going for but this approach may work.

def cond1 = CCI < 0;
def cond2 = cond1[1] and <whatever cond2 is>;
def cond3 = cond2[1] and <whatever cond3 is>;
plot watchlistValue = if cond3 then 3 else if cond2 then 2 else if cond1 then 1 else 0;
 
RobertPayne

RobertPayne

Member
Robert Payne. I need help writing some of the code for one of my systems. In an uptrend, which I can write with several moving averages, I want to look back from the current 5 min. bar to find 2 or more low points that match the low of the current bar but I don't want to look back more than 60 bars. In other words I am trying to get an arrow to pop up on the chart on the current bar if there are 2 previous times before that price has hit the same low point and bounced off support with at least a one bar gap or more between where the lows hit the same price. Of course that would be a buy signal. For a sell signal you would do the reverse by looking for high points in a downtrend. I think if you can write the code for the buy side I can look at your code and figure out how to write the code for the sell side. If you need more information or clarification let me know. Also if you are like me and don't like to type and would rather talk over the phone let me know and I will give you my cell number or if you have TeamViewer I can show you examples of what I am trying to do on my computer screen. Looking forward to hearing from you. Coy Ponish.
You will need to use a fold loop. More information on this function is available here: https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/fold.html

Here's an example.

Ruby:
input length = 60;
def countHighTouches = fold i = 0 to length with internalSum = 0 do if GetValue(high, i) == high then internalSum + 1 else internalSum;
plot arrowUp = counthightouches == 3;
arrowup.setpaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
arrowup.setdefaultColor(color.magenta);
arrowup.setlineWeight(3);
 
B

Bradford

New member
VIP
I'm not certain I understand, precisely, what you are going for but this approach may work.
Let me rephrase the question.
There are 3 different conditions that would give me concern the trade is no longer going my way.
I want each condition to produce a value of 0 or 1.
If none of the conditions are true then the trade is still good.
If 1 of them is true then the trade may be going against me.
If 2 are true then caution.
If 3 then stop out.

Here is where i am stuck.
Day 1 after trigger what is the sum
Day 2 after trigger what is the sum
Day 3 after trigger what is the sum

Example
Day 1 might total 1
Day 2 might return to 0

Example
Day 1 might total 3 - then stop out

Is your solution still accurate?
 
RobertPayne

RobertPayne

Member
Is your solution still accurate?
Try it and see. Experiment yourself. Play around to see what does and doesn't work. I gave you an example the other day of how to combine conditions and determine what the value is (1, 2, or 3). I am not going to do ALL the work for you.
 
C

Coy Ponish

New member
I just learned how to do a screenshot. As they say a picture is worth a thousand words. Maybe from this example someone can figure out how to get an arrow to pop up on the chart the third time a candlestick touches the same price level without the body going through the price level. I don't care if the candlestick wick goes through the price level as long as the body doesn't go through the price level. Ruby, thanks for your input. I went and read the information about the fold loop but it was beyond my understanding. However it looked like it might be the answer but not sure. If no one is able to help me with this maybe someone could tell me the phone number of a progammer I could call and pay to program this for me.

Well shoot (shoot isn't exactly the word I was thinking of). I couldn't paste the screenshot into this spot. I asked the guy at ThinkorSwim if I could paste the screenshot in another website and he said yes. Back to the drawing board.
 
A

ansheth

New member
2019 Donor
Hello,I am looking for some thinkscript help. I'm back testing the Chaikin recommendations, trying to determine whether I renew in December. To accomplish this, I'm having to pull a bunch of historic data from TOS. If I set a value in a Custom field to represent the days offset, is there a way to use that value in the custom values that look for Price, trend, Chaikin MF, RSI etc? Thank you so much.
 
D

dallzy

New member
VIP
Hey folks, I have a study and based on that study I would like to autotrade options positions.. yes I know I can blow my whole account if it makes a mistake... but I would start with only 100$ anyone know who can help with the auto trade options code?
 
S

skynetgen

Well-known member
I wonder if it is possible to profile thinkscripts. I found following entries in client.log

18.11.19 23:58:44:589 DEBUG util.Histograms - Profiler - Operation.TOTAL - Script: VolumeProfile (ms): 80,220 / 258316 = 0.31 in (0 [0-0-1] 265)
18.11.19 23:58:44:589 DEBUG util.Histograms - Profiler - Operation.TOTAL - Script: VolumeProfile (ns): 80,380,419,000 / 258316 = 311,171 in (1,643 [4,253-8,014-397,704] 266,606,258)
18.11.19 23:58:44:589 DEBUG util.Histograms - Profiler - Operation.TOTAL - Script: _008b0148_37cb_4eb9_ba28_c0347e47cde2 (ms): 135 / 6403 = 0.02 in (0 [0-0-0] 2)
18.11.19 23:58:44:589 DEBUG util.Histograms - Profiler - Operation.TOTAL - Script: _008b0148_37cb_4eb9_ba28_c0347e47cde2 (ns): 171,946,100 / 6

That GUID is likely one of my custom scripts. Is there a way to tell which one it is?
 
U

urvishu

New member
I would like to contribute to this forum by offering to answer questions for those of you who are coding your own indicators. If you are stuck on something, perhaps I can help you figure it out.
Hi Robert, I will really appreciate if you can please fix this small script for me. I am trying to put an Arrow when price or candle closes above the TEMA for the first time. With this script it is ploting arrows for each candle. Also, similar for down-cross as well. Here's what I did based on my little understanding:

Code:
input price = close;
input length = 10;

def ema1 = ExpAverage(price, length);
def ema2 = ExpAverage(ema1, length);
def ema3 = ExpAverage(ema2, length);

plot TEMA = 3 * ema1 - 3 * ema2 + ema3;
TEMA.SetDefaultColor(GetColor(0));

def Condition1 = if
close > TEMA
then 1 else Double.NaN;
plot x = Condition1;
x.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_UP);
 
BenTen

BenTen

Administrative
Staff
VIP
@urvishu See if this is what you're looking for.

Code:
input price = close;
input length = 10;

def ema1 = ExpAverage(price, length);
def ema2 = ExpAverage(ema1, length);
def ema3 = ExpAverage(ema2, length);

plot TEMA = 3 * ema1 - 3 * ema2 + ema3;
TEMA.SetDefaultColor(GetColor(0));

def Condition1 = close crosses above TEMA;
plot x = Condition1;
x.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_UP);
 
T

tomsk

Well-known member
VIP
You will need to use a fold loop. More information on this function is available here: https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/fold.html

Here's an example.

Ruby:
input length = 60;
def countHighTouches = fold i = 0 to length with internalSum = 0 do if GetValue(high, i) == high then internalSum + 1 else internalSum;
plot arrowUp = counthightouches == 3;
arrowup.setpaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
arrowup.setdefaultColor(color.magenta);
arrowup.setlineWeight(3);
@RobertPayne I looked at your little snippet above, shouldn't we look at GetValue(high, -i) rather than GetValue(high, i) ?
Notice the minus sign in front of the variable "i"? I'm pretty sure that would be the case but thought I'd run this by you to confirm.

Here is the revised script if so

Code:
input length = 60;
def countHighTouches = fold i = 0 to length with internalSum = 0 do if GetValue(high, -i) == high then internalSum + 1 else internalSum;
plot arrowUp = counthightouches == 3;
arrowup.setpaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
arrowup.setdefaultColor(color.magenta);
arrowup.setlineWeight(3);
 
BenTen

BenTen

Administrative
Staff
VIP
Due to the inactivity of @RobertPayne, I have decided to lock this thread. Thank you, Robert, for your contribution. All unanswered queries will be moved to their own dedicated thread. If anyone else has any other questions, please create a new post in the Questions forum. Our community members, including Robert, will chime in to help whenever possible. :)
 
Status
Not open for further replies.
Top