Skip to content

transformer error #67

@Need-an-AwP

Description

@Need-an-AwP

i was trying an indicator called 'Purple Cloud' in pineTS

Purple Cloud

but pinets throw error when executing pineTS.run():

ReferenceError: buy is not defined
    at _r (.next\dev\server\chunks\[root-of-the-server]__35be2dc2._.js:7669:12)
    at Dr._executeIterations (C:\Users\17904\Desktop\costo\.next\dev\server\chunks\[root-of-the-server]__35be2dc2._.js:12645:29) 
    at Dr._runComplete (C:\Users\17904\Desktop\costo\.next\dev\server\chunks\[root-of-the-server]__35be2dc2._.js:12517:74)       
    at async (instrumentation.ts:94:31)

so i tried to make it output the code after transform:

    /**
     * Transpile the Pine Script code
     * @private
     */
    private _transpileCode(pineTSCode: Function | String): Function {
        const transformer = transpile.bind(this);
        const transpiledCode = transformer(pineTSCode, this._debugSettings);

        console.log('=== transpiled code ===');
        console.log(transpiledCode.toString());
        console.log('=== transpiled code ===\n');

        return transpiledCode;
    }

undefined variables can be seen in the transformed js code:

 // [Line 27] plotshape(buy && xs != xs[1] && direction < 0, {title: 'Strong BUY', text: '🚀', style: shape.labelup, location: location.belowbar, color: color.green, textcolor: color.white, size: size.tiny}); 
  const p54 = $.param(buy && xs != xs[1] && $.get($.let.glb1_direction, 0) < 0, undefined, 'p54');
// [Line 28] plotshape(sell && xs != xs[1] && direction > 0, {title: 'Strong SELL', text: '☄️', style: shape.labeldown, location: locationn.abovebar, color: color.red, textcolor: color.white, size: size.tiny});
  const p61 = $.param(sell && xs != xs[1] && $.get($.let.glb1_direction, 0) > 0, undefined, 'p61');

buy and sell two variables have been defined correctly in previous transformed code, but they are not used here

the full transformed code: transformed_script.js

i don't think i can completely understand the transformer in a short time, this is the farthest i can reach😭

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