Support & Resistance Values (Constants)


Category:
0
0

Hey guys!

 

I am having trouble developing a script. I want it to plot some basic price levels for the stock I am looking at.

Let’s say the stock is at 200. I would want it to plot a price level at two levels (by 10’s) both up and down. However, the price levels have to be rounded marks.  Here are a couple of examples:

If a stock is at 200:

Plot a line at 210, 220, 190, 180

 

If a stock is at 201:

Plot a line at 210, 220, 200, 190

 

If a stock is at 206:

Plot a line at 210, 220, 200, 190

 

Thank you!! 🙂

 

Marked as spam
Posted by (Questions: 8, Answers: 5)
Asked on February 10, 2020 5:03 pm
162 views
0
Private answer

The solution is pretty simple to implement. However there needs to be a very clear pattern to how you want these levels to adapt to the current price. I looked at the three examples you gave and I don't see a pattern that can be incorporated into a solution.

So you need an algorithm. This algorithm needs to cover the full range of values in the stock market. It should include a set of rules that enable it to adapt to prices ranging from 1 dollar up to 1 thousand dollars. For example. Take current price and determine how many digits are on the left side of the decimal point. Then round that value to the nearest full increment. Which implies you need a list of increments. A value of 225 might round up to 230. Just depends on the granularity you want here. Then from that base number you then increment by 1's, 5's, 10's, 25's or 100's. Depending on how many digits to the left of the decimal.

The algorithm to do this is the most difficult part. But until you have a complete algorithm we can't even write a single line of code.

Or you can create a very simple study with user adjustable inputs for each value you want to plot:

input levelOne = 180;
input levelTwo = 190;
input levelThree = 200;
input levelFour = 210;
plot dataOne = levelOne;
plot dataTwo = levelTwo;
plot dataThree = levelThree;
plot dataFour = levelFour;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 10, 2020 6:09 pm