Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detect Chart Type

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

    Detect Chart Type

    I'm trying to get my strategy to detect what chart type is being used.

    I finally got this to compile, but it doesn't work.

    Code:
    if (CurrentBar > 1)
    {
    if (BarsArray[0].BarsPeriod.BarsPeriodType != BarsPeriodType.PointAndFigure)
    {
    throw new Exception("This strategy requires a Point and Figure chart. Please apply it to a PnF chart.");
    }
    }

    Any help is appreciated.

    #2
    I have tried:

    string myType = BarsArray[0].BarsPeriod.BarsPeriodType.ToString();
    Print("myType: " + myType);

    if (BarsArray[0].BarsPeriod.BarsPeriodType != BarsPeriodType.PointAndFigure)
    {
    Print(String.Format("You chose {0}. You need BarsPeriodType.PointAndFigure.", myType));
    }​

    and that seems to work for me. Output:
    myType: Second
    You chose Second. You need BarsPeriodType.PointAndFigure.​

    Comment


      #3
      Not entirely sure you need to throw a new exception to detect what type you are using. If you need it to prevent the strategy from being used on the other hand, I don't have too much experience with. I usually see exceptions being used with a try catch block...but the consensus on Stack Overflow seems to be that "throw new exception" is a generally bad idea.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      43 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      47 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X