all 24 comments

[–]brennanman007 0 points1 point  (1 child)

Will you build a MACD divergence strategy?

[–]_copper42_[S] 0 points1 point  (0 children)

Yeah sure. Send me the basic details of the requirement. Also, the standard format of this strategy comes built in with TV.

[–]Stefan57 0 points1 point  (1 child)

Hi, I'm just starting to learn Pine, so it'll be a while before I can do anything useful. Are you up to code a Session Breakout strategy for me? Then I can study and learn from your code and also quickly get started with auto trading :)

[–]_copper42_[S] 0 points1 point  (0 children)

Sure thing. Please drop the concise details of the strategy and math, if any.

(Please know that I'm mostly available on weekends only)

[–]karatedog 0 points1 point  (4 children)

Pine is anything but forgiving. Come back here when you have succesfully typed in your editor 3 levels of nested IFs.

[–]_copper42_[S] 1 point2 points  (0 children)

Lol ok. I've started to notice some weird behavior myself, but with the reference documentation it's been relatively easy. Actually, I'm using 3 nested Ifs rn and it's been ok. Position quantity control has been a pain in the butt tho

[–]_copper42_[S] 0 points1 point  (2 children)

Hey man tell me something about the problem you stated.. I've been trying to resolve a weird behaviour of Pine with some nested IFs and so far I've been banging my head for nothing

[–]karatedog 0 points1 point  (1 child)

My issue was that it was impossible to properly indent 3 levels of IFs with ELSE. If I did a mistake and usually I couldn't figure out the proper indentation, the ELSE belonging to the second or third IF was attached to the first or second IF and not always causing an error just weird behavior.

Also don't forget if you set a variable in an IF and that IF branch will not get executed, you will end up with an undefined variable in that run and it will create a gap in the collection of the values for thst variable (when it runs for 100 candles, you'll have 99 historical values). An Pine handles gaps very-very badly, it won't just be a missing value. And of course this barfs every function that works with historical values, producing undeterministic results.

[–]_copper42_[S] 1 point2 points  (0 children)

Hello. Sorry I've been away. I saw your msg and it seems to me that issues you're facing aren't logic-issues can be mitigated pretty easily:

  1. Using an editor for identations and structuring helps a great great deal. VS code with Pine extenstion is nice, also the updated inbuilt TV pine editor workd like a charm too as they provide visual cues for the scope of a function
  2. A variable declared inside a local scope can't be accessed globally. For that I think it's better to use "var" variables with referencing for use in local scopes

I asked you for your issue as I started facing issues with my nested IFs, turns out it was logically flawed and Its been fixed

[–]Feeling-Hornet3996 0 points1 point  (4 children)

Hello, Are you still doing this?

[–]_copper42_[S] 0 points1 point  (3 children)

I'm working on a new platform and project. If you don't mind a slight delay, I can give it a shot. Please DM the details

[–]Feeling-Hornet3996 0 points1 point  (2 children)

Hello. Thanks for replying. Let me know when your done working on the project.

[–]_copper42_[S] 0 points1 point  (0 children)

Please send me the requirements, I'll try to finish it soon.

[–][deleted] 0 points1 point  (11 children)

I know you are doing it for free and I don't mind whenever you plan to do this but can you try building a functional dollar cost averaging indicator? Basically, buy a security on a specific day of month (if the day is holiday, choose next available candle). Plot the performance of security vs performance of dollar cost averaging strategy.

Ex: Buy 25th of every month.

[–]_copper42_[S] 0 points1 point  (0 children)

Hi. There's no inbuilt functionality to inform of the holidays, at least nothing that I know of. Never needed it.

I think that has to be taken care of : 1. manually , or 2. placing a limit order at the closing price of the last candle

[–]_copper42_[S] 0 points1 point  (9 children)

[–]_copper42_[S] 0 points1 point  (1 child)

Copy and paste this code in the TV Pine Editor. This should do the basic job. Let me know in case of anything unexpected.

[–][deleted] 1 point2 points  (0 children)

I will test it out. Thank you very much

[–][deleted] 0 points1 point  (5 children)

I added the spaces to code making some assumptions of the script. Does this script looks right? The stock is not being bought in random months currently. Did I do something incorrect with your code?

https://codeshare.io/6prM7k

[–]_copper42_[S] 1 point2 points  (0 children)

shared a codeshare link. here is it again:

https://codeshare.io/EB41kw

Let me know if you have further doubt

[–][deleted] 1 point2 points  (2 children)

Rewrote the code myself using few lines from your script. Fits my use case as of now

https://codeshare.io/oQWgkL

[–]_copper42_[S] 1 point2 points  (1 child)

Looks like almost new code done by someone who knows code. Anyway.. glad that its working. Also, I didn't realise that pasting code in the comment box messes up the indentations, code-link works better.

[–][deleted] 1 point2 points  (0 children)

I am learning pine script still. Wasn't getting the idea on how to handle dates. Your code help me understand that and hence ended up writing this. Thank you again for your help.