Offering to help with scripting

Status
Not open for further replies.
C

Coy Ponish

New member
To Robert Payne or anyone who can help:

I need help writing script that can look back on 60 or less 5 min. bars and put an arrow on the chart where the third time a bar low has stopped at the same price (bouncing off support) in an uptrend or look back on 60 or less 5 min. bars and put an arrow on the chart where the third time a bar high has stopped at the same price (bouncing off resistance() in a downtrend. Also there has to be at least one bar gap or more between the bars reaching the same price low or high. If you can help me with this it might be easier to look at my computer screen where I can show you many examples of what I am trying to do. Also, I am new to this website. I can write the script for the uptrend or downtrend. I just need help with the look back 60 or less bars.
 
Last edited by a moderator:
horserider

horserider

Well-known member
VIP
@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();
 
RobertPayne

RobertPayne

Member
Any particular reason that most of my posts have been deleted? Have I broken any rules?
 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@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.
 
B

Bradford

New member
If you are stuck on something, perhaps I can help you figure it out...

I have a Custom WatchList Column linked to a Scan that displays a 1.0 if true and a different color. I want to improve the Column with a Checklist or Grading of the Scan results.

I want to add code that displays the Sum of additional Conditions in the Column
If “Condition2" is true then count 1+1=2.0, else 1+0=1.0;
If “Condition3" is true then count +1, else +0;

So the column will display a 1.0 or 2.0 or 3.0.
Can you help with the count code please?
 
RobertPayne

RobertPayne

Member
If you are stuck on something, perhaps I can help you figure it out...

I have a Custom WatchList Column linked to a Scan that displays a 1.0 if true and a different color. I want to improve the Column with a Checklist or Grading of the Scan results.

I want to add code that displays the Sum of additional Conditions in the Column
If “Condition2" is true then count 1+1=2.0, else 1+0=1.0;
If “Condition3" is true then count +1, else +0;

So the column will display a 1.0 or 2.0 or 3.0.
Can you help with the count code please?
Just add up the conditions. Here's an example.

Ruby:
def ma8 = Average(close, 8);
def ma13 = Average(close, 13);
def ma21 = Average(close, 21);

def cond1 = close > ma8;
def cond2 = close > ma13;
def cond3 = close > ma21;

plot total = cond1 + cond2 + cond3;
total.AssignValueColor(if total == 1 then Color.WHITE else Color.BLACK);
AssignBackgroundColor(if total == 3 then Color.LIME else if total == 2 then Color.GREEN else if total == 1 then Color.DARK_GREEN else Color.BLACK);
 
markos

markos

Well-known member
VIP
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.

 
Last edited by a moderator:
RobertPayne

RobertPayne

Member
@markos

AddLabel() displays a STRING value. So, it will be sorted alphabetically.

Plot displays a numeric value and will be sorted numerically.
 
C

Coy Ponish

New member
@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();
 
B

Bradford

New member
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
 
C

Coy Ponish

New member
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.
 
horserider

horserider

Well-known member
VIP
@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.
 
C

Coy Ponish

New member
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.
 
C

Coy Ponish

New member
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.
 
RobertPayne

RobertPayne

Member
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.



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.



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.



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.
 
C

Coy Ponish

New 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.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
L Questions 3
J007RMC Questions 1
M Questions 0
Brain Monkey Questions 0
S Questions 3

Top