Gabrielx77
Active member
Here's a label that everyone can add if they quickly want to see how many shares they can buy with a certain amount of money instead of having to use the calculator; this is for the amount of shares at the 5 min. high +$0.01. You can change your balance amount, the time frame of how long the label adjusts and the time frames of the candles by switching the number AND word 5 to 1, 10, 15, whatever you want.
Code:
# shares_5min
# calculate shares to buy
# from the high
# during the first 5 minutes
# with an adjustment added to the price
# divided into an account balance number
#
# only_first_5_minutes , if it is no, then it calculates shares all day
# timeframe , select desired timeframe for finding the high price, default 5 minutes
def na = Double.NaN;
input account_balance = 1000;
input stock_price_adjust = 0.01;
input only_first_5_minutes = yes;
# first 5 minutes, EST
input period_start = 0930;
input period_end = 0935;
def firstfive = SecondsFromTime(period_start) >= 0 and SecondstillTime(period_end) >= 0;
def timeframe = aggregationperiod.five_min;
def hifive = high(period = timeframe);
def adjprice = if (only_first_5_minutes and firstfive) then (hifive + stock_price_adjust) else if !only_first_5_minutes then (hifive + stock_price_adjust) else 0;
def shares = if adjprice > 0 then round(account_balance/adjprice,1) else 0;
addlabel(yes, "account: " + account_balance + " shares: " + shares,color.yellow);
Last edited: