Is A Trade Worth It In ThinkOrSwim

Mr_Wheeler

Active member
a7bLeFj.png


The Green and Red Arrow are a Bollinger Bands cross-over indicator. If you want a setup that mimics video games, more specifically games such as RPGs then this is the setup for you.

The chart.

https://tos.mx/UE3dVgb

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 = no;
input  current_number_of_shares_that_you_can_purchase_at_the_buy_arrow_price = no;
input  buy_arrow_price = no;
input profit_if_you_bought_at_the_buy_arrow_with_your_budget = no;
input stock_price_of_the_fast_moving_average_line = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_the_fast_moving_Avg_price = no;
input stock_price_of_the_Medium_moving_average_line = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_the_Med_moving_Avg_price = no;
input stock_price_of_the_slow_moving_average_line = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_the_slow_moving_Avg_price = no;
 

##########

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);

##########################################################################################################################################################
##########################################################################################################################################################

#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 Med_Upper_Band_dev = 1.5;
input Low_Upper_Band_dev = 1.0;

input High_Low_Band_dev = -1.0;
input Med_Low_Band_dev = -1.5;
input Lowest_Low_Band_dev = -2.0;

input timeFrame = {default Month, WEEK, day};

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 Med_Upper_Band = Vwap_price +  Med_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 Med_low_Band =  Vwap_price + Med_Low_Band_dev * deviation;
plot Lowest_Low_Band =  Vwap_price + Lowest_Low_Band_dev * deviation;


############Clouds####################
############Clouds####################
############Clouds####################


AddCloud(Highest_Upper_Band, Low_Upper_Band,  CreateColor(255, 255, 255));
AddCloud(High_Low_Band, Lowest_Low_Band,(CreateColor(255, 255, 255)));


############Clouds####################
############Clouds####################
############Clouds####################

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);

Med_Upper_Band.SetDefaultColor(CreateColor(255, 255, 255));
Med_Upper_Band.SetLineWeight(3);

High_Low_Band.SetDefaultColor(GetColor(4));
High_Low_Band.SetLineWeight(3);

Med_low_Band.SetDefaultColor(CreateColor(255, 255, 255));
Med_low_Band.SetLineWeight(3);

Lowest_Low_Band.SetDefaultColor(CreateColor(255, 95, 95));
Lowest_Low_Band.SetLineWeight(3);

#############################4_band Vwap Control -- inputs#############################


input Current_Upper_Highest_band_price = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_highest_upper_band = no;
input Profit_if_you_bought_at_current_price_and_sold_at_highest_upper_band = no;

input Current_Upper_Medium_band_price = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_upper_band = no;
input Profit_if_you_bought_at_current_price_and_sold_at_medium_upper_band = no;


input Current_Low_upper_band_price = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_Lower_upper_band = no;
input Profit_if_you_bought_at_current_price_and_sold_at_lower_upper_band = no;

input current_Vwap_price = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_VWAP = no;
input Profit_if_you_bought_at_current_price_and_sold_at_VWAP = no;

input current_high_Lower_band_price = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_high_lower_band = no;
input Profit_if_you_bought_at_current_price_and_sold_at_high_lower_band = no;

input Current_lower_Medium_band_price = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_lower_band = no;
input Profit_if_you_bought_at_current_price_and_sold_at_medium_lower_band = no;

input current_Lowest_band_price = no;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_lowest_band = no;
input Profit_if_you_bought_at_current_price_and_sold_at_lowest_band = no;

#################################################### 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 ### ### ###

### ### ### Medium Upper band ### ### ###
AddLabel(Current_Upper_Medium_band_price, Concat(" Medium Upper Band price = ",  Round (med_Upper_Band)),(CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_upper_band, Concat("buy Arrow shares Profit @ Medium Upper Band = ", Round( Budget / greenBuy  * Med_Upper_Band - Budget)), (CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_medium_upper_band, Concat("Current price shares profit @ Medium Upper Band = ", Round( Share_Quantity_purchase_limit  *  Med_Upper_Band - Budget )), (CreateColor(255, 255, 255)));
### ### ### Medium Upper band ### ### ###

### ### ### Lowest 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);
### ### ### Lowest 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 ### ### ###

### ### ### Medium lower band ### ### ###
AddLabel(Current_lower_Medium_band_price, Concat(" Medium lower Band price = ",  Round (Med_low_Band)),(CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_lower_band, Concat("buy Arrow shares Profit @ Medium lower Band = ", Round( Budget / greenBuy  * Med_low_Band - Budget)), (CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_medium_lower_band, Concat("Current price shares profit @ Medium lower Band = ", Round( Share_Quantity_purchase_limit  *  Med_low_Band - Budget )), (CreateColor(255, 255, 255)));
### ### ### Medium 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 = no;
input Stop_Loss_share_price_target = no;
input The_Current_stock_price_Stop_Loss_share_price_target = no;
input profit_goal = no;
input Required_Price_Change_for_profit =no;
input Stock_Price_Profit_goal_share_price = no;

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;



The Notification side.

https://tos.mx/RlF4mwi

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);

# spacer
input Spacer1 = yes;

addlabel(Spacer1, "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ",(CreateColor(8,65,93))); # my custom color for my setup.

# end spacer code

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);


# spacer
input Spacer2 = yes;

addlabel(Spacer2, "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ",(CreateColor(8,65,93))); # my custom color for my setup.

# end spacer code



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 Spacer3 = yes;

addlabel(Spacer3, "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ",(CreateColor(8,65,93))); # my custom color for my setup.

# end spacer code

##################################################

input Highest_Upper_Band_dev = 2.0;
input Med_Upper_Band_dev = 1.5;
input Low_Upper_Band_dev = 1.0;

input High_Low_Band_dev = -1.0;
input Med_Low_Band_dev = -1.5;
input Lowest_Low_Band_dev = -2.0;

input timeFrame = {default Month, WEEK, day};

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 Med_Upper_Band = Vwap_price +  Med_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 Med_low_Band =  Vwap_price + Med_Low_Band_dev * deviation;
plot Lowest_Low_Band =  Vwap_price + Lowest_Low_Band_dev * deviation;


############Clouds####################
############Clouds####################
############Clouds####################



AddCloud(Highest_Upper_Band, Low_Upper_Band,  CreateColor(8,65,93));
AddCloud(High_Low_Band, Lowest_Low_Band,(CreateColor(8,65,93)));


############Clouds####################
############Clouds####################
############Clouds####################

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);

Med_Upper_Band.SetDefaultColor(CreateColor(255, 255, 255));
Med_Upper_Band.SetLineWeight(3);

High_Low_Band.SetDefaultColor(GetColor(4));
High_Low_Band.SetLineWeight(3);

Med_low_Band.SetDefaultColor(CreateColor(255, 255, 255));
Med_low_Band.SetLineWeight(3);

Lowest_Low_Band.SetDefaultColor(CreateColor(255, 95, 95));
Lowest_Low_Band.SetLineWeight(3);

#############################4_band Vwap Control -- inputs#############################

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_Upper_Medium_band_price = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_upper_band = yes;
input Profit_if_you_bought_at_current_price_and_sold_at_medium_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_lower_Medium_band_price = Yes;
input Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_lower_band = yes;
input Profit_if_you_bought_at_current_price_and_sold_at_medium_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 ### ### ###

### ### ### Medium Upper band ### ### ###
AddLabel(Current_Upper_Medium_band_price, Concat(" Medium Upper Band price = ",  Round (med_Upper_Band)),(CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_upper_band, Concat("buy Arrow shares Profit @ Medium Upper Band = ", Round( Budget / greenBuy  * Med_Upper_Band - Budget)), (CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_medium_upper_band, Concat("Current price shares profit @ Medium Upper Band = ", Round( Share_Quantity_purchase_limit  *  Med_Upper_Band - Budget )), (CreateColor(255, 255, 255)));
### ### ### Medium Upper band ### ### ###

### ### ### Lowest 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);
### ### ### Lowest 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 ### ### ###

### ### ### Medium lower band ### ### ###
AddLabel(Current_lower_Medium_band_price, Concat(" Medium lower Band price = ",  Round (Med_low_Band)),(CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_buy_arrow_and_sold_at_medium_lower_band, Concat("buy Arrow shares Profit @ Medium lower Band = ", Round( Budget / greenBuy  * Med_low_Band - Budget)), (CreateColor(255, 255, 255)));
AddLabel(Profit_if_you_bought_at_current_price_and_sold_at_medium_lower_band, Concat("Current price shares profit @ Medium lower Band = ", Round( Share_Quantity_purchase_limit  *  Med_low_Band - Budget )), (CreateColor(255, 255, 255)));
### ### ### Medium 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 Spacer4 = yes;

addlabel(Spacer4, "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ",(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;
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
315 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