0

I have been trying to convert a trading strategy written in PineScript to EasyLanguage. As background, Tradingview uses PineScript and TradeStation uses EasyLanguage.

Here is a link that does a very good job describing what the strategy is doing. Pseudocode for Swing Trading script

Here is the PineScript version:

//Strategy Details
no = input(3, title='BUY/SELL Swing')
Barcolor = input(false, title='BUY/SELL Bar Color')
Bgcolor = input(false, title='BUY/SELL Background Color')
res = ta.highest(high, no)
sup = ta.lowest(low, no)
iff_1 = close < sup[1] ? -1 : 0
avd = close > res[1] ? 1 : iff_1
avn = ta.valuewhen(avd != 0, avd, 0)
tsl = avn == 1 ? sup : res
Buy = ta.crossover(close, tsl)
Sell = ta.crossunder(close, tsl)
plotshape(Buy, title='Buy', color=color.new(color.green, 0), style=shape.arrowup, location=location.belowbar, text='Buy Signal', textcolor=color.new(color.lime, 0))
plotshape(Sell, title='Sell', color=color.new(color.red, 0), style=shape.arrowdown, text='Sell Signal', textcolor=color.new(color.red, 0))
colr = close >= tsl ? color.green : close <= tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title='BUY/SELL Chart Line')
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr : na)
alertcondition(Buy, title='Buy Signal', message='Buy Signal')
alertcondition(Sell, title='Sell Signal', message='Sell Signal')

Here is how far I was able to get in EasyLanguage:

//Strategy Details
input: length (3);

variables:
    resistance( 0 ),
    support( 0 ),
    avd( 0 ),
    avn( 0 ),
    tsl( 0 ),
    iff_1( 0 ),
    counter( 0 ),
    between( 0 );
    resistance = highest(high, length);
    support = lowest(low, length);
    if close<support[1] then
    iff_1 = - 1
    else
        iff_1 = 0;
    if close>resistance[1] then
    avd =  1
    else
        avd = iff_1;
    if avd != 0 then
    avn = avd
    else
        avn = 0

As you can see, I am having some difficulties here. Hoping someone with experience in both PineScript and EasyLanguage could lend me a hand with the conversion. Seems like a very easy conversion...but it is proving more difficult than my skills are allowing.

Anything you can provide would be most appreciated.

0 Answers0