TradingView
grantcause
30 янв 2019 г., 14:25

ProfitTrailer Example TradingView Signals [v2019-01-31] 

Bitcoin / USD CoinBinance

Описание

ProfitTrailer Example TradingView Signal

This script provides an example of a TradingView Signal for use with ProfitTrailer's
new SIGNALS functionality and it's new TradingView integration capability.

This signals script implements a simple Moving Average Cross strategy
that works on any chart timeframe.

It allows you to pick the Price source i.e. Open, Close (default), etc.

You are able to choose between EMA (default) or SMA moving average
calculations.

You can define the fast and slow period lengths for use within the
moving average calculations.

If you get some value out of this indicator please consider making
a small donation to my favourite charity the Save the Childrens Fund.
Every donation will make a difference to the lives of children.
All donations over $2 are tax deductable. You can donate here:

https://savethechildrenfundraising.org.au/cryptocoyn

Copyright (c) 2019, Grant Cause aka CryptoCoyns
Комментарии
grantcause
Had a report of a possible repainting issue. We cant fix it as such as it is a problem with TradingView itself see here: getsatisfaction.com/tradingview/topics/strategies-and-indicators-are-repainting They attempted to fix it in 2017 but it didn't work (my opinion, I believe they did a workaround rather than a fix, others would disagree) see here: tradingview.com/wiki/Pine_Script:_Release_Notes Look for where they talk about Version 3 you will notice the use of version3 at the top of the script I wrote as an example signals script. The reason it happens occasionally in that script is that it makes use of the Security function to allow the selection of timeframes. They added a couple of extra flags in Version 3: // To avoid difference in calculation on history/realtime you can request not latest values and use merge strategy flags as follows:
s2=security(tickerid, "D", close[1], barmerge.gaps_off, barmerge.lookahead_on)
These flags are already set as the defaults when you use the //@version3 at the top of your script. So you have their latest fixes for this. You can stop the repaint from happening by adding the close[1] but then you wont be getting the latest version of the data but the previous candles (or timeframe you pick) close value which kind of the defeats the purpose of using this as a signal on realtime data. As far as I know it is a chart repainting issue and not an alert issue so the alerts should still fire correctly. if you want to try using the previous candles close value (rather than the price source you pick) in the script I wrote here is the line you need to change:
securitySource = security(ticker, period, close[1])
But this will disable the ability to change the source of the price to use. i.e. Open, Close, etc.
jaypabs78
Hi,

How can I use SMA indicator with 10-days, 50-days, 100-days, 200-days and get the bot to buy when the 10-days crossed all other indicator?

Thank you
grantcause
@jaypabs78, easily done just modify the script above by creating additional moving average lines like this for each timeframe i.e 10 days, 50 days, etc.

ma10 = sma(securitySource, 10)
ma50 = sma(securitySource, 50)
ma100 = sma(securitySource, 100)
ma200 = sma(securitySource, 200)

Then change the buy / sell conditions as follows, you only need to test the 10 and 50 as the others will already be crossed if the 10 goes above or below the 50:

buySignal = crossover( ma10, ma50 )
sellSignal = crossunder (ma10, ma50 )

You will have to test this out but it should be something like that.

Cheers
dpanday
So does this repaint?
grantcause
@dpanday, yes I explained that in the comment above you could try securitySource = security(ticker, period, priceSource(1) ) which looks at the previous candle close instead of the current candle close. Cheers,
Ещё