Custom Indicator Bugs
Hi,
I've found 5 bugs (so far) on custom indicator.
Changing the color opacity of a line (
TOptValue_LineStyle) will not take effectObjProp.OBJPROP_LOCKEDis on the documentation but when setting itthis.api.SetObjectProperty(name, ObjProp.OBJPROP_LOCKED, true)
Syntax error is displaying Property 'OBJPROP_LOCKED' does not exist on type 'typeof ObjProp'.
I cannot change style of a line when setting
isStaticinCreateChartObject. 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 doRemoveAllObjectsCan't change the color opacity of
TObjectType.TEXTWhen I set the color to#ffffff00(0% opacity) it will still display#ffffff(100% opacity)iBarShiftdoesn't return -1 when date is not exact even ifisExactis 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?
Comments7
Yuliia Hladko
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_LOCKEDworks in the newer API, although we recommendisStatic: truewhen you need an object that cannot be dragged. For static objects, passisStatic: truewhen changing or removing them as well.We also checked
iBarShiftwithisExact: trueon a custom timeframe, and it now returns the expected result.Carl D
Sep 30
Hi @Yuliia Hladko
The
iBarShiftseems working on custom timeframe that I reported but I tried on 1 week and its not workingSerhii S.
Jul 14
Hi,
Thank you for the detailed bug report.
Our developer has reviewed each of the issues you mentioned.
Here are the results:
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.0To change the opacity, use:
this.api.SetObjectProperty(objectName, ObjProp.OBJPROP_OPACITY, opacityValue, true);The opacity range is 0–255.
OBJPROP_LOCKED
Please update the npm package to ^2.4.0. The property is available in the latest version.
Static objects
If you create an object with
isStatic = true, you also need to specifyisStatic = truewhen callingSetObjectProperty, 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);Changing the opacity of
TObjectType.TEXTPlease use:
this.api.SetObjectProperty(name, ObjProp.OBJPROP_OPACITY, opacityValue);where
opacityValueis in the range 0–255.iBarShift()withisExact = trueWe were able to reproduce this issue. It appears that a previous fix was unintentionally reverted, and
isExact = trueis 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 inputthis.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.
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_LineStyleuser input opacity should work in this case, I’ll follow up here.Yuliia Hladko
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.opacityis a value from0to1, whileOBJPROP_OPACITYexpects0to255, 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, passtrueas the last argument toSetObjectPropertytoo.Serhii S.
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.