Jump to content
Medved Trader Forums
  • 0

Previous Month/Year H/L/C

Mark 44


Hey guys, just wondering if we could have a previous Month/Year H/L/C indicator built.

I have enclosed my TOS script to give you an idea of what I had in mind.



declare once_per_bar;
declare upper;
declare real_size;

input Pivots = {"Shadows", default "Normal"};
input showOnlyLast = no;
input ShowCloud = yes;
input showBubble = yes;
input ShiftBubble = 5;
def n1 = ShiftBubble + 1;

input timeFrame = { "DAY", "WEEK", "MONTH", "OPT EXP", default "YEAR"};

def cap = GetAggregationPeriod();

def errorInAggregation =
    timeFrame == timeFrame.YEAR and !(cap == AggregationPeriod.MONTH or cap == AggregationPeriod.DAY) or
    timeFrame == timeFrame.YEAR and cap == AggregationPeriod.DAY and BarNumber() < 510 or
    timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH or
    timeFrame == timeFrame."OPT EXP" and cap >= AggregationPeriod.OPT_EXP;

AddLabel( errorInAggregation, "Agregation Error", Color.RED);

def IsNewYear = GetYear() != GetYear()[1];
#def IsNewFrame = GetYYYYMMDD(period = timeFrame);

def cBar = if IsNaN(close) then 0 else BarNumber();
def LastBar = HighestAll(cBar);
def isExtention = BarNumber() > LastBar;

def C_ ;
def H_ ;
def L_ ;

if  isExtention
then {

    C_   = C_[1];
    H_   = H_[1];
    L_   = L_[1];
} else

if timeFrame == timeFrame."YEAR"
then {

    C_ = if IsNewYear then close[1] else C_[1];
    H_ = if IsNewYear then high else Max(H_[1], high);
    L_ = if IsNewYear then low else Min(L_[1], low);
else {

    C_ = if BarNumber() <= 1 then open else close(period = timeFrame)[1];
    H_ = if BarNumber() <= 1 then open else high(period = timeFrame)[1];
    L_ = if BarNumber() <= 1 then open else low(period = timeFrame)[1];

def C ;
def H ;
def L ;

if timeFrame == timeFrame."YEAR"
then {

    C   = if IsNewYear then C_ else C[1];
    H   = if IsNewYear then H_[1] else H[1];
    L   = if IsNewYear then L_[1] else L[1];
else {

    C   = C_;
    H   = H_;
    L   = L_;

plot Cl;
plot Hi;
plot Lw;
if (showOnlyLast and !isExtention)
then {

    Cl = Double.NaN;
    Hi = Double.NaN;
    Lw = Double.NaN;
else {

    Cl = C;
    Hi = H;
    Lw = L;




def cond = showBubble and IsNaN(close[ShiftBubble]) and !IsNaN(close[n1]) ;

AddChartBubble(cond, Cl, Concat("m cl: ", Round(Cl)), Color.white);
AddChartBubble(cond, Hi, Concat("m hi: ", Round(Hi)), Color.white);
AddChartBubble(cond, Lw, Concat("m lo: ", Round(Lw)), Color.white);


Edited by SPT
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Mike, I'm new to the platform and we're still getting familiar with things but really like what I see so far. Last week on Twitter I pointed out that open interest was not displayed for Questrade data on the Medved option chain. Just wanted to follow up with you guys on that to see if there is any way to get that resolved. Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...