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 Darkslide_Tom, Yesterday, 11:08 PM
      0 responses
      7 views
      0 likes
      Last Post Darkslide_Tom  
      Started by wolfrine97, Yesterday, 10:54 PM
      0 responses
      6 views
      0 likes
      Last Post wolfrine97  
      Started by sastrades, Yesterday, 09:24 PM
      0 responses
      9 views
      0 likes
      Last Post sastrades  
      Started by techbid, 03-21-2025, 12:16 PM
      1 response
      14 views
      0 likes
      Last Post techbid
      by techbid
       
      Started by laketrader, 03-10-2025, 07:20 AM
      7 responses
      68 views
      0 likes
      Last Post laketrader  
      Working...
      X