Hello everyone,
First of all, thank you for your time and help.
I have an issue when I want to build a strategy based on TPO.
Here is my code (strategy):
All the values for PC, POC, and tpo.getPointOfControl() are N/A
at line 57, I used this too:
profile tpo = timeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, #"numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
the result was the same.
I'll appreciate it, if you help me to get the POC's value inside a strategy, instead of a study.
I need to call TPO's POC value inside a strategy to test its trades.
Thanks
First of all, thank you for your time and help.
I have an issue when I want to build a strategy based on TPO.
Here is my code (strategy):
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2010-2022
#
input pricePerRowHeightMode = {default TICKSIZE, AUTOMATIC, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default DAY, CHART, MINUTE, HOUR, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = no;
input valueAreaPercent = 70;
input opacity = 20;
def period;
def yyyymmdd = getYyyyMmDd();
def seconds = secondsFromTime(0);
def month = getYear() * 12 + getMonth();
def day_number = daysFromDate(first(yyyymmdd)) + getDayOfWeek(first(yyyymmdd));
def dom = getDayOfMonth(yyyymmdd);
def dow = getDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
period = 0;
case MINUTE:
period = floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
period = floor(seconds / 3600 + day_number * 24);
case DAY:
period = countTradingDays(Min(first(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
period = floor(day_number / 7);
case MONTH:
period = floor(month - first(month));
case "OPT EXP":
period = exp_opt - first(exp_opt);
case BAR:
period = barNumber() - 1;
}
def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = 0 < period - period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}
profile tpo = timeProfile("startnewprofile"=1);
tpo.Show("color"=Color.BLUE);
tpo.show();
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.getPointOfControl()) and con then pc[1] else tpo.getPointOfControl();
def plotsDomain = IsNaN(close) == onExpansion;
def POC = if plotsDomain then pc else Double.NaN;
AddLabel(yes,tpo.getPointOfControl()[0]);
AddLabel(yes, POC[0]);
AddLabel(yes, pc[0]);
All the values for PC, POC, and tpo.getPointOfControl() are N/A
at line 57, I used this too:
profile tpo = timeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, #"numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
the result was the same.
I'll appreciate it, if you help me to get the POC's value inside a strategy, instead of a study.
I need to call TPO's POC value inside a strategy to test its trades.
Thanks
Last edited by a moderator: