Jason Posted July 22, 2019 Report Posted July 22, 2019 (edited) Trying to determine how I can specify in code the color of the paintbar? I can select the color manually in the Parameters box but I want to be able to control the color from within the code for testing purposes and customization of colors when different conditions are met within the same paintbar. For example, multiple IF conditions each with a separate color... In one of the paintbars I created I can see 0xFF9399FF set within SetColorAndShape but I'm unfamiliar with this number format can't investigate further. Thanks Edited July 22, 2019 by Jason Quote
Mike Medved Posted July 22, 2019 Report Posted July 22, 2019 There are three ways to specify a color. 1. Color.something - like Color.Black, Color.White, Color.Lime etc. - these are absolute colors. 2. SysColor.something - like SysColor.Positive, SysColor.Bid, SysColor.MainIndicator1 - these colors are taken from the current chart's color scheme. 3. the hex format. 0xFF9399FF - the first FF is transparency, just always leave it FF. 93 is the red component, 99 is green, FF is blue. So this color would be a bluish gray. FF is max, so the 0xFF9399FF is a lightish blue. See https://www.color-hex.com/ your 0xFF9399FF would be equivalent to #9399FF there. Quote
Jerry Medved Posted July 23, 2019 Report Posted July 23, 2019 one more thing - note that you don't have to figure out the colors. We Have the Color INSERT button on the toolbar of the Advanced Editor. put the cursor in the code where you want the color code to go, click on the INSERT button for the color palette, select the color, done. Quote
Jason Posted July 23, 2019 Author Report Posted July 23, 2019 Nice, thank you! The transparency component was throwing me off there. But I am having another problem. When I specify a color in code it does not have an effect. The colors seem to have a life of their own or are locked to whatever colors are selected by default or otherwise in the Parameters box. How can I reset them or make them subordinate to what I've in code? For example, I'm using this: SetColorAndShape("INHAMMER", PBShape.Fill, Color.Purple ); TriggerAlert("test!", @"test."); SetScanResult(@"test"); And the paintbar as drawn is showing up Red. Quote
Jerry Medved Posted July 23, 2019 Report Posted July 23, 2019 if you name a color, then the value you specify in the code is just the default and overriden when it is actually used on the chart. Remove the naming parameter. SetColorAndShape(PBShape.Fill, Color.Purple ); Quote
Jason Posted July 24, 2019 Author Report Posted July 24, 2019 When I try this after deleting the name parameter using: SetColorAndShape(PBShape.Fill, Color.Purple ); I get 3 errors: Pos Code Description 29, 9 CS1502 The best overloaded method match for 'MT.Charting.PaintbarBase.SetColorAndShape(string, MT.Charting.PaintbarBase.PBShape, MT.Charting.PaintbarBase.SysColor)' has some invalid arguments 29, 26 CS1503 Argument 1: cannot convert from 'MT.Charting.PaintbarBase.PBShape' to 'string' 29, 40 CS1503 Argument 2: cannot convert from 'System.Drawing.Color' to 'MT.Charting.PaintbarBase.PBShape' Quote
Jerry Medved Posted July 24, 2019 Report Posted July 24, 2019 oops, sorry, should be: SetColorAndShape(Color.Purple, PBShape.Fill); Quote
Jason Posted July 24, 2019 Author Report Posted July 24, 2019 Yes THAT works much better! Never would have thought to switch them around like that. Thanks Quote
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.