I am having an issue that doesn't make sense to me. I already wrote this strategy as an indicator and it works perfectly.
I now have the code moved into a strategy, however, some peculiar results are showing up.
I have two variables that I use to prevent "double" entries from being taken (entries taken *right* after a profit/stop gets filled). In essence, I only take one trade in one direction and then wait for a trade in the opposite direction to "reset" possible entries in the first direction.
Here is what it looks like in the strategy:
if (criteria1 and criteria2 and OKForLong) { EnterLong(1); OKForLong = false; OKForShort = true; } if (criteria3 and criteria4 and OKForShort) { EnterShort(1); OKForShort = false; OKForLong = true; }
This code works perfectly in the indicator but generates NO orders in the strategy. (the indicator places arrows/text on the bars on the chart instead of enter() orders)
NOW ... when I take out the OKForLong/Short out of the if() statements, all of the correct trade entries get generated (including the double entries of course). BUT ... with them in, no trades at all.
This tells me that these two variables are not getting reset.
Couple of things:
1) These variables are global scope to the strategy
2) They are reset to true when ToDay(Times[1][0]) != ToDay(Times[1][1]) (A new day starts in the second data series on which my indicator/strategy is driven).
Any ideas?
Thanks!
Comment