Hello
I did manage to create a script for TOS, but it doesnt work the same as DAS. I dont have DAS so I cant see what is the problem, but I noticed this differences when Thor posts high trades and I compare the levels and are not quite the same. If anyone can help us it would be great. I am sharing my code so we can build upon it.
Luke_cdt
TOS code:
input aggregationPeriod = {default "DAY", "WEEK", "MONTH"};
input length = 1;
Assert(length > 0, "'length' should be positive: " + length);
def yyyymmdd = GetYYYYMMDD();
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def period;
switch (aggregationPeriod) {
case DAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
period = Floor(day_number / 7);
case MONTH:
period = Floor(month - First(month));
}
def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % length else count[1], 0);
def start = CompoundValue(1, count < count[1] + period - period[1], yes);
def highValue = if start then Highest(high(period = AggregationPeriod.FOUR_HOURS), 6)[1] else if highValue[1] != 0 then highValue[1] else Double.NaN;
#plot x= highValue;
def lowValue = if start then Lowest(low(period = AggregationPeriod.FOUR_HOURS), 6)[1] else if lowValue[1] != 0 then lowValue[1] else Double.NaN;
#Plot y= lowValue;
def closeValue = if start then close(period = aggregationPeriod)[1] else closeValue[1];
#plot z=closeValue;
def range = highValue - lowValue;
#plot R5 = closeValue + range ;
plot R4 = closeValue + (range * (1.1) / 2);
plot R3 = closeValue + (range * (1.1) / 4);
plot R2 = closeValue + (range * (1.1) / 6);
plot R1 = closeValue + (range * (1.1) / 12);
#plot PP = (highValue + lowValue + closeValue)/3 ;
plot S1 = closeValue - (range * (1.1) / 12);
plot S2 = closeValue - (range * (1.1) / 6);
plot S3 = closeValue - (range * (1.1) / 4);
plot S4 = closeValue - (range * (1.1) / 2);
#plot S5 = (closeValue - range);
#R1.Hide();
#S1.Hide();
#R5.SetDefaultColor(GetColor(5));
R4.SetDefaultColor(Color.GREEN);
R3.SetDefaultColor(Color.RED);
R2.SetDefaultColor(Color.GRAY);
R1.SetDefaultColor(Color.GRAY);
#PP.SetDefaultColor(Color.YELLOW);
S1.SetDefaultColor(Color.GRAY);
S2.SetDefaultColor(Color.GRAY);
S3.SetDefaultColor(Color.GREEN);
S4.SetDefaultColor(Color.RED);
#S5.SetDefaultColor(GetColor(6));
#R5.SetPaintingStrategy(paintingStrategy);
R4.SetPaintingStrategy(paintingStrategy.line);
R3.SetPaintingStrategy(paintingStrategy.line);
R2.SetPaintingStrategy(paintingStrategy.line);
R1.SetPaintingStrategy(paintingStrategy.line);
#PP.SetPaintingStrategy(paintingStrategy.line);
S1.SetPaintingStrategy(paintingStrategy.line);
S2.SetPaintingStrategy(paintingStrategy.line);
S3.SetPaintingStrategy(paintingStrategy.line);
S4.SetPaintingStrategy(paintingStrategy.line);
#S5.SetPaintingStrategy(paintingStrategy);