Username: Password:

Author Topic: [WIP] Finn's TV Microprofit Strategy  (Read 8465 times)

Offline Damasta

  • Trust: (0)
  • Rookie
  • *
  • Posts: 8
  • suck my ボールズ
    • View Profile
[WIP] Finn's TV Microprofit Strategy
« on: October 01, 2017, 04:04:57 PM »
Hello guys and girls who own the TV plugin (if not maybe this gets you excited to get it on http://gunbot.tv/).

After Exquitas excellent first setup of a basic MACD strategy I decided to play around with it
and figured a way out on how to narrow down the reaction time of the buy/sell detection.

Before you set this up be sure you have gained some TV and trading experience first as this is a very agressive
strategy and I advise being cautious with selecting pairs.

First of all what you have to check when using this:
Quote
Gunbot settings:
-"TV_GAIN": 0.6 in order to take the profit as soon as it exists on a sell trigger. DON'T go below because GB will sell at loss because of fees
-"TV_TRADING_LIMIT": 0.001 for the beginning as suggestion in order to test it before going to higher volume (I use 0.0015 fyi).
Don't tune it too high as it'll burn your funds because GB will double up at buy triggers on a downtrend to get the average bought price down.

Pair selection:
-I run the strat on 3 minutes as it is Microprofit
-Choose pairs that look curvy
-AVOID pairs that have less than 0.6% gain between support and resistance
-AVOID pairs that happen to be very volatile. The script contains some safety regarding that but it doesn't work 100% of the time but maybe 90%.
-Check your pairs frequently for those conditions. I check mine every day at least once and swap them out with pairs that go up.

That's how to work with this strategy. Now I will finally show you how to set it up. First of all copy my script and apply it to the chart:
Code: [Select]
//@version=2
study("MACDgen", precision=7)
fast = 5, slow = 10
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
micro = sma(macd,2)
hist = macd - signal
plot(hist, title="a", color=hist>0 and hist[0]>hist[1]?#00ff00:hist<=0 and hist[0]<hist[1]?#f72e2e:hist>0 and hist[0]<hist[1]?#008000:hist<0 and hist[0]>hist[1]?#7f0000:white, style=histogram)
plot(macd, title="b", color=red, linewidth=2)
plot(signal, title="c", color=blue, linewidth=2)
plot(micro, title="micro", color=black, linewidth=2)

histgood = false
difgood = false
dif = 0

//Pulling out the average difference between black MACD and blue Signal to use for condition
if (barstate.isnew)
    for i=0 to 50
        dif := dif + abs(signal[i]-micro[i])
    dif := dif/75

plot(dif,color=green)

if (barssince(cross(macd,micro)) > 2) //check for history of crossing to avoid volatile triggers
    histgood := true
else
    histgood := false
if (abs(signal-micro) > dif) //check for black MACD to have proper distance to the blue Signal, see above
    difgood := true
else
    difgood := false

//display the conditions
plotshape(histgood[1], style=shape.circle, location=location.bottom)
plotshape(difgood, style=shape.xcross, location=location.bottom)
plotshape(histgood[1] and difgood and crossunder(macd,micro), style=shape.arrowdown, location=location.top, color=red)
plotshape(histgood[1] and difgood and crossover(macd,micro), style=shape.arrowup, location=location.top, color=green)

//alert triggers
alertcondition(histgood[1] and difgood and crossover(macd,micro),"Buying Condition", "BUY_BITTREX_BTC-")
alertcondition(histgood[1] and difgood and crossunder(macd,micro),"Selling Condition", "SELL_BITTREX_BTC-")

After doing that you can see where the conditions meet and it will trigger an alert for buying/selling using the arrows as display.
Before thinking "oh but it might sell too early here" remind yourself what the TV_GAIN feature is for :).
I will continue to develop this strategy and update it here.

Now on to the alerts:
To set up an alert make sure everything including the interval looks good to you.
Set it up like this:


Now you're good to go. As for an example I have added the trades that have actually happened on MEMEBTC this morning:


Please feel free to suggest changes!
Gre, Finn
« Last Edit: October 12, 2017, 02:39:54 PM by Damasta »

Offline allanster

  • Trust: (+4)
  • Contributor
  • **
  • Posts: 128
  • lux ex tenebris
    • View Profile
  • Telegram: allanster
Re: [WIP] Finn's TV Microprofit Strategy
« Reply #1 on: October 01, 2017, 11:12:12 PM »
Thank you for sharing this! Very helpful.
more human than human

Offline joren

  • Trust: (0)
  • Rookie
  • *
  • Posts: 1
    • View Profile
Re: [WIP] Finn's TV Microprofit Strategy
« Reply #2 on: October 03, 2017, 12:58:00 PM »
Nice work - the slightly slower micro line and history check really help filter out noise.

The arrows also make a nice display in TV for manual trading... 

Thanks for sharing!  Running with RC 5055 - now if the markets will just cooperate :)


Offline allanster

  • Trust: (+4)
  • Contributor
  • **
  • Posts: 128
  • lux ex tenebris
    • View Profile
  • Telegram: allanster
Re: [WIP] Finn's TV Microprofit Strategy
« Reply #3 on: October 04, 2017, 10:27:35 AM »
Thanks for sharing this, look forward to trying this out!
more human than human

Offline dmains

  • Trust: (0)
  • Rookie
  • *
  • Posts: 8
    • View Profile
Re: [WIP] Finn's TV Microprofit Strategy
« Reply #4 on: October 09, 2017, 01:54:37 AM »
For those that want to play with backtesting, we can convert this to a trading strategy so tradingview can mark buys/sells and calculate profit.

Here's how to do it for other scripts you might see:

1. change
Code: [Select]
study(arg1, arg2, argN) to
Code: [Select]
strategy(arg1, arg2, argN, overlay=true)
2. Turn the alert conditions into if statements that trigger buys and sells:

Code: [Select]
alertcondition([color=purple]histgood[1] and difgood and crossover(macd,micro)[/color],"Buying Condition", "BUY_BITTREX_BTC-")  //copy the part before the first comma
alertcondition([color=purple]histgood[1] and difgood and crossunder(macd,micro)[/color],"Selling Condition", "SELL_BITTREX_BTC-")

turns into

Code: [Select]
if(histgood[1] and difgood and crossover(macd,micro))
    strategy.entry("BUY", strategy.long)
if(histgood[1] and difgood and crossunder(macd,micro))
    strategy.entry("SELL", strategy.short)


We can also optionally change hard-coded values into user inputs, so change their values and see what happens:
 
(Optional) Change
 
Code: [Select]
fast = 5, slow = 10
to

Code: [Select]
fast = input(5)
slow = input(10)


And here's the whole thing for easy copy + paste:


Code: [Select]
//@version=2
strategy("MACD_Finn", precision=7, overlay=true)
fast = input(5), slow = input(10)
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
micro = sma(macd,2)
hist = macd - signal
plot(hist, title="a", color=hist>0 and hist[0]>hist[1]?#00ff00:hist<=0 and hist[0]<hist[1]?#f72e2e:hist>0 and hist[0]<hist[1]?#008000:hist<0 and hist[0]>hist[1]?#7f0000:white, style=histogram)
plot(macd, title="b", color=red, linewidth=2)
plot(signal, title="c", color=blue, linewidth=2)
plot(micro, title="micro", color=black, linewidth=2)

histgood = false
difgood = false
dif = 0

//Pulling out the average difference between black MACD and blue Signal to use for condition
if (barstate.isnew)
    for i=0 to 50
        dif := dif + abs(signal[i]-micro[i])
    dif := dif/75

plot(dif,color=green)

if (barssince(cross(macd,micro)) > 2) //check for history of crossing to avoid volatile triggers
    histgood := true
else
    histgood := false
if (abs(signal-micro) > dif) //check for black MACD to have proper distance to the blue Signal, see above
    difgood := true
else
    difgood := false

//display the conditions
plotshape(histgood[1], style=shape.circle, location=location.bottom)
plotshape(difgood, style=shape.xcross, location=location.bottom)
plotshape(histgood[1] and difgood and crossunder(macd,micro), style=shape.arrowdown, location=location.top, color=red)
plotshape(histgood[1] and difgood and crossover(macd,micro), style=shape.arrowup, location=location.top, color=green)

//alert triggers
if(histgood[1] and difgood and crossover(macd,micro))
    strategy.entry("BUY", strategy.long)

if(histgood[1] and difgood and crossunder(macd,micro))
    strategy.entry("SELL", strategy.short)

Thank you for sharing this Finn!  ;D

Offline dmains

  • Trust: (0)
  • Rookie
  • *
  • Posts: 8
    • View Profile
Re: [WIP] Finn's TV Microprofit Strategy
« Reply #5 on: October 09, 2017, 06:03:35 AM »
I made a couple more changes to make signal length and micro length configurable, even though there's nothing wrong with the current values. Just fiddling.

Code: [Select]
fastLength = input(5)
slowLength = input(10)
signalLength = input(9)
microLength = input(2)
fastMA = ema(close, fastLength)
slowMA = ema(close, slowLength)
macd = fastMA - slowMA
signal = sma(macd, signalLength)
micro = sma(macd,microlength)
hist = macd - signal



What is the reason for dividing dif by 75? Is that just an empirical value? Maybe something else to make configurable for the strategy version?

Offline dmains

  • Trust: (0)
  • Rookie
  • *
  • Posts: 8
    • View Profile
Re: [WIP] Finn's TV Microprofit Strategy
« Reply #6 on: October 09, 2017, 09:54:24 PM »
Here's an interesting idea: use buy signals on shorter candles (such as 3 minutes) to ensure you get in on the bounce after a pump, but use buy signals on longer candles (such as 15 minutes - 1 hour depending on the pair) to help you ride the wave and avoid early sells!

Otherwise, careful selection of TV GAIN can help you squeeze out more profit, as Finn said.