I have tried to make this as clear as possible with what is going on. Also written is an explanation of what the strategy is supposed to do so that you are not just blindly trying to figure it out. Please let me know if you have any questions or if I just did not make it clear enough. Any help is really appreciated!

I have attached the script file in order to save on the number of words posted.
When lines #109 & #126 are commented out, all of the draw objects draw correctly. When they are not commented out, that is where I start running into issues.
These two lines are exactly the same except that one is for longs and the other is for shorts
In the section for TrendDirection.Up (Line #119), when the LongEntry (Line #109) is uncommented, the draw objects will draw correctly until a long trade is placed. As soon as that happens, no more draw objects will be drawn. The Output Window says,
Would somebody be willing to take a look at this and see if this is, in fact, where my problem is and let me know what I could to fix it?
Maybe you want a bit of an idea of what this code is supposed to do.
In its current form, it is supposed to find a range (between 2:00 am and 9:00 am). With that range it is supposed to find the highest bar and the lowest bar and take note of the High and Low respectively. When it finds the high, for example, and the TrendDirection is Up, then it is supposed to place a EnterLongStop order x pips above that high and x pips below the low of the range. It is then supposed to place a SellLimit order above the Entry Order. If the Entry Order is not triggered by a particular time (22:00) then it is to be cancelled.
It is only supposed to take one trade per day, therefore a flag was created (restrictTrade). When the Entry Order is triggered then the flag is to be set to true, thus not allowing any more trading to happen for that day. Then, on the next day, during the range then the flag is changed back to false in order to allow trading. (I have tried various combinations of this flag to see if it is causing the problem, but it does not appear to be the issue).
If you have any more questions, feel free to ask me. Thank you in advance for any help that anyone is able to give.

Comment