martinflds
New member
Good Day,
This is my first post as well as "attempt" at scripting for TOS or any kind for that matter. Most of my coding is from looking at other peoples code and lines from the TOS code and trying to plug and play. For those of you whom know more than I, (probably all of you)would you be so kind as to take a look at this and give me some feedback. Additionally once all is good I can repost the completed code and the link so others can use.
What I am trying to do here is place a box on my chart that displays the average daily price movement of a stock over 30 (or X# )days. Additionally I would like another with the % of the current day's movement in compared to that 30 Day Avg. Ultimately I would like to be able to look as I am scanning stocks to determine if the daily average price movement would interest further investigation. Say I am looking at great gapping stock but it is 200% over the daily price movement I may want to note that but look for something that has a little more room on the daily average for profit, until I become a little more competent with trading.
Issues:
The box does show up with avg well as a % box before the market is open, however once in premarket/ open it will only work with some stocks. Additionally no % of the daily avg shows in the box.
I would like to make it adjustable by time frame. Below is set for 30 days specifically and in order to use a higher period of time I would needs to manually enter the days. Initially I tried "def avg= average (price, length/ length) ;" "(then using input length = 30;" however it came up with a wildly different number I believe higher by $3 on the QQQ's for todays date. With my basic lvl math equation writing in script (which is basically none) I couldn't figure it out.
This is my first post as well as "attempt" at scripting for TOS or any kind for that matter. Most of my coding is from looking at other peoples code and lines from the TOS code and trying to plug and play. For those of you whom know more than I, (probably all of you)would you be so kind as to take a look at this and give me some feedback. Additionally once all is good I can repost the completed code and the link so others can use.
What I am trying to do here is place a box on my chart that displays the average daily price movement of a stock over 30 (or X# )days. Additionally I would like another with the % of the current day's movement in compared to that 30 Day Avg. Ultimately I would like to be able to look as I am scanning stocks to determine if the daily average price movement would interest further investigation. Say I am looking at great gapping stock but it is 200% over the daily price movement I may want to note that but look for something that has a little more room on the daily average for profit, until I become a little more competent with trading.
Issues:
The box does show up with avg well as a % box before the market is open, however once in premarket/ open it will only work with some stocks. Additionally no % of the daily avg shows in the box.
I would like to make it adjustable by time frame. Below is set for 30 days specifically and in order to use a higher period of time I would needs to manually enter the days. Initially I tried "def avg= average (price, length/ length) ;" "(then using input length = 30;" however it came up with a wildly different number I believe higher by $3 on the QQQ's for todays date. With my basic lvl math equation writing in script (which is basically none) I couldn't figure it out.
Code:
# Name Daily_$_Movement_Indicator
# Version 1.0
# Created by: Joey
# Created: 04/26/20
#Inputs
input DayAvg = yes;
input PercentOfDay = yes;
#Price Data
def price = Open("day")-close("day");
def avg = (price[1] + price[2] + price[3] + price[4] + price[5] + price[6] + price[7] + price[8] + price[9] + price[10] + price[11] + price[12] + price[13] + price[14] + price[15] + price[16] + price[17] + price[18] + price[19] + price[20] + price[21] + price[22] + price[23] + price[24] + price[25] + price[26] + price[27] + price[28] + price[29] + price[30]) / 30;
def PercentOfDay = Round((price / avg) * 100);
# Labels
AddLabel(DayAvg, "Avg Price Mvt:" + round(avg, 2), Color.LIGHT_GRAY);
AddLabel(PercentOfDay, "% of Avg:" + ("%"), Color.YELLOW);
Long Post but Thanks!
Last edited by a moderator: