What I've been trying to do is create a rule that enters a long position if the open of 4 candles ago is less than or equal to the close of 1 candle ago plus a gap of 2%. The way this looks is: Open[4] <= (Close[1]) * (1 + 0.02) ... and the same reverse rule for shorting -- which is coded the same, just reversed (>=) of course.
In addition to this, it can only enter the trade if the current candle is 9:35 AM. I have the time part coded right, but the entries are just out of whack. What I am trying to accomplish with this is to go long (or short) if at 9:35 the price is 2.5% higher (or lower) than the opening price at 9:30. Pretty straight forward, I thought.
How would I code this? Some of the entries look correct from a directional standpoint, but they aren't always following the 2% rule, and some entries are completely wrong -- going LONG when the 9:35 price is clearly lower than the 9:30 price (and vice versa for shorts).
If anyone could help me out and show me what conditions I need to select to create the proper entry rules for long and short that'd be much appreciated.
Thanks!



Comment