Can someone please help me add strat labels for previous 2 bars as well, currently it displays labels for current bar (5, 10 and 15 mins).
Will if work if I add [-1] after the agg here -> def tfFive_Min = AggregationPeriod.FIVE_MIN
Or Something similar, I tried but was not working.
I know I will have to make changes here as well to look back even further-
onebarFifteen_Min = hFifteen_Min <= hFifteen_Min[1] && lFifteen_Min >= lFifteen_Min[1];
twobarFifteen_Min = hFifteen_Min <= hFifteen_Min[1] && lFifteen_Min < lFifteen_Min[1] or
hFifteen_Min > hFifteen_Min[1] && lFifteen_Min >= lFifteen_Min[1];
thrbarFifteen_Min = hFifteen_Min > hFifteen_Min[1] && lFifteen_Min < lFifteen_Min[1];
An example of what to update will be really helpful.
Can someone please help with?
I know it might be little hectic and time consuming.
Code:
#Define global colors for light-to-dark labels (1,2, 3, upside/downside)
DefineGlobalColor("3up", CreateColor(000, 050, 025));
DefineGlobalColor("2up", CreateColor(000, 075, 010));
DefineGlobalColor("1up", CreateColor(050, 135, 055));
DefineGlobalColor("3down", CreateColor(125, 010, 010));
DefineGlobalColor("2down", CreateColor(175, 025, 025));
DefineGlobalColor("1down", CreateColor(175, 050, 065));
#Color labels Red/Green only for all bar types
#DefineGlobalColor("greenTimeframe", CreateColor(000, 100, 000));
#DefineGlobalColor("redTimeframe", CreateColor(100, 000, 000));
#Show only on intraday charts (thinkscript/ToS is
#declare hide_on_daily;
input showMin = yes;#Hint showMin: 1 minute\nStrat "the Oner"\nIntraday timeframe
input showFive_Min = yes;#Hint
input showTen_Min = yes;#Hint
input showFifteen_Min = yes;#Hint
### Five_Min AGGREGATION PERIOD ###
def tfFive_Min = AggregationPeriod.FIVE_MIN;
def hFive_Min;
def lFive_Min;
def oFive_Min;
def cFive_Min;
def grnFive_Min;
def redFive_Min;
def onebarFive_Min;
def twobarFive_Min;
def thrbarFive_Min;
if GetAggregationPeriod() <= AggregationPeriod.FIVE_MIN {
hFive_Min = high (period = tfFive_Min);
lFive_Min = low (period = tfFive_Min);
oFive_Min = open (period = tfFive_Min);
cFive_Min = close(period = tfFive_Min);
onebarFive_Min = hFive_Min <= hFive_Min[1] && lFive_Min >= lFive_Min[1];
twobarFive_Min = hFive_Min <= hFive_Min[1] && lFive_Min < lFive_Min[1] or
hFive_Min > hFive_Min[1] && lFive_Min >= lFive_Min[1];
thrbarFive_Min = hFive_Min > hFive_Min[1] && lFive_Min < lFive_Min[1];
grnFive_Min = oFive_Min <= cFive_Min;
redFive_Min = oFive_Min >= cFive_Min;
} else {
hFive_Min = 0;
lFive_Min = 0;
oFive_Min = 0;
cFive_Min = 0;
grnFive_Min = Double.NaN;
redFive_Min = Double.NaN;
onebarFive_Min = Double.NaN;
twobarFive_Min = Double.NaN;
thrbarFive_Min = Double.NaN;
}
#Color labels Red/Green only for all bar types
#AddLabel(showFive_Min, "5m", GlobalColor("greenTimeframe");
#AddLabel(showFive_Min, "5m", GlobalColor("redTimeframe");
AddLabel(showFive_Min, "5",
if onebarFive_Min && grnFive_Min then GlobalColor("1Up")
else if twobarFive_Min && grnFive_Min then GlobalColor("2Up")
else if thrbarFive_Min && grnFive_Min then GlobalColor("3Up")
else if onebarFive_Min && redFive_Min then GlobalColor("1Down")
else if twobarFive_Min && redFive_Min then GlobalColor("2Down")
else if thrbarFive_Min && redFive_Min then GlobalColor("3Down")
else Color.GRAY);
### Ten_Min AGGREGATION PERIOD ###
def tfTEN_Min = AggregationPeriod.TEN_MIN;
def hTEN_Min;
def lTEN_Min;
def oTEN_Min;
def cTEN_Min;
def grnTEN_Min;
def redTEN_Min;
def onebarTEN_Min;
def twobarTEN_Min;
def thrbarTEN_Min;
if GetAggregationPeriod() <= AggregationPeriod.TEN_MIN {
hTEN_Min = high (period = tfTEN_Min);
lTEN_Min = low (period = tfTEN_Min);
oTEN_Min = open (period = tfTEN_Min);
cTEN_Min = close(period = tfTEN_Min);
onebarTEN_Min = hTEN_Min <= hTEN_Min[1] && lTEN_Min >= lTEN_Min[1];
twobarTEN_Min = hTEN_Min <= hTEN_Min[1] && lTEN_Min < lTEN_Min[1] or
hTEN_Min > hTEN_Min[1] && lTEN_Min >= lTEN_Min[1];
thrbarTEN_Min = hTEN_Min > hTEN_Min[1] && lTEN_Min < lTEN_Min[1];
grnTEN_Min = oTEN_Min <= cTEN_Min;
redTEN_Min = oTEN_Min >= cTEN_Min;
} else {
hTEN_Min = 0;
lTEN_Min = 0;
oTEN_Min = 0;
cTEN_Min = 0;
grnTEN_Min = Double.NaN;
redTEN_Min = Double.NaN;
onebarTEN_Min = Double.NaN;
twobarTEN_Min = Double.NaN;
thrbarTEN_Min = Double.NaN;
}
#Color labels Red/Green only for all bar types
#AddLabel(showTEN_Min, "5m", GlobalColor("greenTimeframe");
#AddLabel(showTEN_Min, "5m", GlobalColor("redTimeframe");
AddLabel(showTEN_Min, "10",
if onebarTEN_Min && grnTEN_Min then GlobalColor("1Up")
else if twobarTEN_Min && grnTEN_Min then GlobalColor("2Up")
else if thrbarTEN_Min && grnTEN_Min then GlobalColor("3Up")
else if onebarTEN_Min && redTEN_Min then GlobalColor("1Down")
else if twobarTEN_Min && redTEN_Min then GlobalColor("2Down")
else if thrbarTEN_Min && redTEN_Min then GlobalColor("3Down")
else Color.GRAY);
### Fifteen_Min AGGREGATION PERIOD ###
def tfFifteen_Min = AggregationPeriod.FIFTEEN_MIN;
def hFifteen_Min;
def lFifteen_Min;
def oFifteen_Min;
def cFifteen_Min;
def grnFifteen_Min;
def redFifteen_Min;
def onebarFifteen_Min;
def twobarFifteen_Min;
def thrbarFifteen_Min;
if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN {
hFifteen_Min = high (period = tfFifteen_Min);
lFifteen_Min = low (period = tfFifteen_Min);
oFifteen_Min = open (period = tfFifteen_Min);
cFifteen_Min = close(period = tfFifteen_Min);
onebarFifteen_Min = hFifteen_Min <= hFifteen_Min[1] && lFifteen_Min >= lFifteen_Min[1];
twobarFifteen_Min = hFifteen_Min <= hFifteen_Min[1] && lFifteen_Min < lFifteen_Min[1] or
hFifteen_Min > hFifteen_Min[1] && lFifteen_Min >= lFifteen_Min[1];
thrbarFifteen_Min = hFifteen_Min > hFifteen_Min[1] && lFifteen_Min < lFifteen_Min[1];
grnFifteen_Min = oFifteen_Min <= cFifteen_Min;
redFifteen_Min = oFifteen_Min >= cFifteen_Min;
} else {
hFifteen_Min = 0;
lFifteen_Min = 0;
oFifteen_Min = 0;
cFifteen_Min = 0;
grnFifteen_Min = Double.NaN;
redFifteen_Min = Double.NaN;
onebarFifteen_Min = Double.NaN;
twobarFifteen_Min = Double.NaN;
thrbarFifteen_Min = Double.NaN;
}
#Color labels Red/Green only for all bar types
#AddLabel(showFifteen_Min, "15", GlobalColor("greenTimeframe");
#AddLabel(showFifteen_Min, "15", GlobalColor("redTimeframe");
AddLabel(showFifteen_Min, "15",
if onebarFifteen_Min && grnFifteen_Min then GlobalColor("1Up")
else if twobarFifteen_Min && grnFifteen_Min then GlobalColor("2Up")
else if thrbarFifteen_Min && grnFifteen_Min then GlobalColor("3Up")
else if onebarFifteen_Min && redFifteen_Min then GlobalColor("1Down")
else if twobarFifteen_Min && redFifteen_Min then GlobalColor("2Down")
else if thrbarFifteen_Min && redFifteen_Min then GlobalColor("3Down")
else Color.GRAY);
Will if work if I add [-1] after the agg here -> def tfFive_Min = AggregationPeriod.FIVE_MIN
Or Something similar, I tried but was not working.
I know I will have to make changes here as well to look back even further-
onebarFifteen_Min = hFifteen_Min <= hFifteen_Min[1] && lFifteen_Min >= lFifteen_Min[1];
twobarFifteen_Min = hFifteen_Min <= hFifteen_Min[1] && lFifteen_Min < lFifteen_Min[1] or
hFifteen_Min > hFifteen_Min[1] && lFifteen_Min >= lFifteen_Min[1];
thrbarFifteen_Min = hFifteen_Min > hFifteen_Min[1] && lFifteen_Min < lFifteen_Min[1];
An example of what to update will be really helpful.
Can someone please help with?
I know it might be little hectic and time consuming.
Last edited by a moderator: