Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

loop search for horizontal hand drawn lines by color --- what am I doing wrong ??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    loop search for horizontal hand drawn lines by color --- what am I doing wrong ??

    Hello,

    The code below finds the hand drawn horizontal lines, and the correct price...but it is not matching on the brush color!!! (black or cyan)

    Anyone?


    foreach (DrawingTool draw in DrawObjects.ToList())
    {
    // select User Drawn Horizontal or Ray Lines
    if (draw.IsUserDrawn)
    {

    if (draw is DrawingTools.HorizontalLine)
    {
    DrawingTools.HorizontalLine thisLine = draw as DrawingTools.HorizontalLine;

    Print ("Horizontal Line Found " + thisLine.StartAnchor.Price.ToString() + " ..... " + thisLine.Stroke.Brush.ToString() + " ..... " + Brushes.Cyan.ToString() + " ..... " + Brushes.Black.ToString());

    if (thisLine.Stroke.Brush == Brushes.Black)
    Print ("Matches BLACK");
    if (thisLine.Stroke.Brush == Brushes.Cyan)
    Print ("Matches CYAN");
    )
    )
    )​

    #2
    well, it is not pretty, but changing the Brush to a string and then comparing them works


    private string thisColor;
    private string myBlack = Brushes.Black.ToString();
    private string myCyan = Brushes.Cyan.ToString();



    DrawingTools.HorizontalLine thisLine = draw as DrawingTools.HorizontalLine;

    thisColor = thisLine.Stroke.Brush.ToString();

    if (thisColor == myBlack)
    Print ("Matches BLACK");

    if (thisColor == myCyan())
    Print ("Matches CYAN");

    if (thisColor == myBlack || thisColor == myCyan)


    I really don't believe it has to be this convoluted...isn't there a more elegant way to compare two brushes/color?
    .
    (it works so unless I get a better answer will leave it that way)

    Comment


      #3
      Hello llanqui,

      What you have done is correct, brushes cannot be compared by using == you would have to get the brushes name and compare that instead which you are doing.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      156 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      90 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      140 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      130 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X