19 Min High Low Indicator for ThinkorSwim

Heloyguerra

New member
Here is an indicator that I had custom made I would like to share with group

Code:
#---------- Study Inputs
input startTimeOne = 930;
input endTimeOne = 949;
input startTimeTwo = 1000;
input endTimeTwo = 1019;
input startTimeThree = 1030;
input endTimeThree = 1049;
input startTimeFour = 1100;
input endTimeFour = 1119;
input startTimeFive = 1130;
input endTimeFive = 1149;
input startTimeSix = 1200;
input endTimeSix = 1219;
input startTimeSeven = 1230;
input endTimeSeven = 1249;
input startTimeEight = 1300;
input endTimeEight = 1319;
input startTimeNine = 1330;
input endTimeNine = 1349;
input startTimeTen = 1400;
input endTimeTen = 1419;
input startTimeEleven = 1430;
input endTimeEleven = 1449;
input startTimeTwelve = 1500;
input endTimeTwelve = 1519;
input startTimeThirteen = 1530;
input endTimeThirteen = 1549;

#---------- Time Span Section
def targetPeriodOne = SecondsFromTime(startTimeOne) >= 0 and SecondsTillTime(endTimeOne) >= 0;
rec targetPeriodOneHigh = if targetPeriodOne and !targetPeriodOne[1] then high else
    if high > targetPeriodOneHigh[1] and targetPeriodOne then high else targetPeriodOneHigh[1];
rec targetPeriodOneLow = if targetPeriodOne and !targetPeriodOne[1] then low else
    if low > 0 and low < targetPeriodOneLow[1] and targetPeriodOne then low else targetPeriodOneLow[1];

def targetPeriodTwo = SecondsFromTime(startTimeTwo) >= 0 and SecondsTillTime(endTimeTwo) >= 0;
rec targetPeriodTwoHigh = if targetPeriodTwo and !targetPeriodTwo[1] then high else
    if high > targetPeriodTwoHigh[1] and targetPeriodTwo then high else targetPeriodTwoHigh[1];
rec targetPeriodTwoLow = if targetPeriodTwo and !targetPeriodTwo[1] then low else
    if low > 0 and low < targetPeriodTwoLow[1] and targetPeriodTwo then low else targetPeriodTwoLow[1];
#
def targetPeriodThree = SecondsFromTime(startTimeThree) >= 0 and SecondsTillTime(endTimeThree) >= 0;
rec targetPeriodThreeHigh = if targetPeriodThree and !targetPeriodThree[1] then high else
    if high > targetPeriodThreeHigh[1] and targetPeriodThree then high else targetPeriodThreeHigh[1];
rec targetPeriodThreeLow = if targetPeriodThree and !targetPeriodThree[1] then low else
    if low > 0 and low < targetPeriodThreeLow[1] and targetPeriodThree then low else targetPeriodThreeLow[1];
#
def targetPeriodFour = SecondsFromTime(startTimeFour) >= 0 and SecondsTillTime(endTimeFour) >= 0;
rec targetPeriodFourHigh = if targetPeriodFour and !targetPeriodFour[1] then high else
    if high > targetPeriodFourHigh[1] and targetPeriodFour then high else targetPeriodFourHigh[1];
rec targetPeriodFourLow = if targetPeriodFour and !targetPeriodFour[1] then low else
    if low > 0 and low < targetPeriodFourLow[1] and targetPeriodFour then low else targetPeriodFourLow[1];
#
def targetPeriodFive = SecondsFromTime(startTimeFive) >= 0 and SecondsTillTime(endTimeFive) >= 0;
rec targetPeriodFiveHigh = if targetPeriodFive and !targetPeriodFive[1] then high else
    if high > targetPeriodFiveHigh[1] and targetPeriodFive then high else targetPeriodFiveHigh[1];
rec targetPeriodFiveLow = if targetPeriodFive and !targetPeriodFive[1] then low else
    if low > 0 and low < targetPeriodFiveLow[1] and targetPeriodFive then low else targetPeriodFiveLow[1];
#
def targetPeriodSix = SecondsFromTime(startTimeSix) >= 0 and SecondsTillTime(endTimeSix) >= 0;
rec targetPeriodSixHigh = if targetPeriodSix and !targetPeriodSix[1] then high else
    if high > targetPeriodSixHigh[1] and targetPeriodSix then high else targetPeriodSixHigh[1];
rec targetPeriodSixLow = if targetPeriodSix and !targetPeriodSix[1] then low else
    if low > 0 and low < targetPeriodSixLow[1] and targetPeriodSix then low else targetPeriodSixLow[1];
#
def targetPeriodSeven = SecondsFromTime(startTimeSeven) >= 0 and SecondsTillTime(endTimeSeven) >= 0;
rec targetPeriodSevenHigh = if targetPeriodSeven and !targetPeriodSeven[1] then high else
    if high > targetPeriodSevenHigh[1] and targetPeriodSeven then high else targetPeriodSevenHigh[1];
rec targetPeriodSevenLow = if targetPeriodSeven and !targetPeriodSeven[1] then low else
    if low > 0 and low < targetPeriodSevenLow[1] and targetPeriodSeven then low else targetPeriodSevenLow[1];
#
def targetPeriodEight = SecondsFromTime(startTimeEight) >= 0 and SecondsTillTime(endTimeEight) >= 0;
rec targetPeriodEightHigh = if targetPeriodEight and !targetPeriodEight[1] then high else
    if high > targetPeriodEightHigh[1] and targetPeriodEight then high else targetPeriodEightHigh[1];
rec targetPeriodEightLow = if targetPeriodEight and !targetPeriodEight[1] then low else
    if low > 0 and low < targetPeriodEightLow[1] and targetPeriodEight then low else targetPeriodEightLow[1];
#
def targetPeriodNine = SecondsFromTime(startTimeNine) >= 0 and SecondsTillTime(endTimeNine) >= 0;
rec targetPeriodNineHigh = if targetPeriodNine and !targetPeriodNine[1] then high else
    if high > targetPeriodNineHigh[1] and targetPeriodNine then high else targetPeriodNineHigh[1];
rec targetPeriodNineLow = if targetPeriodNine and !targetPeriodNine[1] then low else
    if low > 0 and low < targetPeriodNineLow[1] and targetPeriodNine then low else targetPeriodNineLow[1];
#
def targetPeriodTen = SecondsFromTime(startTimeTen) >= 0 and SecondsTillTime(endTimeTen) >= 0;
rec targetPeriodTenHigh = if targetPeriodTen and !targetPeriodTen[1] then high else
    if high > targetPeriodTenHigh[1] and targetPeriodTen then high else targetPeriodTenHigh[1];
rec targetPeriodTenLow = if targetPeriodTen and !targetPeriodTen[1] then low else
    if low > 0 and low < targetPeriodTenLow[1] and targetPeriodTen then low else targetPeriodTenLow[1];
#
def targetPeriodEleven = SecondsFromTime(startTimeEleven) >= 0 and SecondsTillTime(endTimeEleven) >= 0;
rec targetPeriodElevenHigh = if targetPeriodEleven and !targetPeriodEleven[1] then high else
    if high > targetPeriodElevenHigh[1] and targetPeriodEleven then high else targetPeriodElevenHigh[1];
rec targetPeriodElevenLow = if targetPeriodEleven and !targetPeriodEleven[1] then low else
    if low > 0 and low < targetPeriodElevenLow[1] and targetPeriodEleven then low else targetPeriodElevenLow[1];
#
def targetPeriodTwelve = SecondsFromTime(startTimeTwelve) >= 0 and SecondsTillTime(endTimeTwelve) >= 0;
rec targetPeriodTwelveHigh = if targetPeriodTwelve and !targetPeriodTwelve[1] then high else
    if high > targetPeriodTwelveHigh[1] and targetPeriodTwelve then high else targetPeriodTwelveHigh[1];
rec targetPeriodTwelveLow = if targetPeriodTwelve and !targetPeriodTwelve[1] then low else
    if low > 0 and low < targetPeriodTwelveLow[1] and targetPeriodTwelve then low else targetPeriodTwelveLow[1];
#
def targetPeriodThirteen = SecondsFromTime(startTimeThirteen) >= 0 and SecondsTillTime(endTimeThirteen) >= 0;
rec targetPeriodThirteenHigh = if targetPeriodThirteen and !targetPeriodThirteen[1] then high else
    if high > targetPeriodThirteenHigh[1] and targetPeriodThirteen then high else targetPeriodThirteenHigh[1];
rec targetPeriodThirteenLow = if targetPeriodThirteen and !targetPeriodThirteen[1] then low else
    if low > 0 and low < targetPeriodThirteenLow[1] and targetPeriodThirteen then low else targetPeriodThirteenLow[1];
#
#---------- Plot High and Low Lines Section
def okToPlotOne = GetDay() == GetLastDay() and targetPeriodOne;
plot targetHighOne = if okToPlotOne then HighestAll(if okToPlotOne then targetPeriodOneHigh else Double.NaN) else Double.NaN;
targetHighOne.SetDefaultColor(Color.GREEN);
targetHighOne.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighOne.HideTitle();
targetHighOne.HideBubble();
plot targetLowOne = if okToPlotOne then LowestAll(if okToPlotOne then targetPeriodOneLow else Double.NaN) else Double.NaN;
targetLowOne.SetDefaultColor(Color.RED);
targetLowOne.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowOne.HideTitle();
targetLowOne.HideBubble();

def okToPlotTwo = GetDay() == GetLastDay() and targetPeriodTwo;
plot targetHighTwo = if okToPlotTwo then HighestAll(if okToPlotTwo then targetPeriodTwoHigh else Double.NaN) else Double.NaN;
targetHighTwo.SetDefaultColor(Color.GREEN);
targetHighTwo.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighTwo.HideTitle();
targetHighTwo.HideBubble();
plot targetLowTwo = if okToPlotTwo then LowestAll(if okToPlotTwo then targetPeriodTwoLow else Double.NaN) else Double.NaN;
targetLowTwo.SetDefaultColor(Color.RED);
targetLowTwo.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowTwo.HideTitle();
targetLowTwo.HideBubble();

def okToPlotThree = GetDay() == GetLastDay() and targetPeriodThree;
plot targetHighThree = if okToPlotThree then HighestAll(if okToPlotThree then targetPeriodThreeHigh else Double.NaN) else Double.NaN;
targetHighThree.SetDefaultColor(Color.GREEN);
targetHighThree.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighThree.HideTitle();
targetHighThree.HideBubble();
plot targetLowThree = if okToPlotThree then LowestAll(if okToPlotThree then targetPeriodThreeLow else Double.NaN) else Double.NaN;
targetLowThree.SetDefaultColor(Color.RED);
targetLowThree.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowThree.HideTitle();
targetLowThree.HideBubble();

def okToPlotFour = GetDay() == GetLastDay() and targetPeriodFour;
plot targetHighFour = if okToPlotFour then HighestAll(if okToPlotFour then targetPeriodFourHigh else Double.NaN) else Double.NaN;
targetHighFour.SetDefaultColor(Color.GREEN);
targetHighFour.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighFour.HideTitle();
targetHighFour.HideBubble();
plot targetLowFour = if okToPlotFour then LowestAll(if okToPlotFour then targetPeriodFourLow else Double.NaN) else Double.NaN;
targetLowFour.SetDefaultColor(Color.RED);
targetLowFour.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowFour.HideTitle();
targetLowFour.HideBubble();

def okToPlotFive = GetDay() == GetLastDay() and targetPeriodFive;
plot targetHighFive = if okToPlotFive then HighestAll(if okToPlotFive then targetPeriodFiveHigh else Double.NaN) else Double.NaN;
targetHighFive.SetDefaultColor(Color.GREEN);
targetHighFive.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighFive.HideTitle();
targetHighFive.HideBubble();
plot targetLowFive = if okToPlotFive then LowestAll(if okToPlotFive then targetPeriodFiveLow else Double.NaN) else Double.NaN;
targetLowFive.SetDefaultColor(Color.RED);
targetLowFive.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowFive.HideTitle();
targetLowFive.HideBubble();

def okToPlotSix = GetDay() == GetLastDay() and targetPeriodSix;
plot targetHighSix = if okToPlotSix then HighestAll(if okToPlotSix then targetPeriodSixHigh else Double.NaN) else Double.NaN;
targetHighSix.SetDefaultColor(Color.GREEN);
targetHighSix.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighSix.HideTitle();
targetHighSix.HideBubble();
plot targetLowSix = if okToPlotSix then LowestAll(if okToPlotSix then targetPeriodSixLow else Double.NaN) else Double.NaN;
targetLowSix.SetDefaultColor(Color.RED);
targetLowSix.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowSix.HideTitle();
targetLowSix.HideBubble();

def okToPlotSeven = GetDay() == GetLastDay() and targetPeriodSeven;
plot targetHighSeven = if okToPlotSeven then HighestAll(if okToPlotSeven then targetPeriodSevenHigh else Double.NaN) else Double.NaN;
targetHighSeven.SetDefaultColor(Color.GREEN);
targetHighSeven.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighSeven.HideTitle();
targetHighSeven.HideBubble();
plot targetLowSeven = if okToPlotSeven then LowestAll(if okToPlotSeven then targetPeriodSevenLow else Double.NaN) else Double.NaN;
targetLowSeven.SetDefaultColor(Color.RED);
targetLowSeven.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowSeven.HideTitle();
targetLowSeven.HideBubble();

def okToPlotEight = GetDay() == GetLastDay() and targetPeriodEight;
plot targetHighEight = if okToPlotEight then HighestAll(if okToPlotEight then targetPeriodEightHigh else Double.NaN) else Double.NaN;
targetHighEight.SetDefaultColor(Color.GREEN);
targetHighEight.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighEight.HideTitle();
targetHighEight.HideBubble();
plot targetLowEight = if okToPlotEight then LowestAll(if okToPlotEight then targetPeriodEightLow else Double.NaN) else Double.NaN;
targetLowEight.SetDefaultColor(Color.RED);
targetLowEight.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowEight.HideTitle();
targetLowEight.HideBubble();

def okToPlotNine = GetDay() == GetLastDay() and targetPeriodNine;
plot targetHighNine = if okToPlotNine then HighestAll(if okToPlotNine then targetPeriodNineHigh else Double.NaN) else Double.NaN;
targetHighNine.SetDefaultColor(Color.GREEN);
targetHighNine.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighNine.HideTitle();
targetHighNine.HideBubble();
plot targetLowNine = if okToPlotNine then LowestAll(if okToPlotNine then targetPeriodNineLow else Double.NaN) else Double.NaN;
targetLowNine.SetDefaultColor(Color.RED);
targetLowNine.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowNine.HideTitle();
targetLowNine.HideBubble();

def okToPlotTen = GetDay() == GetLastDay() and targetPeriodTen;
plot targetHighTen = if okToPlotTen then HighestAll(if okToPlotTen then targetPeriodTenHigh else Double.NaN) else Double.NaN;
targetHighTen.SetDefaultColor(Color.GREEN);
targetHighTen.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighTen.HideTitle();
targetHighTen.HideBubble();
plot targetLowTen = if okToPlotTen then LowestAll(if okToPlotTen then targetPeriodTenLow else Double.NaN) else Double.NaN;
targetLowTen.SetDefaultColor(Color.RED);
targetLowTen.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowTen.HideTitle();
targetLowTen.HideBubble();

def okToPlotEleven = GetDay() == GetLastDay() and targetPeriodEleven;
plot targetHighEleven = if okToPlotEleven then HighestAll(if okToPlotEleven then targetPeriodElevenHigh else Double.NaN) else Double.NaN;
targetHighEleven.SetDefaultColor(Color.GREEN);
targetHighEleven.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighEleven.HideTitle();
targetHighEleven.HideBubble();
plot targetLowEleven = if okToPlotEleven then LowestAll(if okToPlotEleven then targetPeriodElevenLow else Double.NaN) else Double.NaN;
targetLowEleven.SetDefaultColor(Color.RED);
targetLowEleven.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowEleven.HideTitle();
targetLowEleven.HideBubble();

def okToPlotTwelve = GetDay() == GetLastDay() and targetPeriodTwelve;
plot targetHighTwelve = if okToPlotTwelve then HighestAll(if okToPlotTwelve then targetPeriodTwelveHigh else Double.NaN) else Double.NaN;
targetHighTwelve.SetDefaultColor(Color.GREEN);
targetHighTwelve.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighTwelve.HideTitle();
targetHighTwelve.HideBubble();
plot targetLowTwelve = if okToPlotTwelve then LowestAll(if okToPlotTwelve then targetPeriodTwelveLow else Double.NaN) else Double.NaN;
targetLowTwelve.SetDefaultColor(Color.RED);
targetLowTwelve.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowTwelve.HideTitle();
targetLowTwelve.HideBubble();

def okToPlotThirteen = GetDay() == GetLastDay() and targetPeriodThirteen;
plot targetHighThirteen = if okToPlotThirteen then HighestAll(if okToPlotThirteen then targetPeriodThirteenHigh else Double.NaN) else Double.NaN;
targetHighThirteen.SetDefaultColor(Color.GREEN);
targetHighThirteen.SetPaintingStrategy(PaintingStrategy.POINTS);
targetHighThirteen.HideTitle();
targetHighThirteen.HideBubble();
plot targetLowThirteen = if okToPlotThirteen then LowestAll(if okToPlotThirteen then targetPeriodThirteenLow else Double.NaN) else Double.NaN;
targetLowThirteen.SetDefaultColor(Color.RED);
targetLowThirteen.SetPaintingStrategy(PaintingStrategy.POINTS);
targetLowThirteen.HideTitle();
targetLowThirteen.HideBubble();

#---------- Consolidate Buy and Sell Lines Section
rec trackHighLine = if IsNaN(targetHighOne) and !IsNaN(targetHighOne[1]) then targetHighOne[1] else
    if IsNaN(targetHighTwo) and !IsNaN(targetHighTwo[1]) then targetHighTwo[1] else
    if IsNaN(targetHighThree) and !IsNaN(targetHighThree[1]) then targetHighThree[1] else
    if IsNaN(targetHighFour) and !IsNaN(targetHighFour[1]) then targetHighFour[1] else
    if IsNaN(targetHighFive) and !IsNaN(targetHighFive[1]) then targetHighFive[1] else
    if IsNaN(targetHighSix) and !IsNaN(targetHighSix[1]) then targetHighSix[1] else
    if IsNaN(targetHighSeven) and !IsNaN(targetHighSeven[1]) then targetHighSeven[1] else
    if IsNaN(targetHighEight) and !IsNaN(targetHighEight[1]) then targetHighEight[1] else
    if IsNaN(targetHighNine) and !IsNaN(targetHighNine[1]) then targetHighNine[1] else
    if IsNaN(targetHighTen) and !IsNaN(targetHighTen[1]) then targetHighTen[1] else
    if IsNaN(targetHighEleven) and !IsNaN(targetHighEleven[1]) then targetHighEleven[1] else
    if IsNaN(targetHighTwelve) and !IsNaN(targetHighTwelve[1]) then targetHighTwelve[1] else
    if IsNaN(targetHighThirteen) and !IsNaN(targetHighThirteen[1]) then targetHighThirteen[1] else trackHighLine[1];

rec trackLowLine = if IsNaN(targetLowOne) and !IsNaN(targetLowOne[1]) then targetLowOne[1] else
    if IsNaN(targetLowTwo) and !IsNaN(targetLowTwo[1]) then targetLowTwo[1] else
    if IsNaN(targetLowThree) and !IsNaN(targetLowThree[1]) then targetLowThree[1] else
    if IsNaN(targetLowFour) and !IsNaN(targetLowFour[1]) then targetLowFour[1] else
    if IsNaN(targetLowFive) and !IsNaN(targetLowFive[1]) then targetLowFive[1] else
    if IsNaN(targetLowSix) and !IsNaN(targetLowSix[1]) then targetLowSix[1] else
    if IsNaN(targetLowSeven) and !IsNaN(targetLowSeven[1]) then targetLowSeven[1] else
    if IsNaN(targetLowEight) and !IsNaN(targetLowEight[1]) then targetLowEight[1] else
    if IsNaN(targetLowNine) and !IsNaN(targetLowNine[1]) then targetLowNine[1] else
    if IsNaN(targetLowTen) and !IsNaN(targetLowTen[1]) then targetLowTen[1] else
    if IsNaN(targetLowEleven) and !IsNaN(targetLowEleven[1]) then targetLowEleven[1] else
    if IsNaN(targetLowTwelve) and !IsNaN(targetLowTwelve[1]) then targetLowTwelve[1] else
    if IsNaN(targetLowThirteen) and !IsNaN(targetLowThirteen[1]) then targetLowThirteen[1] else trackLowLine[1];

plot buyLine = trackHighLine;
buyLine.SetDefaultColor(Color.CYAN);
plot sellLine = trackLowLine;
sellLine.SetDefaultColor(Color.MAGENTA);

#---------- Siganls Section
def rawBuySignal = close[1] <= buyLine[1] and close > buyLine;
def rawSellSignal = close[1] >= sellLine[1] and close < sellLine;
plot buySignal = rawBuySignal and !rawBuySignal[1];
buySignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buySignal.SetDefaultColor(Color.BLUE);
buySignal.SetLineWeight(3);
plot sellSignal = rawSellSignal and !rawSellSignal[1];
sellSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sellSignal.SetDefaultColor(Color.YELLOW);
sellSignal.SetLineWeight(3);
addOrder(OrderType.BUY_AUTO, no);
 
I would like to share my second version of there 19 min break out indicator. I not very good at back testing if someone can back test it would be great

Code:
MTS2005 19m range break _ MTSD_19mStrat_Code3
# MTS CUSTOM for Hector Guerra
# STRATEGY 2005 v0.5

input StartTime = 330; #Hint StartTime: Code3 Suggestion start at 12:30 AM Pacific Time = 3:30 AM ET
input EndTime = 1500; #Hint EndTime: Code3 Suggestion Stop at Noon Pacific = 3PM ET EXCEPT Oil; end at 2PM ET. 
Input AnyTime = Yes;
input TrailingStopTicks = 30;
input MoveBreakEvenTicks = 10;

def ActiveTIME = SecondsFromTime(StartTime) > 0 and SecondsTillTime(EndTime) > 0;

def t = TickSize();
def t19 = (GetTime() - 1140000) % 1800000;
def t30 = (GetTime() % 1800000);
def dbTrgBar = t19 == 0;
def db30Bar = t30 == 0;
def active = Highest(dbTrgBar[1], 10) == 1;
def h19 = If(t19 == 0, Highest(high, 19), 0);
def h19d = If(ActiveTIME OR AnyTime, Highest(h19[1], 30), h19d[1]);
def l19 = If(t19 == 0, Lowest(low, 19), 0);
def l19d = If(ActiveTIME OR AnyTime, Highest(l19[1], 30), l19d[1]);
plot UpperBO = If(ActiveTIME OR AnyTime, h19d, Double.NaN);
UpperBO.SetPaintingStrategy(PaintingStrategy.DASHES);
plot LowerBO = If(ActiveTIME OR AnyTime, l19d, Double.NaN);
LowerBO.SetPaintingStrategy(PaintingStrategy.DASHES);
AddCloud(If(active, LowerBO, Double.NaN), UpperBO, Color.GRAY, Color.GRAY);
def LongBO =  (ActiveTIME OR AnyTime) and active and high crosses above UpperBO;
def ShortBO = (ActiveTIME OR AnyTime) and active and low crosses below LowerBO;

def LongStop =  low crosses below l19d;
def ShortStop =  high crosses above h19d;

def Status = if LongBO then 1 else if ShortBO then -1 else if Status[1] > 0 and LongStop then 0 else if Status[1] < 0 and ShortStop then 0 else Status[1];
def BuySig = Status crosses above 0;
def SellSig = Status crosses below 0;

AddOrder(OrderType.BUY_AUTO, BuySig, UpperBO + t, 1, Color.CURRENT, Color.GREEN,"19mBO");
AddOrder(OrderType.SELL_AUTO, SellSig, LowerBO - t, 1, Color.CURRENT, Color.RED,"19mBO");
AddOrder(OrderType.SELL_TO_CLOSE, LongStop , l19d, 1, Color.CURRENT, Color.YELLOW,"19mSTOP");
AddOrder(OrderType.BUY_TO_CLOSE, ShortStop , h19d, 1, Color.CURRENT, Color.YELLOW,"19mSTOP");
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
515 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top