#Testing trading strategies on Tradingview. Pine Script code.

73 messages · Page 1 of 1 (latest)

warped helm
#

So I've been trying to see if ChatGPT can create a Pine Script code to implement trading strategies I input without having to learn Pine Script.

So far I've been unsuccesfull, since the codes it generates seem to have lots of errors. Nevertheless, I do think it has potential because the codes it creates aren't completely wrong. Also, I've had most success in giving it a code so that it corrects it.

I think I need to learn the basics of Pine Script, so that I can feed it the information it need so that it can then learn the language. Although, I could just go to a website that has all the information of the programing language and just copy and paste it into ChatGPT.

In the image I put an example of a code it generated after me telling what strategy I wanted and telling it what to correct in the code.

This is a lesser known language, but if anyone has had trouble trying to get it to make code in any other language, I would like to know if there's a way to teach it.

last moon
#

I would find a pine language ebook and copy paste bits of code and either tell it or ask it what it means

lament radish
#

Any news?

jolly quartz
#

act as pinescript coder . you write an oscillator strategy to use on a 5 min chart for equities, enter long when ema 5 is greater than ema 20 and exit when ema 5 is less than ema 20. enter short when ema 5 is less than ema 20 and exit when ema 5 is greater than ema 20.

jaunty osprey
#

Nice idea

ivory tinsel
#

i"m doing the same with mql4. I asked what I should do to give it the required knowledge and copy pasted the data. After that I made it write a simple EA and gave it the error codes and which line they were on. Trial and error made it work like I wanted to. VERY long conversation!

valid palm
#

how to write a pine script?

#

hi

warped helm
scarlet aurora
#

"Pinescript Oscillator Strategy"

civiveunltd@gmail.com
act as pinescript coder . you write an oscillator strategy to use on a 5 min chart for equities, enter long when ema 5 is greater than ema 20 and exit when ema 5 is less than ema 20. enter short when ema 5 is less than ema 20 and exit when ema 5 is greater than ema 20.

Here is the code for the oscillator strategy that you described:

Copy code
// This strategy enters a long position when the EMA 5 is greater than the EMA 20
// and exits the position when the EMA 5 is less than the EMA 20.
// It enters a short position when the EMA 5 is less than the EMA 20
// and exits the position when the EMA 5 is greater than the EMA 20.

// Set the input parameters
study("EMA Oscillator Strategy", shorttitle="EMA OSC", precision=4)
emaLength5 = input(5, minval=1)
emaLength20 = input(20, minval=1)

// Calculate the EMA 5 and EMA 20
ema5 = ema(close, emaLength5)
ema20 = ema(close, emaLength20)

// Set the strategy variables
longEntered = false
shortEntered = false

// Enter a long position if the EMA 5 is greater than the EMA 20
if ema5 > ema20 and not longEntered
longEntered = true
shortEntered = false
strategy.entry("Long", strategy.long)

// Exit the long position if the EMA 5 is less than the EMA 20
if ema5 < ema20 and longEntered
longEntered = false
strategy.close("Long")

// Enter a short position if the EMA 5 is less than the EMA 20
if ema5 < ema20 and not shortEntered
shortEntered = true
longEntered = false
strategy.entry("Short", strategy.short)

// Exit the short position if the EMA 5 is greater than the EMA 20
if ema5 > ema20 and shortEntered
shortEntered = false
strategy.close("Short")

solemn kestrel
#

same here.. after a while i finally understand a little about it.. first need to #define the strategy first..

#

i think you need to #define (your order to define )

vocal fossil
#

if anyone can help create a strategy dm me!

brittle tapir
#

Hey! I love this discussion. I have worked on several trading algorithms, using fuzzy logic, none with deep learning. If you want to jump into a conversation happy to chat. I use python

upbeat jolt
#

I'm interested in creating this as well... I'm looking to create a strategy using Bollinger Bands. 24 min timeframe - enter when Below - SL to entry - 1st TP at MA - SL to MA - 2nd TP at Top - rinse & repeat.

vocal fossil
#

oh this is nice

primal nacelle
#

Hi guys - I also build my own strategies. But I would like to clarify something- you just use the ChatGPT for the code writing right ? Not to guide on the building of the strategy

warped helm
#

If you want to learn a trading strategy, there are plenty of youtube videos out there, and also web pages, where you can learn good strategies

primal nacelle
#

What I meant is simple - let me give a simple example: suppose you want to know if you can use a regression on continuous data. As such you would make that question to the ChatGPT

#

This is a way where you would be using the ChatGPT in building the strategy - of course not the actual strategy. Saying in a different way, if it’s used to check the validation of the methods you apply ( ie regression like if the error are normal distributed, etc , etc )

warped helm
#

You got me there

#

No idea

#

I would encourage you to try it out though

#

I don't even know if pine script has a normal distribution function, or a library, that can add said functions

#

What I do know you can do in pine script is backtest strategies and see how effective they are throughout a period of finite time. There you can see the percentage of times it has worked

cosmic dune
#

It is still great to learn the syntax of pine code, I have been working on converting certain pine code to python for testing purposes and there are many work around to getting what you need.

#

Knowing the syntax helps correct the errors as I have seen many of the errors are just simple typos or forgetting simple but vital changes on just a single line. It knows how to structure but the in-depth capabilities seem a bit limited

frozen oak
#

i would love to collaborate with others on this . Should we jump on a group chat and talk more ?

last moon
#

Im interested if you make one

lost moss
#

im also in

cedar jasper
#

Hey, i'm a new user on chat gpt but i trade since 2020, how can i use the AI ti create a protibale strategie to use on prop firm account ?

cedar jasper
#

Hey! What language do brokers use to program this in transactions?

cedar jasper
cedar jasper
cosmic dune
cosmic dune
cedar jasper
#

And for you to be able to run commands like these there must be a series of layers of security. Does code like the one in this project make it possible to implement these fraud security steps or would it become much larger and complex?

#

Sorry, I don't understand the subject very well. So the questions...😅

cosmic dune
#

@cedar jasper all good! No pinescript is unique of itself to tradingview. Connecting to brokers that are not supported by tradingview you would need to code in another language is which you can connect trough via an API

steel forge
#

whats the difference between this and 3commas? free trading bot for dummies

cedar jasper
cosmic dune
#

No pinescript is exclusive to tradingview

cedar jasper
plush coral
#

Interested in this conversation as I would like to include AI to model a private trading software product. Did anyone set up a group chat off discord to discuss?

barren root
cosmic dune
#

I may put something together, depending on what everyone’s overall goals are

livid siren
#

+1 to the AI model convo above

plush coral
loud gazelle
#

I would also be very interested in joining a group. Please add me if something gets put together!

lavish fiber
#

Any updates on this? Very interested. Happy to contribute in any way

neon crest
#

Same as above^^ Is there any updates?

cosmic dune
#

I am currently putting a discord channel together and so forth

#

I’ll let you guys know when it is complete

oak birch
#

Im a complete noob when it comes to this kind of stuff, but i was messing around and got it to write out code for me based on this prompt " write python code that uses a genetic algorithim or neural net producing the most gains on the stock market outputting the highest gains, then reproduce those highest gains and then run it against every day that the stock market has existed"

#

if anyone would like to look at it, i can put it in the chat, only posting here because this is the closest channel ive seen to what I was trying to accomplish.

cosmic dune
#

Did it develop a neural net? Or was it using other factors like averages and so forth?

#

Secondly did you have a dataset for it to run through to train?

#

And for those looking to put a project together, are we keeping it simple and sticking to TradingView where we all have similar connection through or are we going with python

last moon
#

Lets stick with trading view. Soon as anyone gets some usable code and how to implement just throw it in here

oak birch
oak birch
cosmic dune
cosmic dune
#

go ahead and send me a dm for those interested

brave stratus
#

the generated pine codes are often wrong, is there any way to use the OpenAI API and write some code to make "it" understanding pinescript better?

cosmic dune
tepid forum
#

what's sites can earning money free online

hallow marten
#

Its better to Use ADX indicator with chanable D value...i saw it last year:-)

soft wasp
soft wasp
# cosmic dune I have found it likes to write in version 4, if you ask it to write in version 5...

I try that again and again. It can't fix it's errors for me most of the time. I've been asking it about multi-timeframe stuff, looping, arrays, and it just can't do it. I remind it that I'm working in V5 and after a few more error messages, it starts to reinsert V4 stuff again. Then I remind it, it apologizes and tells me that it corrected the code, but made absolutely zero changes to it. Just typed out the exact same thing. It's incredibly frustrating and I have several projects that I'm likely going to pay a human for help with. If GPT could just read the Pine manual and understand it better than I can (which shouldn't be hard), I imagine it could do everything I've asked.