very simple pinescript strategy translation help

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

very simple pinescript strategy translation help

Postby LearningByDoing » Wed Jun 01, 2016 3:37 pm

I tested the below pinescript strategy and the results were promising.
Could this be translated into a lua strategy? (optional sl, limit and trailing would be nice, but are not a must).

Code: Select all
Period=input('500')
longCondition = crossover(security(tickerid, Period, close),security(tickerid, Period, open))
if (longCondition)
    strategy.entry("BUY", strategy.long)
shortCondition = crossunder(security(tickerid, Period, close),security(tickerid, Period, open))
if (shortCondition)
    strategy.entry("SELL", strategy.short)


it's not very fancy but my attempts to bring this to lua are not really working very well (yet).
Period is in the pinescript a duration in minutes, but if I get ticks in lua it would also be fine with me (I'll then just convert it).

Any help with this would be highly appreciated.
LearningByDoing
 
Posts: 18
Joined: Wed Apr 13, 2016 6:13 pm

Re: very simple pinescript strategy translation help

Postby Apprentice » Thu Jun 02, 2016 3:06 am

Basically.
Open Short if we have a down candle
Open Long if we have up candles.
Is this True?
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36494
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: very simple pinescript strategy translation help

Postby LearningByDoing » Thu Jun 02, 2016 5:03 am

In short: yes.

while the candle length can be adjusted in minutes.

I was surprised to see how well this did in the tradingview strategy tester, that I want to give it a go with a lua strategy.

However my attempts with
Code: Select all
Source.close[-1] < Source.close[-period]

as condition did not even closely bring comparable results.
So I'd be very thankfull if you could give me a hint, or even better the lua code.

best,
LearningByDoing
LearningByDoing
 
Posts: 18
Joined: Wed Apr 13, 2016 6:13 pm



Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 34 guests