Skip to main content

Custom Indicator Bugs

Hi,

I've found 5 bugs (so far) on custom indicator.

  1. Changing the color opacity of a line (TOptValue_LineStyle) will not take effect

  2. ObjProp.OBJPROP_LOCKED is on the documentation but when setting it this.api.SetObjectProperty(name, ObjProp.OBJPROP_LOCKED, true)

Syntax error is displaying Property 'OBJPROP_LOCKED' does not exist on type 'typeof ObjProp'.

  1. I cannot change style of a line when setting isStatic in CreateChartObject. It's always solid blue line. I don't know if it's intended (not mentioned in the documentation). Also, I can't remove it even if I do RemoveAllObjects

  2. Can't change the color opacity of TObjectType.TEXT When I set the color to #ffffff00 (0% opacity) it will still display #ffffff (100% opacity)

  3. iBarShift doesn't return -1 when date is not exact even if isExact is set on newly added timeframe like 12H.

    Ex. 2023-02-13T08:17:00.000Z. The time is 8:17 so it should return -1 on 12H (720)

Here is the indicator

test-indicator.js.txt

20.1 KB• Text

How does this impact your experience?
Status: In Progress7 comments

Comments7

  • Yuliia Hladko

    Team•

    Sep 30

    Hi Carl, thanks for your patience and for the detailed examples.

    We checked the issues again.

    • Line styling, including opacity, works with the current API through InputStroke; this also addresses your follow-up about opacity from the style input.

    • OBJPROP_LOCKED works in the newer API, although we recommend isStatic: true when you need an object that cannot be dragged. For static objects, pass isStatic: true when changing or removing them as well.

    • We also checked iBarShift with isExact: true on a custom timeframe, and it now returns the expected result.

    • Carl D

      •

      Sep 30

      Hi @Yuliia Hladko

      The iBarShift seems working on custom timeframe that I reported but I tried on 1 week and its not working

  • Serhii S.

    Team•

    Jul 14

    Hi,

    Thank you for the detailed bug report.
    Our developer has reviewed each of the issues you mentioned.

    Here are the results:

    1. Changing the color opacity of a line (TOptValue_LineStyle)

      This has already been addressed in the latest API version. Please update the npm package to:

      forex-tester-custom-indicator-api ^2.4.0

      To change the opacity, use:

      this.api.SetObjectProperty(objectName, ObjProp.OBJPROP_OPACITY, opacityValue, true); 

      The opacity range is 0–255.

    2. OBJPROP_LOCKED

      Please update the npm package to ^2.4.0. The property is available in the latest version.

    3. Static objects

      If you create an object with isStatic = true, you also need to specify isStatic = true when calling SetObjectProperty, for example:

      this.api.SetObjectProperty(name, ObjProp.OBJPROP_COLOR, this.lineStyle.color, true); 

      Also, RemoveAllObjects() removes only non-static objects by default. To remove static objects, use:

      this.api.RemoveAllObjects(TObjectType.V_LINE, true); 
    4. Changing the opacity of TObjectType.TEXT

      Please use:

      this.api.SetObjectProperty(name, ObjProp.OBJPROP_OPACITY, opacityValue); 

      where opacityValue is in the range 0–255.

    5. iBarShift() with isExact = true

      We were able to reproduce this issue. It appears that a previous fix was unintentionally reverted, and isExact = true is currently being ignored in this scenario.

      We'll fix this in one of the upcoming updates.

    Thank you again for reporting these issues. Your feedback helps us improve the API.

    • Carl D

      •

      Jul 14

      Thank you so much.

      I just have one question, how to get the opacity of a color from a user input (TOptValue_LineStyle). I tried this.lineStyle.opacity but it doesnt take effect, that means the opacity can only be change by code and not by user input, unless I create another number user input

      this.api.CreateChartObject(name, TObjectType.V_LINE, 0, this.api.Time(0).addMinutes(2));
      this.api.SetObjectProperty(name, ObjProp.OBJPROP_COLOR, this.lineStyle.color);
      this.api.SetObjectProperty(name, ObjProp.OBJPROP_OPACITY, this.lineStyle.opacity); //this is what im talking about
      this.api.SetObjectProperty(name, ObjProp.OBJPROP_STYLE, this.lineStyle.style);
      this.api.SetObjectProperty(name, ObjProp.OBJPROP_WIDTH, this.lineStyle.width);
      • Serhii S.

        Team•

        Jul 14

        Thanks for pointing this out. I’ve already passed your question and code example to our developers, and I’m waiting for their response.

        As soon as I have an update on whether TOptValue_LineStyle user input opacity should work in this case, I’ll follow up here.

      • Yuliia Hladko

        Team•

        Sep 30

        Thanks for the follow-up about opacity from the line-style input. You can use the value selected by the user; a separate number input isn’t necessary. this.lineStyle.opacity is a value from 0 to 1, while OBJPROP_OPACITY expects 0 to 255, so convert it when applying the style:

        this.api.SetObjectProperty( name, ObjProp.OBJPROP_OPACITY, Math.round(this.lineStyle.opacity * 255) );

        Apply the updated value again when the indicator settings change. If the object was created with isStatic: true, pass true as the last argument to SetObjectProperty too.

  • Serhii S.

    Team•

    Jul 14

    Hi @Carl D! Thank you for the videos, the indicator file, and the detailed description of the issues.

    I’ve already informed our developers about this.
    We need some time to investigate your custom indicator and look into these bugs properly.

    I appreciate you taking the time to report this so thoroughly.