# G_AL_PriceDrop. # The goal is to have an alert for a percentage drop in price from yesterday’s close that I can execute at night and have the alert work the next day. # ALERT TRIGGER 1. # Inputs. input AlertPriceDrop = 0.02 ; # 2% price drop from yesterday’s close. # Test for today’s low being greater than 2% (AlertPriceDrop) lower than yesterday’s close. # Define yesterday’s closing price and today's low price. def ydayClose = close [1] ; def tdayLow = low ; # Define the condition to alert. def PriceDrop = tdayLow < (1 - AlertPriceDrop) * ydayClose ; # If I implement this alert trigger 1 tonight so that it will be ready to test tomorrow’s numbers, of course that isn’t what happens; I get an immediate alert based on this day’s low and yesterday’s close. So, it appears that I need to add a time element so the alert only happens during the hours I pick. # ALERT TRIGGER 2. # Inputs. input AlertStartTime = 940 ; # 9:40 AM Eastern Time; I’m Pacific Time; Assuming TOS using Eastern. input AlertStopTime = 1600 ; # 4:00 PM. # Test that the time of day is between the input hours selected. # Current time (HHMM format??). def currentTime = GetTime ( ) ; # Assuming GetTime is in same format as the other times? # Define start time and stop time conditions for the alert to work. def AlertStart = currentTime >= AlertStartTime ; #Couldn’t I skip currentTime and just use GetTime? def AlertStop = currentTime <= AlertStopTime ; # Define the alert period by combining the conditions. def AlertPeriod = AlertStart AND AlertStop ; # This trigger 2 doesn’t work. It still gives me an alert outside of the “AlertPeriod”. Why? # PLOT THE ALERT; Plot ActivateAlert = PriceDrop AND AlertPeriod ; Alert ( ActivateAlert, “Large Price Drop”, Alert.ONCE, Sound.BELL ) ;