NexusFi: Find Your Edge


Home Menu

 





SC Custom Menu Items


Discussion in Sierra Chart

Updated
    1. trending_up 1,394 views
    2. thumb_up 9 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

SC Custom Menu Items

  #1 (permalink)
 
josh's Avatar
 josh 
Georgia, US
Legendary Market Wizard
 
Experience: None
Platform: SC
Broker: Denali+Rithmic
Trading: ES, NQ, YM
Posts: 6,245 since Jan 2011
Thanks Given: 6,781
Thanks Received: 18,250

In this thread, a generous user contributed some code that takes advantage of Sierra's new ACS functionality which allows catching mouse events when a custom button is pressed.

The thing is, I hate toolbars, particularly those in Sierra. So, I decided to implement what I needed as a menu. Basically, I wanted a way to hide/show 2 or more studies at the same time. The region data line right-click show/hide menu in SC is helpful but it only shows/hides one study at a time, and if you are using several to implement shading, etc., then you may have 5 or more that need to all work together. So, this was the reason to explore this option.

Here is the SC documentation. It is not scary, and is pretty easy to understand. I encourage you to read it. The relevant section is the first one, though the subsequent sections are related:
Advanced Custom Study Interaction With Menus, ToolBar Buttons, Mouse Pointer Events - Sierra Chart

The first code block on that page really tells the story. You use a persistent variable, and add a menu item. Do this for as many menu items as you need. Then, you listen for a menu click and if it's the particular one you want, then you perform some action. Here is my code block for the "VWAP RTH" menu item:

 
Code
if (sc.MenuEventID != 0 && sc.MenuEventID == MenuID1)
{
		sc.SetStudyVisibilityState(CH01_STDY_01, t);
		sc.SetStudyVisibilityState(CH01_STDY_02, f);
		sc.SetStudyVisibilityState(CH01_STDY_03, f);
		sc.SetStudyVisibilityState(CH01_STDY_04, f);
		sc.SetStudyVisibilityState(CH01_STDY_05, f);
		sc.SetStudyVisibilityState(CH01_STDY_06, f);
		sc.SetStudyVisibilityState(CH01_STDY_07, f);
		sc.SetStudyVisibilityState(CH01_STDY_08, f);
}
I use #define at the top to define CH01_STDY_ZZ as study numbers in my chart that I want to hide or show. You could take these as input variables but I prefer just to put them in the code as it's easy to change if using a #define or variable. So I have

 
Code
#define CH01_STDY_01 4
...
#define t 0
"4" is the study ID of a study I will want to hide or show. In this case it's the RTH VWAP. 2-8 are the ETH VWAP, SD bands, and shading studies. For some reason in the SetStudyVisibilityState(num, state) function, 0 appears to set the study visible and 1 makes it invisible, so I am able to quickly change true and false if SC changes this by using the #define at the top.

As the SC documentation mentions in the 2nd section and as shown in the code block, you need to remove whatever menu items you are not using when the study unloads.

That's it! Just use this to hide/show whatever study you like! If I can answer any questions I'll be happy to. The best thing to do is fire up the CPP editor in Sierra and give it a go. For a single menu item the code shouldn't be more than 30 or 40 lines long, it is very simple, as shown above.


Started this thread Reply With Quote




Last Updated on April 8, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts