Jump to content
Medved Trader Forums

Access data in a paintbar external to current symbol?


Recommended Posts

Is there any way at all that I could access data from one symbol within paintbar code that's being used as an indicator in another symbol? Let's say that I have an indicator that I want to trigger an alert but only when the SPY is moving or down. Or that I am interested is measuring the percentage of change (up or down) since open of one symbol against the change of another symbol. Is this possible? I would think it would be since it's possible to plot one symbol, as a comparison indicator, on top of the chart of another symbol.

Thanks!

Link to comment
Share on other sites

I can reference it but scaling issues arise. Specifically, what I wanted to be able to do is have something like the SPY plotted, as a secondary symbol, on the same chart as the main symbol and then measure, in code, the distance (probably best measured in units of the main symbol) between where the lines are drawn for each symbol on the chart at each candlestick. Although I don't NEED to have this depicted precisely on the chart (I haven't been able to get, for example, the SPY as a simple comparison indicator, plotted properly as a secondary symbol). I thought a practical approach to this might be to access the percentage of change since open of the secondary symbol so that it could be compared to the percentage of change since open of the main symbol. The idea is to track the relative strength of one symbol against another, whether it's an index or regular stock. This way you could measure the correlation or divergence between the two throughout the trading session. It's also occurred to me that beta could be used to achieve something approximate to this but I don't see any quick access to that in MT and calculating something like that in paintbar code would still require access to data from both symbols, would require mathematics that could get very complicated very quickly and would be a very hacky way to approach the problem..

Link to comment
Share on other sites

Jason, all that stuff can be done using the advanced code with tracking session-variables as we did in other examples on this forum before.

You can look at session info, any time you get new session, record the price as "open" (for both the core symbol and compare-to symbol), then for all subsequent values you can get percentage from open as    (Close-SessionOpen)*100/SessionOpen, and compare them.  Same with session high/lows - we discussed this before.

Link to comment
Share on other sites

Yeah, after posting it occurred to me that I could manually calculate the percentages. I'd still want to fish for a more direct way to access other symbol data. Using the second symbol as an "indicator" and running any calculations manually is a simple but roundabout way of dealing with it that wasn't obvious to me. Thanks for the help.

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