Help with plotting lines and label for SPX/ES based on RTH/ETH sessions.

tradegeek

Active member
2019 Donor
VIP
I had this working when it was a little simpler. Now that I've added other things, it's no longer plotting the lines or the label. Hopefully, someone with more experience will be able to help me out.

I'm trying to plot three lines (high, low, close) that are inputted manually at the beginning of the RTH and ETH sessions for SPX or ES futures. I also want to add a cloud around those three line plots. Depending on which symbol (SPX or ES) the chart is showing and which session is currently trading (RTH or ETH), I want the label to show the info specific to the symbol and the current session.

Code:
#
# Predicted High Low Close for RTH and ETH sessions #                                                   
# These levels are inputed manually and is only valid
# for the specified period!
#                                                                       
                                                                      
                    
def na = Double.NaN;
def timeStrRTH = (SecondsFromTime(930) > 0) and (SecondsFromTime(1700) < 0);
def timeStrETH = ((1700) > 0) and (SecondsFromTime(930) < 0);

input AlgoHigh = 2801;
input AlgoLow = 2689;
input AlgoClose = 2743;
input AlgoHighETH = 2801;
input AlgoLowETH = 2689;
input AlgoCloseETH = 2743;
input diff = 12;
input MarginErrorHigh = 10;
input MarginErrorLow = 14.5;
input MarginErrorClose = 0;

def AHRTH = AlgoHigh - diff;
def ALRTH = AlgoLow - diff;
def ACRTH = AlgoClose - diff;
def AHETH = AlgoHighETH - diff;
def ALETH = AlgoLowETH - diff;
def ACETH = AlgoCloseETH - diff;

plot AH;
plot AL;
plot AC;

if  GetSymbol() == "/ES:XCME" {
    AH = if timeStrRTH then AHRTH else if timeStrETH then AHETH else na ;
    AL = if timeStrRTH then ALRTH else if timeStrETH then ALETH else na ;
    AC = if timeStrRTH then ACRTH else if timeStrETH then ACETH else na ;
} else

if  GetSymbol() == "SPX" {
    AH = if timeStrRTH then AlgoHigh else na ;
    AL = if timeStrRTH then AlgoLow else na ;
    AC = if timeStrRTH then AlgoClose else na ;
} else  {
    AH = na;
    AL = na;
    AC = na;

}

def upperAH = AH + (MarginErrorHigh/2);
def lowerAH = AH - (MarginErrorHigh/2);
def upperAL = AL + (MarginErrorLow/2);
def lowerAL = AL - (MarginErrorLow/2);
def upperAC = AC + (MarginErrorClose/2);
def lowerAC = AC - (MarginErrorClose/2);

AddCloud(upperAH, lowerAH, Color.LIGHT_RED);
AddCloud(upperAL, lowerAL, Color.LIGHT_GREEN);
AddCloud(upperAC, lowerAC, Color.light_ORANGE);

AH.SetDefaultColor(Color.RED);
AH.SetLineWeight(2);

AL.SetDefaultColor(Color.GREEN);
AL.SetLineWeight(2);

AC.SetDefaultColor(Color.ORANGE);
AC.SetLineWeight(2);

AddLabel(GetSymbolPart()== "SPX", "Algo High: " + AH, Color.RED);
AddLabel(GetSymbol()== "SPX" and timeStrRTH, "Algo Low: " + AlgoLow, Color.GREEN);
AddLabel(GetSymbol()== "SPX" and timeStrRTH, "Algo Close: " + AlgoClose, Color.ORANGE);

AddLabel(GetSymbol()== "SPX" and timeStrETH, "Algo High: " + AlgoHighETH, Color.RED);
AddLabel(GetSymbol()== "SPX" and timeStrETH, "Algo Low: " + AlgoLowETH, Color.GREEN);
AddLabel(GetSymbol()== "SPX" and timeStrETH, "Algo Close: " + AlgoCloseETH, Color.ORANGE);
                                  
AddLabel(GetSymbolPart()== "/ES:XCME" and timeStrRTH, "Algo Low: " + ALRTH, Color.GREEN);
AddLabel(GetSymbol()== "/ES:XCME" and timeStrRTH, "Algo Close: " + ACRTH, Color.ORANGE);

AddLabel(GetSymbol()== "/ES:XCME" and timeStrETH, "Algo High: " + AHETH, Color.RED);
AddLabel(GetSymbol()== "/ES:XCME" and timeStrETH, "Algo Low: " + ALETH, Color.GREEN);
AddLabel(GetSymbol()== "/ES:XCME" and timeStrETH, "Algo Close: " + ACETH, Color.ORANGE);
 

Similar threads

Top