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 JAVIER LLORDEN, 03-13-2023, 11:10 AM
      6 responses
      976 views
      0 likes
      Last Post pavan15589  
      Started by Delerium, 01-11-2022, 04:20 PM
      5 responses
      450 views
      0 likes
      Last Post wbear009  
      Started by ybforex, 03-11-2025, 05:30 PM
      12 responses
      101 views
      0 likes
      Last Post rockmanx00  
      Started by forgebench, Today, 02:22 PM
      2 responses
      10 views
      0 likes
      Last Post forgebench  
      Started by MamaKB, 02-14-2025, 03:38 PM
      10 responses
      86 views
      0 likes
      Last Post Fertryd2  
      Working...
      X