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 TrippTraders, Yesterday, 07:14 PM
      1 response
      12 views
      0 likes
      Last Post brucerobinson  
      Started by decosenty, Yesterday, 11:33 PM
      0 responses
      8 views
      0 likes
      Last Post decosenty  
      Started by RicharBarrio, Yesterday, 11:26 PM
      0 responses
      6 views
      0 likes
      Last Post RicharBarrio  
      Started by paulo_br, 09-13-2024, 08:41 AM
      8 responses
      1,155 views
      0 likes
      Last Post AppleID25  
      Started by mno_om, Yesterday, 08:44 PM
      0 responses
      11 views
      0 likes
      Last Post mno_om
      by mno_om
       
      Working...
      X