Robert Payne offering to help with ThinkScript

Status
Not open for further replies.

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

@RobertPayne Yes they were broken out to different threads to make it easier for members to search for them. I thought the system would have notified you.
 
Hey Robert, I posted a trial of 5 Rel Strength columns at the link below, post #34.
Simply, what can I do to make the columns in the 2 pics below list numbers in their proper order?
The above/below 200 Day SMA column is both + & - . The other is 0 to 100 Range.
https://usethinkscript.com/threads/ibd-style-chart-and-scan.532/page-2
CBEnpii.png
 
Last edited by a moderator:
@Coy Ponish Here is a line of high and low of past 60 bars. Maybe someone else will tackle the rest.

Code:
# Line At Price
plot priceLine = highestAll(if isNaN(close[-60])
                            then close
                            else Double.NaN);
priceline.SetStyle(Curve.Long_Dash);
priceLine.SetLineWeight(2);
priceLine.SetDefaultColor(CreateColor(255,215,0));
priceline.HideTitle();

plot pricelinel = lowestall(if isNaN(close[-60])
                            then close
                            else Double.NaN);
pricelinel.SetStyle(Curve.Long_Dash);
priceLine.SetLineWeight(2);
priceLine.SetDefaultColor(CreateColor(255,215,0));
priceline.HideTitle();
 
When the CCI crosses below the zero line it can trigger a Down Signal.
I am struggling with the differences between these two conditions:
1. the CCI was above the zero line on the 5th bar before the Down Signal
2. the CCI was above the zero line for all 5 bars before the Down Signal
 
horserider, Thanks for trying to help me. You obviously know more about writing script than I do. I didn't know what some of the script you wrote for me meant but I put it into my program and it put arrows on the chart but not exactly where I wanted them. Some of them were exactly where I wanted them so I think you are close and can probably write the script I need. I probably didn't explain it good enough. I was wondering if the name horserider meant you were from Texas like me. I would like to know if you have the free program called TeamViewer which allows you to look at my screen. I could show you in a minute or two examples of what I am trying to do and you could either say yes I can do it or no I can't and that would be the end of it. I put my phone number on a message before but it seems to have been erased. I am new to this site and may not know all the rules of using this site but I am going to try one more time. cell : (361)442-9055. If you still want to help call me and we can arrange a time for you to look at my screen and decide if you can write the script I need. I am retired so I am available from 7:30am to Midnight when I bring in the dogs for the night. Just ask for Coy. If my cell number gets erased again I will assume it is not permitted and will quit doing it.
 
@Coy Ponish Howdy fellow Texan. That script is very simple. It draws a line at the highest and lowest point of the past 60 bars. As the bars move forward in time it will keep selecting those highest and lowest points. Plots dashed lines, I do not know how you got arrows.
I do not believe I can code what you want.

However you can use the dashed lines and watch for the 3 bounces off the lines.

Give your dogs a scratch on the head for me.
 
horserider I had a hard time getting the dogs to go outside to eat. It is raining lightly here in Corpus Christi. Thanks for explaining those 2 horizontal lines. I was wondering what they were for. I am going back to the chart to take another look now that I understand how those lines work. Thanks again.
 
horserider I think the arrows that come up on the chart are caused by some of the script I wrote combined with the script you wrote. After reading your explanation of how your script works I went back to the chart and changed to -60 to -30 to see if it would look back 30 bars which it did. Then I switched it back to -60. Thanks for the help.
 
When the CCI crosses below the zero line it can trigger a Down Signal.
I am struggling with the differences between these two conditions:
1. the CCI was above the zero line on the 5th bar before the Down Signal
2. the CCI was above the zero line for all 5 bars before the Down Signal

Ok. Let's break this down.

Condition 1 Example

We will define condition 1 as CCI just crossed below zero AND it was above zero 5 bars ago.

Ruby:
def cond1 = CCI crosses below 0 and CCI[5] > 0;

The first half of the condition (before the and) is straight forward---CCI just crossed below 0.

The second half references the CCI value 5 bars ago CCI[5] and checks if that bar, and that bar only, was above 0. CCI[3] would look at the CCI value 3 bars ago.

vWdToOL.png


Condition 1 is TRUE above because CCI just crossed below 0 and, if you count back 5 bars, CCI was above 0 at that time. It makes no difference what happened between that bar and now.

Condition 2 Example

We will define condition 2 as CCI just crossed below 0 and CCI has been above 0 for the past 5 bars.

Ruby:
def isAboveZero = cci > 0;
def cond2 = cci crosses below zero and sum(isAboveZero[1], 5) == 5;

def isAboveZero = cci > 0; is a boolean condition---it can either be TRUE or FALSE. CCI is either above zero (true) or it isn't (false). A true condition has a value of 1 and a false condition has a value of 0.

So, if we want to know whether or not CCI has been above zero for the past 5 bars, we can use the sum() function to add up the last 5 isAboveZero boolean values. If that value is equal to 5 then we know that all 5 were above zero.

NPAoTfY.png


In the above example sum(isAboveZero[1], 5) would be 1 + 1 + 1 + 1 + 1 = 5 and CCI just crossed below zero. So, condition 2 is true.

2Nmb8zx.png


In the above example sum(isAboveZero[1], 5) would be 0 + 0 + 1 + 1 + 1 = 3 and CCI just crossed below zero. So, condition 2 is false.
 

Attachments

  • vWdToOL.png
    vWdToOL.png
    1.3 KB · Views: 87
  • NPAoTfY.png
    NPAoTfY.png
    1.4 KB · Views: 99
  • 2Nmb8zx.png
    2Nmb8zx.png
    1.4 KB · Views: 105
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.
 
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 =
 
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;
 
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?
 
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.
 
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.
 
Status
Not open for further replies.

BenTen's Watchlist + Setup + Trade Recaps

Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.

Learn more

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
518 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top