You aren't testing for CurrentBar > 1 first. If you check the Log, it will tell you as much.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
(1) For the first bar of your chart, which is CurrentBar = 0, you cannot access Close or Open, because it does not exist. Therefore, you need insert a line in the beginning of OnBarUpdate()
(2) There are bars that have a zero range when high = low. In that case you will run into a division by zero problem, which you need to exclude.
(3) Rather than using the Plot method to place a dot above or below the current bar, I would use the NinjaScript method DrawDot(), which allows you draw a margin above the high or below the low. If you use the Plot method, you may get unwanted dots, even if you have set no values to the plot.
The following user says Thank You to Fat Tails for this post: