Jason Posted July 28, 2018 Report Share Posted July 28, 2018 I am trying to write paintbar code for a scan which would alert given conditions such as the high of the day is equal to the high of the first 5 minute candlestick in the chart or that the low of the day was reached by the previous candlestick, etc.. How would I accomplish this? I am assuming I would need state keeping to do this since the high/low of the day would need to be retained for each new paintbar calculation but I have tried using CurrentState and SymbolData as a test without any success. Is there a better way? Thanks! Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted July 29, 2018 Report Share Posted July 29, 2018 SymbolData.High and SymbolData.Low is high or low of the day. The first 5 minute high/low is something that you would need to calculate yourself - basically make the variables in the advanced code (outside the functions) that would hold the high/low, then in the code check if current timestamp is within first five minutes of the session and set the high/lows accordingly... If that is not clear I could post some code here for you. Quote Link to comment Share on other sites More sharing options...
Jason Posted July 29, 2018 Author Report Share Posted July 29, 2018 (edited) Okay, just to begin with a simple test case I tried: public void MainCalculation() { if (High == SymbolData.High) { SetColor("High", SysColor.MainIndicator3); return; } } on a 5 minute chart but it doesn't highlight the candlestick with the high. I suspect there's something about the how it's calculated that I don't understand. According to this I'm expecting that the paintbar will iterate through each candlestick in the chart in sequence comparing the high of that candlestick to the high of the day. Edited July 29, 2018 by Jason Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted July 29, 2018 Report Share Posted July 29, 2018 Show me the code you're using. Should be something like this (if it's a paintbar) if (High == SymbolData.High) { SetColor(Green); } or use SetScanResult for a scan. Quote Link to comment Share on other sites More sharing options...
Jason Posted July 29, 2018 Author Report Share Posted July 29, 2018 9 minutes ago, Jason said: public void MainCalculation() { if (High == SymbolData.High) { SetColor("High", SysColor.MainIndicator3); return; } } Sorry, just edited the post Quote Link to comment Share on other sites More sharing options...
Jason Posted July 31, 2018 Author Report Share Posted July 31, 2018 The code I was trying is almost identical to yours but nothing is drawn on the chart. I'm out of ideas for what I could be doing wrong. Quote Link to comment Share on other sites More sharing options...
Jason Posted August 2, 2018 Author Report Share Posted August 2, 2018 Actually, nevermind. It's working now. Thought at first it was because I hadn't added the state-keeping code to one of the test paintbars I had created but now when I try it with and without state-keeping it's working. Don't know why though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.