Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
What color is the candle?
Collapse
X
-
What color is the candle?
I have a custom indicator that paints the bar with one of several brushes and I need to be able to determine which one of them was used.. Of course, it's a simple matter to just look at it and see, but I want to use this information in a Strategy and need a way to extract the hex value of the brush that was used. It appears that the gdi32 GetPixel DllImport should do the job, but I'm unable to obtain the proper color using this approach. Please show me the proper method required to obtain this pixel value.Tags: None
-
I realized that I was a bit short on detail when posting the problem, so here is the code:
SharpDX.Direct2D1.SolidColorBrush SharpDXRedBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Red);
RenderTarget.FillRectangle(new SharpDX.RectangleF(BoxStartX, y, BoxWidth, BoxHeight), SharpDXRedBrush);
uint pixel = GetPixel((BoxStartX + BoxWidth)/2, (y + BoxHeight)/2);
Print("Center of Top rectangle " + ((pixel >> 16) & 0xFF) + " " + ((pixel >> 8) & 0xFF) + " " + (pixel & 0xFF));
and this was the output: "Center of Top Rectangle 213 141 64" which is sort of gray and the actually displayed rectangle is Red as should be
-
Is the custom indicator something you built or something you have source code for? If so, why not store the information you need in a more computer friendly format? The indicator could store a Series<T>, perhaps an enum.
Code:public enum BarColor { ColorOne, ColorTwo, ColorThree } public class SomeIndicator { public Series<BarColor> BarColor { get; private set; } }
I would suggest going one step further and changing the enum to represent the actual meanings behind the color instead of the color itself.
Comment
-
No, I only have access to the visual data that is displayed for the indicator and know only that one of several brushes was used to paint the bar. That is why I'm trying to access the data in this roundabout method. Why is the data not available? In the code example snippet above, you can see that I successfully created a red rectangle and when I attempt to access one of the pixels inside the rectangle with GetBit, it returns a completely different value than what I just created at that point, so the data that was just created on the display is not accessible on the canvas immediately after it is created.
Comment
-
Did you attach a debugger and look at the indicator? Perhaps you can use reflection to access the underlying data the indicator might be using when it determines how to color the chart. Its a shame the designers of the indicator didn't make the indicator more then just a visual presentation.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by adeelshahzad, Today, 03:54 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 09:43 AM | ||
Started by yertle, Today, 08:38 AM
|
4 responses
13 views
0 likes
|
Last Post
by yertle
Today, 09:38 AM
|
||
Started by bill2023, Yesterday, 08:51 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 09:37 AM | ||
Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
|
80 responses
19,667 views
5 likes
|
Last Post Today, 09:29 AM | ||
Started by dappa, Today, 09:18 AM
|
1 response
6 views
0 likes
|
Last Post Today, 09:25 AM |
Comment