Hi there,
Got this strategy from Trading View and it looks all right. As my program skills stopped in the 80's with the C64 I was wondering if somebody could convert this Pine Script into Power language cheers!
1 //@version=2
2 strategy(title='[STRATEGY][RS]HA Swing V0', shorttitle='RS', overlay=true, pyramiding=0, initial_capital=100000, currency=currency.USD)
3 tf = input('15')
4 trade_size = input(10000)
5 r = heikenashi(tickerid)
6 ro = security(r, tf, open)
7 rc = security(r, tf, close)
8 plot(ro, color=gray)
9 plot(rc, color=black)
10 sel_entry = rc < ro
11 //sel_close = high > ro
12 buy_entry = rc > ro
13 //buy_close = low < ro
14 strategy.entry('sell', long=strategy.short, qty=trade_size, comment='sell', when=sel_entry)
15 //strategy.close('sell', when=sel_close)
16 strategy.entry('buy', long=strategy.long, qty=trade_size, comment='buy', when=buy_entry)
17 //strategy.close('buy', when=buy_close)
Can somebody convert this Pine script into Power Language? [SOLVED]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Can somebody convert this Pine script into Power Languag [SOLVED]
Something like this would do:
Note however that PowerLanguage doesn't have a `security()` function, so you'll need to add additional data series to the chart and manually configure these to match the time frame (15 minutes by default) and symbol of the first data series.
Also, PowerLanguage strategies cannot plot values on the chart as strategies in TradingView can, so you'll need to create an additional PowerLanguage indicator for that (or don't use the visual plots, of course).
The TradingView strategy settings set by the `strategy()` function (like pyramiding, initial capital, and currency) all need to be set manually in MultiCharts too (right-click on the chart, select 'Format Signals', and then click on the 'Properties' button).
Code: Select all
// [STRATEGY][RS]HA Swing V0
Inputs:
trade_size(10000);
Variables:
ro(0), rc(0), sel_entry(false), sel_close(false), buy_entry(false), buy_close(false);
ro = Open data2; // Set data2 to a Heikin-Ashi chart
rc = Close data3; // Data3 needs to be a Heikin-Ashi chart also
sel_entry = rc < ro;
//sel_close = high > ro
buy_entry = rc > ro;
//buy_close = low < ro
if (sel_entry) then
SellShort ("sell") trade_size contracts next bar at market;
//if (sel_close) then
// BuyToCover ("sell") next bar at market;
if (buy_entry) then
Buy ("buy") trade_size contracts next bar at market;
//if (buy_close) then
// Sell ("buy") next bar at market;
Also, PowerLanguage strategies cannot plot values on the chart as strategies in TradingView can, so you'll need to create an additional PowerLanguage indicator for that (or don't use the visual plots, of course).
The TradingView strategy settings set by the `strategy()` function (like pyramiding, initial capital, and currency) all need to be set manually in MultiCharts too (right-click on the chart, select 'Format Signals', and then click on the 'Properties' button).