could somebody suggest a quick fix? the code below is meant to test random entry/exit. it buys when rand(1,100)<=50, the position is exited when rand(1,100)>50. the random number needs to be generated at least once per day. entries/exits occur at five minutes before EOD.
i think the entries are random but my exits won't cooperate. the script either exits after 79 bars (SPY, 5-min bars used for testing) or not at all. it should exit as soon as the correct random number is generated.
also, how could i put the random numbers on the 5-min chart of SPY?
any help is appreciated!
CODE:
Please log in to see this code.