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 sclay115, Today, 09:42 PM
      0 responses
      1 view
      0 likes
      Last Post sclay115  
      Started by sclay115, Today, 09:40 PM
      0 responses
      1 view
      0 likes
      Last Post sclay115  
      Started by DayTradingDEMON, Yesterday, 02:10 PM
      6 responses
      39 views
      0 likes
      Last Post rockmanx00  
      Started by Pointtoni, Yesterday, 11:41 PM
      3 responses
      36 views
      0 likes
      Last Post jenacie.com  
      Started by Nate G, 03-17-2025, 02:53 PM
      4 responses
      73 views
      1 like
      Last Post timko
      by timko
       
      Working...
      X