nasdorq Posted December 29, 2022 Report Share Posted December 29, 2022 This seems like a simple paintbar, but I'm somehow stuck on this. If todays high crosses above the previous days high, trigger alert. Naturally this could only trigger once per session. I'm using the Horizonal Line indicator for the Vars, such as below. If I try to use the CurrentDailyHigh instead of the TodayHigh var, I get an error message. If anyone has any suggestions I'd be appreciative. Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted December 29, 2022 Report Share Posted December 29, 2022 CrossesUp is a special MT function for use with array type variables, bid. Ask last. Today's high and previous high are not array variables. We don't keep the history. If you want to trigger specifically when it crosses, then you would need to keep track of the previous value for those yourself using the state mechanisms Quote Link to comment Share on other sites More sharing options...
nasdorq Posted December 30, 2022 Author Report Share Posted December 30, 2022 Is there a way to get the high of the current day on a bar by bar basis? Then I could have a line where "if todays high (1 bar ago) is less than yesterdays high, and todays high (current bar) is greater than yesterdays high, then triggeralert" Unfortunately the state keeping is a bit over my head. In my example using the horizontal line TodayHigh, I was hoping TodayHigh[1] would work as it's the intraday setting, though it seems to fetch the previous days high. If I can get this working, I can then use it as a template for other paintbars like crossing yesterdays low, red to green, green to red, breaking opening range, etc. Quote Link to comment Share on other sites More sharing options...
nasdorq Posted December 30, 2022 Author Report Share Posted December 30, 2022 the goal looking for the current day's high crossing above yesterdays high, is that I could limit the alert to the first time it happens. Otherwise, just looking for anytime price is above yesterdays high, it would trigger repeatedly throughout the session. Quote Link to comment Share on other sites More sharing options...
nasdorq Posted January 2 Author Report Share Posted January 2 I managed to cobble something together from looking at other state keeping posts in the forum. It works for the most part, though there's one small error I can't seem to solve. I attached a picture of of it on the NQH23 and QQQ. Red horizontal lines are previous days high. Green background is the current bar crossing above the previous days high. It works on the QQQ. but on NQ, sometimes the paintbar triggers on the opening bar, even though it isn't crossing the previous day high. I've circled them in blue. The 29th it even triggers twice in the same session. If anyone has any suggestions I'd love to hear. Happy new year! code didn't post, so attaching as a screenshot Quote Link to comment Share on other sites More sharing options...
Donald Q. Posted January 3 Report Share Posted January 3 For good measure, initialize AboveHigh and BelowHigh to a known value (i.e., -1) in order to avoid situations where those variables reference 0 or 1 unexpectedly. Quote Link to comment Share on other sites More sharing options...
nasdorq Posted January 3 Author Report Share Posted January 3 Thank you for the reply Don. Under private struct PaintbarState I have: public int AboveHigh; public int Below High; Do you mean edit those so they both have the value -1? Unfortunately I'm over my head with this stuff, so I'm not sure how to initialize something, what it would look like or where to put it. 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.