I am trying to code a strategy takes trades based off touching a level 2 times.
so first, i determine the level i want, then i check if the current bar has touched the level or not, if it did
then i wait for the current candle to close first, then i place the order, so technically, the trade has to be taken
on the second retest of a level.
some context for what you see on the chart :" eventually i want to test the strategy on both green line and red line, each being a level ( high level, low level ) relative to a candle (the diamond in this case). for the purpose of debugging, i am limiting my algorithm to handle just one level at the moment which is the low level (green line).
so as you can see on the chart, the first bar where the algorithm starts, the bar does not touch the green line, so all good, the next bar touches, we can confirm it did based off the logs, so all is good, we know now that the green level is tested we set that to true, now we have qualified a trade, the next candle that touches this level, needs to place a trade, that next candle is the one at 22:15 where my cursor is on the chart, however as you can see the trade is not taken, it is rather taken at the next one ..
i have refactored my code a dozen time to debug this, this is the simplest way i have come up with, the issue seems to arise from the EnterLongLimit method(), not that I am blaming the method, of course it is me who's missing something, if anyone can elaborate on what am I doing wrong, much appreciate the help in advance !!
here's a snippet of the script i have written, i can include more if needed.
: "
"
logs:

Comment