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