Jump to content
Medved Trader Forums
Sign in to follow this  
Jason

How to access high of the day for comparisons?

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by Jason

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
9 minutes ago, Jason said:


 

 

public void MainCalculation() { if (High == SymbolData.High) { SetColor("High", SysColor.MainIndicator3); return; } }

Sorry, just edited the post

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...