Ugly Gate

Ramisegal

Active member
I've been experimenting with a new indicator called the Ugly Gate (UG). It's calculated by adding up the price levels of multiple time segments throughout the day. I've been testing it on various time frames and assets, and I'm seeing some interesting results. Has anyone else heard of this indicator or have any experience with it?
 
I've been experimenting with a new indicator called the Ugly Gate (UG). It's calculated by adding up the price levels of multiple time segments throughout the day. I've been testing it on various time frames and assets, and I'm seeing some interesting results. Has anyone else heard of this indicator or have any experience with it?

i haven't . sounds interesting. do you need help tweaking it? care to post the code?
 

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

Thanks for asking, currently the best setting are for NQ and ES
This is the code i got so far, it it is for a custom column, but you know what to do...

input UseRegularTrading = yes;
input RthTradeTimeStart = 0930;
input RthTradeTimeEnd = 1600;
def ActiveRthTradeTime = if SecondsTillTime(RthTradeTimeStart) <= 0 and SecondsTillTime(RthTradeTimeEnd) >= 0 then 1 else 0;
def activerth = if !UseRegularTrading then ActiveRthTradeTime else RegularTradingStart(GetYYYYMMDD()) - GetTime() < 0 and RegularTradingEnd(GetYYYYMMDD()) - GetTime() > 0;

def activeam = if SecondsTillTime(0700) <= 0 and
SecondsTillTime(1200) >= 0 then 1 else 0;
def activepm = if SecondsTillTime(1200) <= 0 and
SecondsTillTime(1600) >= 0 then 1 else 0;
def londonsession = if SecondsTillTime(0100) <= 0 and
SecondsTillTime(1130) >= 0 then 1 else 0;

def charth = high;
def chartl = low;
def charto = open;
def chartc = close ;

def RTHOpen = if activerth and !activerth[1] then charto else RTHOpen[1];
def pRTHOpen = if RTHOpen and !RTHOpen[1] then RTHOpen[1] else pRTHOpen[1];
def RTHClose = if !activerth and activerth[1] then chartc else RTHClose[1];
def pRTHclose = if !activerth and activerth[1] then RTHClose[1] else RTHClose[1];

def RTHamLow = if activeam and !activeam[1] then chartl
else if activeam and chartl < RTHamLow[1] then chartl else RTHamLow[1];
def RTHamhigh = if activeam and !activeam[1] then charth
else if activeam and charth > RTHamhigh[1] then charth else RTHamhigh[1];

def RTHpmLow = if activepm and !activepm[1] then chartl
else if activepm and chartl < RTHpmLow[1] then chartl else RTHpmLow[1];
def RTHpmhigh = if activepm and !activepm[1] then charth
else if activepm and charth > RTHpmhigh[1] then charth else RTHpmhigh[1];

def londonsessionHigh = if londonsession and !londonsession[1] then charth
else if londonsession and charth > londonsessionHigh[1] then charth else londonsessionHigh[1];
def londonsessionlow = if londonsession and !londonsession[1] then chartl
else if londonsession and chartl < londonsessionlow[1] then chartl else londonsessionlow[1];

def plondonsessionHigh = if londonsession and !londonsession[1] then londonsessionHigh[1] else plondonsessionHigh[1];
def plondonsessionlow = if londonsession and !londonsession[1] then londonsessionlow[1] else plondonsessionlow[1];

def RTHLow = if activerth and !activerth[1] then chartl
else if activerth and chartl < RTHLow[1] then chartl else RTHLow[1];
def pRTHLow = if activerth <> activerth[1] then RTHLow[1] else pRTHLow[1];

def RTHhigh = if activerth and !activerth[1] then charth
else if activerth and charth > RTHhigh[1] then charth else RTHhigh[1];
def pRTHhigh = if activerth <> activerth[1] then RTHhigh[1] else pRTHhigh[1];

def aRTHhigh = if !activerth and activerth[1] then charth
else if !activerth and charth > aRTHhigh[1] then charth
else aRTHhigh[1];

def aRTHLow = if !activerth and activerth[1] then chartl
else if !activerth and chartl < aRTHLow[1] then chartl
else aRTHLow[1];

def paRTHhigh = if activerth <> activerth[1] then aRTHhigh[1] else paRTHhigh[1];
def paRTHLow = if activerth <> activerth[1] then aRTHLow[1] else paRTHLow[1];
def def_ahh = if activerth then aRTHhigh else if !activerth then paRTHhigh else double.nan;

def _rth_open_close = aRTHLow +aRTHHigh +RTHOpen +pRTHOpen +RTHclose +pRTHclose ;
def p_hhllsum = _rth_open_close +pRTHLow +pRTHhigh ;
def a_hhllsum = _rth_open_close +paRTHLow +paRTHhigh ;
def hhllsum =( if activerth then p_hhllsum else a_hhllsum )+if londonsession then RTHpmLow +RTHpmhigh + plondonsessionHigh +plondonsessionlow else RTHamLow +RTHamhigh + londonsessionHigh +londonsessionlow ;

def BuySignalRthPm = hhllsum<>hhllsum[1] and hhllsum > hhllsum[1];
def SellSignalRthPm = hhllsum<>hhllsum[1] and hhllsum < hhllsum[1];

def rthhighlevel = if hhllsum<>hhllsum[1] and hhllsum> hhllsum[1] then low[1] else rthhighlevel[1];
def rthlowlevel = if hhllsum<>hhllsum[1] and hhllsum < hhllsum[1] then high[1] else rthlowlevel[1];
def brth = (close > rthhighlevel and close > rthlowlevel) or rthlowlevel > rthlowlevel[1];
def srth = ( close < rthlowlevel and close < rthhighlevel) or rthhighlevel < rthhighlevel[1] ;

def xBuysignal = ( ( brth ) or ( BuySignalRthPm )) and !(( srth ) or ( SellSignalRthPm ));
def xSellSignal = (( srth ) or ( SellSignalRthPm )) and !( ( brth ) or ( BuySignalRthPm ));

def Buysignal = xBuysignal and !xSellSignal;
def SellSignal = xSellSignal and !xBuysignal;

def SellStop = 0;
def buyStop = 0;

#######################################
## Maintain the position of trades
#######################################

def CurrentPosition; # holds whether flat = 0 long = 1 short = -1

if (BarNumber() == 1) or IsNaN(CurrentPosition[1]) {
CurrentPosition = 0;
} else {
if CurrentPosition[1] == 1 { # LONG
if (SellSignal) {
CurrentPosition = -1;
} else if (BuyStop) {
CurrentPosition = 0;
} else {
CurrentPosition = CurrentPosition[1];
}
} else if CurrentPosition[1] == -1 { # SHORT
if (BuySignal) {
CurrentPosition = 1;
} else if (SellStop) {
CurrentPosition = 0;
} else {
CurrentPosition = CurrentPosition[1];
}
} else
if CurrentPosition[1] == 0 { # FLAT

if (BuySignal) {
CurrentPosition = 1;
} else if (SellSignal) {
CurrentPosition = -1;
} else {
CurrentPosition = CurrentPosition[1];
}
} else {
CurrentPosition = CurrentPosition[1];
}
}

def isLong = if CurrentPosition == 1 then 1 else 0;
def isShort = if CurrentPosition == -1 then 1 else 0;
def isFlat = if CurrentPosition == 0 then 1 else 0;

def isOrder = if CurrentPosition == CurrentPosition[1] then 0 else 1;

def orderPrice = if (isOrder and (BuySignal or SellSignal)) then open[-1] else orderPrice[1];
plot entrylevel = orderPrice[1];
entrylevel.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
entrylevel.assignValueColor(if isLong then color.green else if isShort then color.red else color.white);

#end of script
 
Thanks for asking, currently the best setting are for NQ and ES
This is the code i got so far, it it is for a custom column, but you know what to do...

input UseRegularTrading = yes;
input RthTradeTimeStart = 0930;
input RthTradeTimeEnd = 1600;
def ActiveRthTradeTime = if SecondsTillTime(RthTradeTimeStart) <= 0 and SecondsTillTime(RthTradeTimeEnd) >= 0 then 1 else 0;
def activerth = if !UseRegularTrading then ActiveRthTradeTime else RegularTradingStart(GetYYYYMMDD()) - GetTime() < 0 and RegularTradingEnd(GetYYYYMMDD()) - GetTime() > 0;

def activeam = if SecondsTillTime(0700) <= 0 and
SecondsTillTime(1200) >= 0 then 1 else 0;
def activepm = if SecondsTillTime(1200) <= 0 and
SecondsTillTime(1600) >= 0 then 1 else 0;
def londonsession = if SecondsTillTime(0100) <= 0 and
SecondsTillTime(1130) >= 0 then 1 else 0;

def charth = high;
def chartl = low;
def charto = open;
def chartc = close ;

def RTHOpen = if activerth and !activerth[1] then charto else RTHOpen[1];
def pRTHOpen = if RTHOpen and !RTHOpen[1] then RTHOpen[1] else pRTHOpen[1];
def RTHClose = if !activerth and activerth[1] then chartc else RTHClose[1];
def pRTHclose = if !activerth and activerth[1] then RTHClose[1] else RTHClose[1];

def RTHamLow = if activeam and !activeam[1] then chartl
else if activeam and chartl < RTHamLow[1] then chartl else RTHamLow[1];
def RTHamhigh = if activeam and !activeam[1] then charth
else if activeam and charth > RTHamhigh[1] then charth else RTHamhigh[1];

def RTHpmLow = if activepm and !activepm[1] then chartl
else if activepm and chartl < RTHpmLow[1] then chartl else RTHpmLow[1];
def RTHpmhigh = if activepm and !activepm[1] then charth
else if activepm and charth > RTHpmhigh[1] then charth else RTHpmhigh[1];

def londonsessionHigh = if londonsession and !londonsession[1] then charth
else if londonsession and charth > londonsessionHigh[1] then charth else londonsessionHigh[1];
def londonsessionlow = if londonsession and !londonsession[1] then chartl
else if londonsession and chartl < londonsessionlow[1] then chartl else londonsessionlow[1];

def plondonsessionHigh = if londonsession and !londonsession[1] then londonsessionHigh[1] else plondonsessionHigh[1];
def plondonsessionlow = if londonsession and !londonsession[1] then londonsessionlow[1] else plondonsessionlow[1];

def RTHLow = if activerth and !activerth[1] then chartl
else if activerth and chartl < RTHLow[1] then chartl else RTHLow[1];
def pRTHLow = if activerth <> activerth[1] then RTHLow[1] else pRTHLow[1];

def RTHhigh = if activerth and !activerth[1] then charth
else if activerth and charth > RTHhigh[1] then charth else RTHhigh[1];
def pRTHhigh = if activerth <> activerth[1] then RTHhigh[1] else pRTHhigh[1];

def aRTHhigh = if !activerth and activerth[1] then charth
else if !activerth and charth > aRTHhigh[1] then charth
else aRTHhigh[1];

def aRTHLow = if !activerth and activerth[1] then chartl
else if !activerth and chartl < aRTHLow[1] then chartl
else aRTHLow[1];

def paRTHhigh = if activerth <> activerth[1] then aRTHhigh[1] else paRTHhigh[1];
def paRTHLow = if activerth <> activerth[1] then aRTHLow[1] else paRTHLow[1];
def def_ahh = if activerth then aRTHhigh else if !activerth then paRTHhigh else double.nan;

def _rth_open_close = aRTHLow +aRTHHigh +RTHOpen +pRTHOpen +RTHclose +pRTHclose ;
def p_hhllsum = _rth_open_close +pRTHLow +pRTHhigh ;
def a_hhllsum = _rth_open_close +paRTHLow +paRTHhigh ;
def hhllsum =( if activerth then p_hhllsum else a_hhllsum )+if londonsession then RTHpmLow +RTHpmhigh + plondonsessionHigh +plondonsessionlow else RTHamLow +RTHamhigh + londonsessionHigh +londonsessionlow ;

def BuySignalRthPm = hhllsum<>hhllsum[1] and hhllsum > hhllsum[1];
def SellSignalRthPm = hhllsum<>hhllsum[1] and hhllsum < hhllsum[1];

def rthhighlevel = if hhllsum<>hhllsum[1] and hhllsum> hhllsum[1] then low[1] else rthhighlevel[1];
def rthlowlevel = if hhllsum<>hhllsum[1] and hhllsum < hhllsum[1] then high[1] else rthlowlevel[1];
def brth = (close > rthhighlevel and close > rthlowlevel) or rthlowlevel > rthlowlevel[1];
def srth = ( close < rthlowlevel and close < rthhighlevel) or rthhighlevel < rthhighlevel[1] ;

def xBuysignal = ( ( brth ) or ( BuySignalRthPm )) and !(( srth ) or ( SellSignalRthPm ));
def xSellSignal = (( srth ) or ( SellSignalRthPm )) and !( ( brth ) or ( BuySignalRthPm ));

def Buysignal = xBuysignal and !xSellSignal;
def SellSignal = xSellSignal and !xBuysignal;

def SellStop = 0;
def buyStop = 0;

#######################################
## Maintain the position of trades
#######################################

def CurrentPosition; # holds whether flat = 0 long = 1 short = -1

if (BarNumber() == 1) or IsNaN(CurrentPosition[1]) {
CurrentPosition = 0;
} else {
if CurrentPosition[1] == 1 { # LONG
if (SellSignal) {
CurrentPosition = -1;
} else if (BuyStop) {
CurrentPosition = 0;
} else {
CurrentPosition = CurrentPosition[1];
}
} else if CurrentPosition[1] == -1 { # SHORT
if (BuySignal) {
CurrentPosition = 1;
} else if (SellStop) {
CurrentPosition = 0;
} else {
CurrentPosition = CurrentPosition[1];
}
} else
if CurrentPosition[1] == 0 { # FLAT

if (BuySignal) {
CurrentPosition = 1;
} else if (SellSignal) {
CurrentPosition = -1;
} else {
CurrentPosition = CurrentPosition[1];
}
} else {
CurrentPosition = CurrentPosition[1];
}
}

def isLong = if CurrentPosition == 1 then 1 else 0;
def isShort = if CurrentPosition == -1 then 1 else 0;
def isFlat = if CurrentPosition == 0 then 1 else 0;

def isOrder = if CurrentPosition == CurrentPosition[1] then 0 else 1;

def orderPrice = if (isOrder and (BuySignal or SellSignal)) then open[-1] else orderPrice[1];
plot entrylevel = orderPrice[1];
entrylevel.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
entrylevel.assignValueColor(if isLong then color.green else if isShort then color.red else color.white);

#end of script

if you change the plot to this,
plot entrylevel = if orderPrice[1] > 0 then orderPrice[1] else na;
then it won't plot lines at 0, on the first couple of bars.

i see some horizontal lines, but not sure what i am supposed to do with them.
 
Last edited:
if you change the plot to this,
plot entrylevel = if orderPrice[1] > 0 then orderPrice[1] else na;
then it won't plot lines at 0, on the first couple of bars.

i see some horizontal lines, but not sure what i am supposed to do with them.
Thanks for the input. now it's all matching.


AD_4nXdECrJhR4cvf3GnhO7BS4zwn4jcshxxWPN4j9DACgAvkv_gybwtU_si7oA5NnpsOk5SlhZGX9A-1bWaBMQdxbvvnC_-tZtBeOVpL_A6eDsjMQIn5Mk1nZLcEHND9h9oVX5E3lBVQo6xVRE9bwm0uuPXfbY
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
434 Online
Create Post

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