Jump to content
Medved Trader Forums

High crosses above previous days high


Recommended Posts

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.

image.png.19e5dfbacd028b18bf1358417698ef88.png

If I try to use the CurrentDailyHigh instead of the TodayHigh var, I get an error message.

image.thumb.png.212b38bc0e27d0243714b27448b4018b.png

If anyone has any suggestions I'd be appreciative.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

image.thumb.png.6d752aee44b55883f11f58dbb0f233fa.png

image.thumb.png.3b96203e60591d4444e98498bec52516.png

 

image.png.8c822c45fad7adb3fdf319c8f71c95f6.png


code didn't post, so attaching as a screenshot

 

image.thumb.png.2822b66215cbf4455c66c65f0ee1b9b7.png

Link to comment
Share on other sites

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.   :(
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...