Skip to content

Multiple issues: ta.dmi subscript, ta.tr syntax, function param mismatch #45

@hsariaslan

Description

@hsariaslan

PyneComp Bug Report

Summary

PyneComp generates code that attempts subscript access on ta.dmi() output values, but PyneCore's ta.dmi() returns tuple[float, float, float], not Series. This causes TypeError: 'float' object is not subscriptable at runtime.

Environment

  • PyneCore Version: 6.3.4
  • Python Version: 3.12
  • Pine Script Version: v6
  • Platform: Linux

Minimal Reproduction

Pine Script Input

//@version=6
strategy("ADX Test")

[diplus, diminus, adx] = ta.dmi(14, 14)

// Access historical ADX value
if adx[1] > 25
    strategy.entry("Long", strategy.long)

Generated Python (problematic)

diplus, diminus, adx = ta.dmi(14, 14)

# ERROR: 'float' object is not subscriptable
if adx[1] > 25:
    strategy.entry("Long", strategy.long)

Error

TypeError: 'float' object is not subscriptable

Root Cause

PyneCore's ta.dmi() returns floats (current bar values only):

# From pynecore/lib/ta.py
def dmi(diLength: int, adxSmoothing: int) -> tuple[float | NA, float | NA, float | NA]:
    ...
    return p, m, adx  # floats, not Series

PyneComp generates direct subscript access (adx[1]) which fails on floats.

Expected Behavior

PyneComp should wrap ta.dmi() output with inline_series() to enable historical access, similar to how it handles ta.crossover():

# Working pattern (ta.crossover):
result = inline_series(ta.crossover(fast, slow), i)

# Expected pattern for ta.dmi():
adx = inline_series(ta.dmi(14, 14)[2], 0)
# Then for historical access:
if inline_series(adx, 1) > 25:
    ...

Additional Issue: ta.tr Without Parentheses

PyneComp generates ta.tr without calling it as a function:

# Generated (incorrect):
atr = ta.rma(ta.tr, 14)  # ta.tr is a function reference

# Should be:
atr = ta.rma(ta.tr(), 14)  # ta.tr() returns the value

Error: TypeError: float() argument must be a string or a real number, not 'function'


Additional Issue: Function Parameter Name Mismatch

PyneComp generates function definitions with mangled parameter names but calls them with non-mangled keyword arguments:

# Generated function definition:
def my_func(param__abc123__):
    pass

# Generated call site:
my_func(param="value")  # ERROR: unexpected keyword argument

Error: TypeError: got an unexpected keyword argument 'param'


Affected Functions

  • ta.dmi() - confirmed
  • ta.tr - confirmed
  • Likely other TA functions returning scalars/tuples

Severity

High - Prevents execution of any strategy using ADX with historical lookback.


PyneCore Version: 6.3.4
Date: 2025-12-04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions