General > Marketplace (General)

[WIP] Finn's TV Microprofit Strategy

(1/2) > >>

Damasta:
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.
--- End quote ---

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: ---//@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-")
--- End code ---

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

allanster:
Thank you for sharing this! Very helpful.

joren:
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 :)

allanster:
Thanks for sharing this, look forward to trying this out!

dmains:
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: ---study(arg1, arg2, argN)
--- End code ---
to
--- Code: ---strategy(arg1, arg2, argN, overlay=true)
--- End code ---

2. Turn the alert conditions into if statements that trigger buys and sells:


--- Code: ---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-")
--- End code ---

turns into


--- Code: ---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)
--- End code ---


We can also optionally change hard-coded values into user inputs, so change their values and see what happens:
 
(Optional) Change
 

--- Code: ---fast = 5, slow = 10
--- End code ---

to


--- Code: ---fast = input(5)
slow = input(10)
--- End code ---


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



--- Code: ---//@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)
--- End code ---

Thank you for sharing this Finn!  ;D

Navigation

[0] Message Index

[#] Next page

Go to full version