Mr_Wheeler
Active member
It has the VWAP line and 4 Std. Deviations lines that you configure in the study config menu.
I configured the lines's & label's colors to be organized by maching the order the colors are displayed with both the lines as well as the labels so you can quickly find each other. Red line, orange line, Purple line, orange line, red line - Red Labels, Orange labels, purple labels, orange labels, red labels.
You enter a budget in the study config and it spits out how much you'll lose at each of the lines. If you're wondering, yes, it does have stop-lost labels, but I disabled them for myself. If you want them then just toggle them in the config.
http://tos.mx/p6fWQhz
I configured the lines's & label's colors to be organized by maching the order the colors are displayed with both the lines as well as the labels so you can quickly find each other. Red line, orange line, Purple line, orange line, red line - Red Labels, Orange labels, purple labels, orange labels, red labels.
You enter a budget in the study config and it spits out how much you'll lose at each of the lines. If you're wondering, yes, it does have stop-lost labels, but I disabled them for myself. If you want them then just toggle them in the config.
http://tos.mx/p6fWQhz
Code:
input Budget = 2000;
def current_price = close;
def Share_Quantity_purchase_limit = Budget / current_price;
########### Moving Average Lines ###########
input price = close;
input fastLength = 9;
input medLength = 50;
input slowLength = 200;
input displace = 0;
input averageType = AverageType.WILDERS;
plot fastAvg = MovingAverage(averageType, price[-displace], fastLength);
plot medAvg = MovingAverage(averageType, price[-displace], medLength);
plot slowAvg = MovingAverage(averageType, price[-displace], slowLength);
fastAvg.SetDefaultColor(CreateColor(51, 204, 255));
medAvg.SetDefaultColor(CreateColor(255, 95, 95));
slowAvg.SetDefaultColor(Color.WHITE);
fastAvg.SetLineWeight(2);
medAvg.SetLineWeight(2);
slowAvg.SetLineWeight(2);
fastAvg.SetPaintingStrategy(PaintingStrategy.DASHES);
medAvg.SetPaintingStrategy(PaintingStrategy.DASHES);
slowAvg.SetPaintingStrategy(PaintingStrategy.DASHES);
#####################################################
# Follow Line Indicator
# Coverted to ToS from TV by bigboss. Original © Dreadblitz
#https://usethinkscript.com/threads/follow-line-indicator.9789/
input BbPeriod = 9;
input BbDeviations = 1;
input UseAtrFilter = yes;
input AtrPeriod = 5;
input HideArrows = no;
def BBUpper = SimpleMovingAvg(close, BbPeriod) + StDev(close, BbPeriod) * BbDeviations;
def BBLower = SimpleMovingAvg(close, BbPeriod) - StDev(close, BbPeriod) * BbDeviations;
def BBSignal = if close > BBUpper then 1 else if close < BBLower then -1 else 0;
def TrendLine =
if BBSignal == 1 and UseAtrFilter == 1 then
Max(low - ATR(AtrPeriod), TrendLine[1])
else if BBSignal == -1 and UseAtrFilter == 1 then
Min(high + ATR(AtrPeriod), TrendLine[1])
else if BBSignal == 0 and UseAtrFilter == 1 then
TrendLine[1]
else if BBSignal == 1 and UseAtrFilter == 0 then
Max(low, TrendLine[1])
else if BBSignal == -1 and UseAtrFilter == 0 then
Min(high, TrendLine[1])
else if BBSignal == 0 and UseAtrFilter == 0 then
TrendLine[1]
else TrendLine[1];
def iTrend = if TrendLine > TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1];
plot buy_price = if iTrend[1] == -1 and iTrend == 1 and !HideArrows then TrendLine else Double.NaN;
buy_price.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
buy_price.SetDefaultColor(Color.GREEN);
buy_price.SetLineWeight(3);
plot buy_arrow = if iTrend[1] == -1 and iTrend == 1 and !HideArrows then TrendLine else Double.NaN;
buy_arrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buy_arrow.SetDefaultColor(Color.GREEN);
buy_arrow.SetLineWeight(5);
plot sell_arrow = if iTrend[1] == 1 and iTrend == -1 and !HideArrows then TrendLine else Double.NaN;
sell_arrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sell_arrow.SetDefaultColor(Color.RED);
sell_arrow.SetLineWeight(5);
plot sell_price = if iTrend[1] == 1 and iTrend == -1 and !HideArrows then TrendLine else Double.NaN;
sell_price.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
sell_price.SetDefaultColor(Color.WHITE);
sell_price.SetLineWeight(3);
########
def arrow_purchase_price = Budget / iTrend ;
######### Label control
input current_number_of_shares_that_you_can_purchase_at_the_current_price = Yes;
input current_number_of_shares_that_you_can_purchase_at_the_buy_arrow_price = Yes;
input buy_arrow_price = Yes;
input profit_if_you_bought_at_the_buy_arrow_with_your_budget = Yes;
input stock_price_of_the_fast_moving_average_line = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_the_fast_moving_Avg_price = Yes;
input stock_price_of_the_Medium_moving_average_line = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_the_Med_moving_Avg_price = Yes;
input stock_price_of_the_slow_moving_average_line = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_the_slow_moving_Avg_price = Yes;
#input remaining_percentage_until_the_fast_and_Medium_moving_average_lines_cross_over =yes;
##########
def greenBuy = if iTrend[1] == -1 and iTrend == 1 and !HideArrows then TrendLine else greenBuy[1];
AddLabel(current_number_of_shares_that_you_can_purchase_at_the_current_price, Concat("current price shares = ", Round(Share_Quantity_purchase_limit)), Color.ORANGE);
AddLabel(current_number_of_shares_that_you_can_purchase_at_the_buy_arrow_price, Concat("Buy arrow shares = ", Round(arrow_purchase_price / greenBuy, 0)), Color.GREEN);
AddLabel(buy_arrow_price, Concat("Buy arrow price = ", Round (greenBuy)), Color.GREEN);
AddLabel(profit_if_you_bought_at_the_buy_arrow_with_your_budget, Concat("Profit @ GreenArw = ", Round (Budget / greenBuy * current_price - Budget)), Color.GREEN);
AddLabel(stock_price_of_the_fast_moving_average_line, Concat("MovAvg = ", Round(fastAvg)), (CreateColor(51, 204, 255)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_the_fast_moving_Avg_price, Concat("Profit @ fastAvg = ", Round(Budget / greenBuy * fastAvg - Budget)), (CreateColor(51, 204, 255)));
AddLabel(stock_price_of_the_Medium_moving_average_line, Concat("MovAvg = ", Round(medAvg)), (CreateColor(255, 95, 95)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_the_Med_moving_Avg_price, Concat("Profit @ medAvg = ", Round( Budget / greenBuy * medAvg - Budget)), (CreateColor(255, 95, 95)));
AddLabel(stock_price_of_the_slow_moving_average_line, Concat("MovAvg = ", Round (slowAvg)), Color.WHITE);
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_the_slow_moving_Avg_price, Concat("Profit @ slowAvg = ", Round (Budget / greenBuy * slowAvg - Budget)), Color.WHITE);
##########################################################################################################################################################
##########################################################################################################################################################
##########################################################################################################################################################
##########################################################################################################################################################
##########################################################################################################################################################
#Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP
#Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWAP #Four Line VWA #Four Line VWAP #Four Line VWAP #Four Line VWAPP
##################################################
#SPACER LABEL
# spacer
input Spacer = yes;
addlabel(Spacer, " ",(CreateColor(8,65,93))); # my custom color for my setup.
# end spacer code
##################################################
input Highest_Upper_Band_dev = 2.0;
input Low_Upper_Band_dev = 1.0;
input High_Low_Band_dev = -1.0;
input Lowest_Low_Band_dev = -2.0;
input timeFrame = {default DAY, WEEK, MONTH};
def cap = GetAggregationPeriod();
def errorInAggregation =
timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = GetYYYYMMDD();
def periodIndx;
switch (timeFrame) {
case DAY:
periodIndx = yyyyMmDd;
case WEEK:
periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);
case MONTH:
periodIndx = RoundDown(yyyyMmDd / 100, 0);
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;
if (isPeriodRolled) {
volumeSum = volume;
volumeVwapSum = volume * vwap;
volumeVwap2Sum = volume * Sqr(vwap);
} else {
volumeSum = CompoundValue(1, volumeSum[1] + volume, volume);
volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
volumeVwap2Sum = CompoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def Vwap_price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(Vwap_price), 0));
plot VWAP = Vwap_price;
plot Highest_Upper_Band = Vwap_price + Highest_Upper_Band_dev * deviation;
plot Low_Upper_Band = Vwap_price + Low_Upper_Band_dev * deviation;
plot High_Low_Band = Vwap_price + High_Low_Band_dev * deviation;
plot Lowest_Low_Band = Vwap_price + Lowest_Low_Band_dev * deviation;
AddCloud(Highest_Upper_Band, Low_Upper_Band, Color.white, Color.white);
AddCloud(High_Low_Band, Lowest_Low_Band, Color.white, Color.white);
VWAP.SetDefaultColor(CreateColor(153, 153, 255));
VWAP.SetLineWeight(3);
Highest_Upper_Band.SetDefaultColor(CreateColor(255, 95, 95));
Highest_Upper_Band.SetLineWeight(3);
Low_Upper_Band.SetDefaultColor(GetColor(4));
Low_Upper_Band.SetLineWeight(3);
High_Low_Band.SetDefaultColor(GetColor(4));
High_Low_Band.SetLineWeight(3);
Lowest_Low_Band.SetDefaultColor(CreateColor(255, 95, 95));
Lowest_Low_Band.SetLineWeight(3);
#############################4_band Vwap Control -- inputs#############################
#Disable Upper band cloud
#disable low band cloud
input Current_Upper_Highest_band_price = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_highest_upper_band = yes;
input Profit_if_you_bought_at_current_price_and_sold_at_highest_upper_band = yes;
input Current_Low_upper_band_price = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_Lower_upper_band = yes;
input Profit_if_you_bought_at_current_price_and_sold_at_lower_upper_band = yes;
input current_Vwap_price = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_VWAP = yes;
input Profit_if_you_bought_at_current_price_and_sold_at_VWAP = yes;
input current_high_Lower_band_price = yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_high_lower_band = yes;
input Profit_if_you_bought_at_current_price_and_sold_at_high_lower_band = yes;
input current_Lowest_band_price = yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_lowest_band = yes;
input Profit_if_you_bought_at_current_price_and_sold_at_lowest_band = yes;
#################################################### Label code.#############################################################
### ### ### highest Upper band ### ### ###
AddLabel(Current_Upper_Highest_band_price, Concat(" highest Upper Band price = ", Round (Highest_Upper_Band)),(CreateColor(255, 95, 95)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_highest_upper_band, Concat("buy Arrow shares Profit @ highest Upper Band = ", Round( Budget / greenBuy *Highest_Upper_Band - Budget)), (CreateColor(255, 95, 95)));
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_highest_upper_band, Concat("Current price shares profit @ Highest Upper Band = ", Round( Share_Quantity_purchase_limit * Highest_Upper_Band - Budget )), (CreateColor(255, 95, 95)));
### ### ### highest Upper band ### ### ###
### ### ### Lower Upper band ### ### ###
AddLabel(Current_Low_upper_band_price, Concat(" Low upper band price = ", Round (Low_Upper_Band)), Color.orange);
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_Lower_upper_band, Concat("buy Arrow shares Profit @ low Upper Band = ", Round( Budget / greenBuy * Low_Upper_Band - Budget)), Color.orange);
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_lower_upper_band, Concat("Current price shares profit @ low Upper Band = ", Round( Share_Quantity_purchase_limit *Low_Upper_Band - Budget )), Color.orange);
### ### ### Lower Upper band ### ### ###
### ### ### VWAP ### ### ###
AddLabel(current_Vwap_price, Concat(" Vwap price = ", Round (VWAP)), Color.viOLET);
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_VWAP, Concat("buy Arrow shares Profit @ Vwap = ", Round( Budget / greenBuy * vwap - Budget)), Color.viOLET);
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_high_lower_band, Concat("Current price shares profit @ Vwap = ", Round( Share_Quantity_purchase_limit * vwap - Budget )), Color.viOLET);
### ### ### VWAP ### ### ###
### ### ### high lower band ### ### ###
AddLabel(current_high_Lower_band_price, Concat(" high low band price = ", Round (High_Low_Band)), Color.orange);
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_high_lower_band, Concat("buy Arrow shares Profit @ high lower band = ", Round( Budget / greenBuy * High_Low_Band - Budget)), Color.orange);
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_VWAP, Concat("Current price shares profit @ high lower band = ", Round( Share_Quantity_purchase_limit * High_Low_Band - Budget )), Color.orange);
### ### ### high lower band ### ### ###
### ### ### Lowest lower band ### ### ###
AddLabel(current_Lowest_band_price, Concat(" Lowest band price = ", Round (Lowest_Low_Band)),(CreateColor(255, 95, 95)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_lowest_band, Concat("buy Arrow shares Profit @ lowest band = ", Round( Budget / greenBuy * Lowest_Low_Band - Budget)),(CreateColor(255, 95, 95)));
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_lowest_band, Concat("Current price shares profit @ lowest band = ", Round( Share_Quantity_purchase_limit * Lowest_Low_Band - Budget )),(CreateColor(255, 95, 95)));
### ### ### Lowest lower band ### ### ###
##########################################################################################################################################################
##########################################################################################################################################################
##########################################################################################################################################################
# spacer
input Spacer2 = yes;
addlabel(Spacer2, " ",(CreateColor(8,65,93))); # my custom color for my setup.
# end spacer code
##########################################################################################################################################################
##########################################################################################################################################################
##########################################################################################################################################################
input Stop_loss_dollar_amount = 250;
input profit_target = 50.0;
input Stop_Loss_targeted_max_loss = yes;
input Stop_Loss_share_price_target = yes;
input The_Current_stock_price_Stop_Loss_share_price_target = yes;
input profit_goal = yes;
input Required_Price_Change_for_profit = yes;
input Stock_Price_Profit_goal_share_price = yes;
AddLabel(Stop_Loss_targeted_max_loss, Concat("Stop Loss targeted max loss = ", Round( Stop_loss_dollar_amount)),Color.white);
AddLabel(Stop_Loss_share_price_target, Concat("Stop Loss share price target = ", Round( Stop_loss_dollar_amount / Share_Quantity_purchase_limit )),Color.white);
AddLabel(The_Current_stock_price_Stop_Loss_share_price_target, Concat("The Current stock price minus the Stop Loss share price target share = ", Round( current_price - (Stop_loss_dollar_amount / Share_Quantity_purchase_limit) )),Color.white);
AddLabel(profit_goal, Concat("profit goal = ", Round( profit_target )), Color.green);
AddLabel(Required_Price_Change_for_profit, Concat("Required Price Change for profit = ", Round( profit_target / Share_Quantity_purchase_limit )), Color.green);
AddLabel(Stock_Price_Profit_goal_share_price , Concat("Stock Price + Profit goal share price = ", Round( profit_target / Share_Quantity_purchase_limit + current_price )), Color.green);
plot stop_loss_line = current_price - (Stop_loss_dollar_amount / Share_Quantity_purchase_limit);
plot profit_target_line = profit_target / Share_Quantity_purchase_limit + current_price;
##########################################################################################################################################################
##########################################################################################################################################################
##########################################################################################################################################################
#Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts
#Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts #Alerts
#def fastAvg_Alert = MovingAverage(averageType, price[-displace], fastLength) crosses MovingAverage(averageType, price[-displace], medLength);
#Alert(fastAvg_Alert, "~~~~~fastAvg / medAvg cross over~~~~~", Alert.BAR, Sound.Chimes);
Last edited: