Getting Started

FAQ

💰

PineConnector Code Adapter

Code Adapter

Converting your Pinescript code to be PineConnector compatible, automatically!

Assuming basic code of:

//@version=5
strategy('Supertrend Strategy', overlay=true)

[supertrend, direction] = ta.supertrend(3, 10)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, 'Up Trend', color=color.new(color.green, 0), style=plot.style_linebr)
downTrend = plot(direction < 0 ? na : supertrend, 'Down Trend', color=color.new(color.red, 0), style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

if ta.change(direction) < 0
    strategy.entry('My Long Entry Id', strategy.long)

if ta.change(direction) > 0
    strategy.entry('My Short Entry Id', strategy.short)

The output should be:

//@version=5
strategy('Supertrend Strategy', overlay=true)

[supertrend, direction] = ta.supertrend(3, 10)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, 'Up Trend', color=color.new(color.green, 0), style=plot.style_linebr)
downTrend = plot(direction < 0 ? na : supertrend, 'Down Trend', color=color.new(color.red, 0), style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

if ta.change(direction) < 0
    strategy.entry('My Long Entry Id', strategy.long)
    alert('60123456789,buy,EURUSD,risk=1', alert.freq_once_per_bar_close)

if ta.change(direction) > 0
    strategy.entry('My Short Entry Id', strategy.short)
    alert('60123456789,sell,EURUSD,risk=1', alert.freq_once_per_bar_close)

plotshape(ta.change(direction) < 0, style=shape.labelup, location=location.belowbar, color=color.new(#046ff9, 0), size=size.large, text='PineConnector \n Buy', textcolor=color.new(color.white, 0)) //plotting up arrow when buy/long conditions met 

plotshape(ta.change(direction) > 0, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 0), size=size.large, text='PineConnector \n Sell', textcolor=color.new(color.white, 0)) //plotting down arrow when sell/short conditions met

There are 2 components that needs to be added:

  1. the alert() code that comes a row after “strategy.entry”
    1. if strategy.entry has “strategy.long” → alert('60123456789,buy,EURUSD,risk=1', alert.freq_once_per_bar_close)
    2. if strategy.entry has “strategy.short” → alert('60123456789,sell,EURUSD,risk=1', alert.freq_once_per_bar_close)
  2. plotshape() code that uses the entry condition → this usually comes after the “if” such as “ta.change(direction) > 0”
    1. since “ta.change(direction) < 0” comes after the “if” and “strategy.long” was used → code to add for arrow up:
    2. plotshape(ta.change(direction) < 0, style=shape.labelup, location=location.belowbar, color=color.new(#046ff9, 0), size=size.large, text='PineConnector \n Buy', textcolor=color.new(color.white, 0)) //plotting up arrow when buy/long conditions met

    3. since “ta.change(direction) > 0” comes after the “if” and “strategy.short” was used → code to add for arrow down:
    4. plotshape(ta.change(direction) > 0, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 0), size=size.large, text='PineConnector \n Sell', textcolor=color.new(color.white, 0)) //plotting down arrow when sell/short conditions met

We may use placeholders for now, and we can refine the exact code to use in later versions.

The above is to be done using HTML, CSS and JS.

Essentially, we are trying to automate “Section 1.2 Strategy” in the documentation here: https://docs.pineconnector.com/low-code#445e8f8d8c9e48c39adf9d2e64bf7a92

Input:

Output: