Bitcoin Forum
December 07, 2016, 08:53:57 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: « 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 »
  Print  
Author Topic: Chrome Browser extension: MtGox trading bot  (Read 67272 times)
BTC-engineer
Sr. Member
****
Offline Offline

Activity: 338



View Profile
March 09, 2012, 11:55:15 AM
 #121

Let me see if I understand the bot now.  At the moment I have USD when two ticks of either +0.25% or -0.25% then the USD will be sold for BTC? Or is it just two +0.25% ticks to buy BTC and two -0.25% ticks to sell BTC?  Am I in the right postion to be holding USD now or should I be holding BTC or doesn't it matter.  Sorry if that sounds n00bish  Huh

Let's assume you set your threshold to 0.25%.
If you have USD in your mtgox account and your ema difference is over +(your_threshold_value) which is > +0.25%, the bot will buy BTCs for your USDs.
If you have BTC in your mtgox account and your ema difference is below -(your_threshold_value) which is < -0.25%, the bot will buy USDs for your BTCs.

So you have a BUY/SELL hysteresis of 2*your_threshold_value of your current ema difference.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481100837
Hero Member
*
Offline Offline

Posts: 1481100837

View Profile Personal Message (Offline)

Ignore
1481100837
Reply with quote  #2

1481100837
Report to moderator
1481100837
Hero Member
*
Offline Offline

Posts: 1481100837

View Profile Personal Message (Offline)

Ignore
1481100837
Reply with quote  #2

1481100837
Report to moderator
piotr_n
Legendary
*
Offline Offline

Activity: 1498


aka tonikt


View Profile WWW
March 09, 2012, 12:07:20 PM
 #122

With the default settings you should be holding USD at the moment.

Check out gocoin - my original project of a bitcoin client written in Go, with some unique features.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
matthewh3
Legendary
*
Offline Offline

Activity: 1372



View Profile WWW
March 09, 2012, 02:12:12 PM
 #123

Let me see if I understand the bot now.  At the moment I have USD when two ticks of either +0.25% or -0.25% then the USD will be sold for BTC? Or is it just two +0.25% ticks to buy BTC and two -0.25% ticks to sell BTC?  Am I in the right postion to be holding USD now or should I be holding BTC or doesn't it matter.  Sorry if that sounds n00bish  Huh

Let's assume you set your threshold to 0.25%.
If you have USD in your mtgox account and your ema difference is going over +(your_threshold_value) which is > +0.25%, the bot will buy BTCs for your USDs.
If you have BTC in your mtgox account and your ema difference is going below -(your_threshold_value) which is < -0.25%, the bot will buy USDs for your BTCs.

So you have a BUY/SELL hysteresis of 2*your_threshold_value of your current ema difference.



Thanks  Wink

matthewh3
Legendary
*
Offline Offline

Activity: 1372



View Profile WWW
March 09, 2012, 02:14:29 PM
 #124

With the default settings you should be holding USD at the moment.

Thanks think I'll stick with the defaults while I'm still learning.

BTC-engineer
Sr. Member
****
Offline Offline

Activity: 338



View Profile
March 09, 2012, 07:17:33 PM
 #125

Today I found some time to look into the code in more detail. I've never done anything with javascript before, so it's not so easy for me to understand everything right away just by looking on it.
However, the code looks very elegant and clean to me, which helped me a lot to understand it, or at least a lot of it. Thanks again piotr_n!

In one of my previous posts I wrote about having bigger trouble with 'floating' historical bot results after a reload of the bot. The bot results were also not or only badly matching to the results of bitcoincharts.com
Also the hint from piotr_n, to set MaxHoursBack=MaxHoursToKeep didn't fix my issues.

I found the problem and now the bot results matching very well with results from other tools. The issue was a mix of different problems.
One was the difference between MaxHoursBack and MaxHoursToKeep.
Then I'm trading with longer EMA's then the default ones (10/21 ticks) and therefore seeing the issue more intensive then users with shorter EMA's.
Finally I had to calculate the EMA over a longer timeframe.

The calculation of the emas in updateEMA() looks correct to me.
But I don't think that the default values are suitable to do a correct EMA calculation. I'm not a math-expert, but did some wiki-research and testing.
What I've found out is the following:
If you want to do a EMA calculation for n-ticks, you have to do the EMA calculation over at least 5*n ticks to get correct values. My tests have shown that the results (3 decimal places) are already nearly exact with a calculation over 4*n ticks. If you only do the calculation over 2*n ticks the results are quite far away from the correct values. With the default settings (EMA's 10/21, MaxHoursBack=48) you do the EMA calculation over ~2.28*n ticks witch is only a roughly approximation of the correct EMA values.  
Longer time-frames then 5*n ticks will not change the result (3 decimal places) anymore and are therefore unnecessary for this tool.

I'm now working with  MaxHoursBack and MaxHoursToKeep >200 ticks and I'm happy to get always the same results and they are also matching with other tools.
BTC-engineer
Sr. Member
****
Offline Offline

Activity: 338



View Profile
March 09, 2012, 09:06:18 PM
 #126

There were already some discussions why the ema difference has to be 2 ticks in a row over/under the defined threshold to trigger a trade.
From looking into the sourcecode I can confirm that behavior. I also don't know why it is there, because I can not remember from the original trading strategy post, that you should wait 2 ticks.
You could change it easily by exchanging  numbers in the buying/selling decisions.  

However, it would be nice to know if this was just a mistake or if the history shows that this is a good extension of the original trading strategy.
So is the 2 tick delay an advice  of the OP? Would love to read about it.
2weiX
Legendary
*
Offline Offline

Activity: 1638


View Profile
March 10, 2012, 10:31:52 AM
 #127

a) if you were to make this an android app, i'd buy it.
b) please remove restrictions as for the EMA numbers (i like to use 100/200, for example)
c) please remove restrictions as for the interval used (lowest: 5minutes, highest 1d, maybe)?
d) please make use of VWAP optionally instead of first price
e) for the android app, please add graphic chart widget


I can't code for the life of me. But if someone were to, I'd buy it.
matthewh3
Legendary
*
Offline Offline

Activity: 1372



View Profile WWW
March 10, 2012, 11:59:04 AM
 #128

a) if you were to make this an android app, i'd buy it.
b) please remove restrictions as for the EMA numbers (i like to use 100/200, for example)
c) please remove restrictions as for the interval used (lowest: 5minutes, highest 1d, maybe)?
d) please make use of VWAP optionally instead of first price
e) for the android app, please add graphic chart widget


I can't code for the life of me. But if someone were to, I'd buy it.

+1

Maybe it's just me being dyslexic but I get the feeling EMA 10, EMA 21 should be inverted to EMA 21, EMA 10 so the bot buy's BTC at <-0.25% and sells BTC at >+0.25%  Huh

BTC-engineer
Sr. Member
****
Offline Offline

Activity: 338



View Profile
March 10, 2012, 12:42:22 PM
 #129

a) if you were to make this an android app, i'd buy it.
b) please remove restrictions as for the EMA numbers (i like to use 100/200, for example)
c) please remove restrictions as for the interval used (lowest: 5minutes, highest 1d, maybe)?
d) please make use of VWAP optionally instead of first price
e) for the android app, please add graphic chart widget


I can't code for the life of me. But if someone were to, I'd buy it.

+1

Maybe it's just me being dyslexic but I get the feeling EMA 10, EMA 21 should be inverted to EMA 21, EMA 10 so the bot buy's BTC at <-0.25% and sells BTC at >+0.25%  Huh

The implementation of the referenced, original trend-following trading strategy is correct. The implemented strategy will not preserve you from loosing money, it's even more likely that you will loose on much more trades than you will win! And of course there is absolutely no guarantee! Using this bot is risky. If you think it's better to trade with inverted EMA's do it, no-one knows in which direction the trend will go.

I would suggest to keep this thread clean from discussions about trading strategies and focus on the technical implementation. There are a lot of other and better threads to discuss the different trading strategies.
matthewh3
Legendary
*
Offline Offline

Activity: 1372



View Profile WWW
March 10, 2012, 12:47:26 PM
 #130

a) if you were to make this an android app, i'd buy it.
b) please remove restrictions as for the EMA numbers (i like to use 100/200, for example)
c) please remove restrictions as for the interval used (lowest: 5minutes, highest 1d, maybe)?
d) please make use of VWAP optionally instead of first price
e) for the android app, please add graphic chart widget


I can't code for the life of me. But if someone were to, I'd buy it.

+1

Maybe it's just me being dyslexic but I get the feeling EMA 10, EMA 21 should be inverted to EMA 21, EMA 10 so the bot buy's BTC at <-0.25% and sells BTC at >+0.25%  Huh

The implementation of the referenced, original trend-following trading strategy is correct. The implemented strategy will not preserve you from loosing money, it's even more likely that you will loose on much more trades than you will win! And of course there is absolutely no guarantee! Using this bot is risky. If you think it's better to trade with inverted EMA's do it, no-one knows in which direction the trend will go.

I would suggest to keep this thread clean from discussions about trading strategies and focus on the technical implementation. There are a lot of other and better threads to discuss the different trading strategies.

Yeah but you can't change the settings to EMA 21, EMA 10 to the bot it won't let you  Huh

sukiho
Full Member
***
Offline Offline

Activity: 180


View Profile
March 11, 2012, 11:34:03 AM
 #131

 I have tried setting MaxHoursBack and MaxHoursToKeep >200 but still quite different to what Im seeing on bitcoin charts or siera for some reason
piotr_n
Legendary
*
Offline Offline

Activity: 1498


aka tonikt


View Profile WWW
March 11, 2012, 12:24:35 PM
 #132

I have tried setting MaxHoursBack and MaxHoursToKeep >200 but still quite different to what Im seeing on bitcoin charts or siera for some reason
Learn how to calculate EMA by yourself, it's basic math, not a rocket science.
Then you will know why the numbers are slightly different.

As I had said, it's mostly about the time window - how many historical candles you process before reaching the final one.
But its not the only factor which can affect the actual number.
I.e. almost all of the charts use the close price, while the extension uses the open price of each hour...

In any case, don't expect that making your EMA a bit more precise would cause the strategy to earn you more money. It doesn't work like that.
If you want to earn more with the strategy you should focus on optimizing the LONG/SHORT/TRESHOLD prams, instead of getting too pedantic with the EMA algorithm.

Check out gocoin - my original project of a bitcoin client written in Go, with some unique features.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
Clipse
Hero Member
*****
Offline Offline

Activity: 504


View Profile
March 11, 2012, 12:28:09 PM
 #133

piotr_n, Can you give me some pointers on how to change the history used to initiate the percentage difference for either buying/selling so that it doesnt wait 2ticks(2hrs) but calculates the ticks used over a shorter period of time ie. if you can point me to where in the source I would need to adjust the tick duration.

Basicly I want to focus on buying/selling as soon as the ema10 move above or below the ema21 and not delay it for an extra hour or 2 waiting on a new tick update. If I recall correctly goombla strictly mentioned that as soon as it cross is the correct time to trade(buy/sell) and delaying it wasnt part of the strategy.

...In the land of the stale, the man with one share is king... >> Clipse

We pay miners at 130% PPS | Signup here : Bonus PPS Pool (Please read OP to understand the current process)
piotr_n
Legendary
*
Offline Offline

Activity: 1498


aka tonikt


View Profile WWW
March 11, 2012, 12:37:48 PM
 #134

piotr_n, Can you give me some pointers on how to change the history used to initiate the percentage difference for either buying/selling so that it doesnt wait 2ticks(2hrs) but calculates the ticks used over a shorter period of time ie. if you can point me to where in the source I would need to adjust the tick duration.
Look for 3600 in the html files - 3600 represents 1 hour.
Then replace the string with 1800 for 30min, 900 for 15min and so on...

Basicly I want to focus on buying/selling as soon as the ema10 move above or below the ema21 and not delay it for an extra hour or 2 waiting on a new tick update. If I recall correctly goombla strictly mentioned that as soon as it cross is the correct time to trade(buy/sell) and delaying it wasnt part of the strategy.
if you want the first tick to trigger a trade, replace this fragment (in background.html):

Code:
if (dif>MinThreshold) {
chrome.browserAction.setBadgeBackgroundColor({color:[0, 128, 0, 200]})
if (USD>=0.01) {
if (getemadif(H1.length-2) > MinThreshold) {
console.log("BUY!!!")
mtgoxpost("buyBTC.php", ['Currency=USD','amount=1000'], one, onl)
}
} else {
//console.log("No USD to exec up-trend")
}
} else if (dif<-MinThreshold) {
chrome.browserAction.setBadgeBackgroundColor({color:[128, 0, 0, 200]})
if (BTC>=0.001) {
if (getemadif(H1.length-2) < -MinThreshold) {
console.log("SELL!!!")
mtgoxpost("sellBTC.php", ['Currency=USD','amount=1000'], one, onl)
}
} else {
//console.log("No BTC to exec down-trend")
}
} else {
if (dif>0) {
chrome.browserAction.setBadgeBackgroundColor({color:[10, 100, 10, 100]})
} else {
chrome.browserAction.setBadgeBackgroundColor({color:[100, 10, 10, 100]})
}
}

... with this:

Code:
if (dif>MinThreshold) {
chrome.browserAction.setBadgeBackgroundColor({color:[0, 128, 0, 200]})
if (USD>=0.01) {
console.log("BUY!!!")
mtgoxpost("buyBTC.php", ['Currency=USD','amount=1000'], one, onl)
} else {
//console.log("No USD to exec up-trend")
}
} else if (dif<-MinThreshold) {
chrome.browserAction.setBadgeBackgroundColor({color:[128, 0, 0, 200]})
if (BTC>=0.001) {
console.log("SELL!!!")
mtgoxpost("sellBTC.php", ['Currency=USD','amount=1000'], one, onl)
} else {
//console.log("No BTC to exec down-trend")
}
} else {
if (dif>0) {
chrome.browserAction.setBadgeBackgroundColor({color:[10, 100, 10, 100]})
} else {
chrome.browserAction.setBadgeBackgroundColor({color:[100, 10, 10, 100]})
}
}

Check out gocoin - my original project of a bitcoin client written in Go, with some unique features.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
Clipse
Hero Member
*****
Offline Offline

Activity: 504


View Profile
March 11, 2012, 12:42:41 PM
 #135

Great, let me give that a whirl.

...In the land of the stale, the man with one share is king... >> Clipse

We pay miners at 130% PPS | Signup here : Bonus PPS Pool (Please read OP to understand the current process)
piotr_n
Legendary
*
Offline Offline

Activity: 1498


aka tonikt


View Profile WWW
March 11, 2012, 12:47:02 PM
 #136

Also, if you want "as soon as...", you may want to shorten the period of how often the extension is checking if there is a new candle.
Now it is 3 minutes:
Quote
setInterval(updateH1, 3*60*1000) // recheck every 3 minutes

And make sure that the time set on your PC is quite precise.

Check out gocoin - my original project of a bitcoin client written in Go, with some unique features.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
Clipse
Hero Member
*****
Offline Offline

Activity: 504


View Profile
March 11, 2012, 12:47:27 PM
 #137

a) if you were to make this an android app, i'd buy it.
b) please remove restrictions as for the EMA numbers (i like to use 100/200, for example)
c) please remove restrictions as for the interval used (lowest: 5minutes, highest 1d, maybe)?
d) please make use of VWAP optionally instead of first price
e) for the android app, please add graphic chart widget


I can't code for the life of me. But if someone were to, I'd buy it.

+1

Maybe it's just me being dyslexic but I get the feeling EMA 10, EMA 21 should be inverted to EMA 21, EMA 10 so the bot buy's BTC at <-0.25% and sells BTC at >+0.25%  Huh

Currently its correct, when ema10 moves upwards across ema21 you are meant to buy and when it moves from top downward across ema21 you are meant to sell so the setup is correct.

...In the land of the stale, the man with one share is king... >> Clipse

We pay miners at 130% PPS | Signup here : Bonus PPS Pool (Please read OP to understand the current process)
Clipse
Hero Member
*****
Offline Offline

Activity: 504


View Profile
March 11, 2012, 01:11:40 PM
 #138

piotr_n, one last thing, Ive got everything set to 300(5mins) rather than 3600(60mins), I just need to figure out where to adjust the updates to reflect the 5min periods rather than 12periods displayed as the same hour ie. 13:00 is displayed 12times since it shows 12 periods of 5mins, can you show me where to adjust it so that it would write 13:05 , 13:10 etc.

...In the land of the stale, the man with one share is king... >> Clipse

We pay miners at 130% PPS | Signup here : Bonus PPS Pool (Please read OP to understand the current process)
piotr_n
Legendary
*
Offline Offline

Activity: 1498


aka tonikt


View Profile WWW
March 11, 2012, 01:17:47 PM
 #139

piotr_n, one last thing, Ive got everything set to 300(5mins) rather than 3600(60mins), I just need to figure out where to adjust the updates to reflect the 5min periods rather than 12periods displayed as the same hour ie. 13:00 is displayed 12times since it shows 12 periods of 5mins, can you show me where to adjust it so that it would write 13:05 , 13:10 etc.
popup.html - this line:
Code:
r.insertCell(-1).innerHTML=(new Date(bp.tim[i]*3600*1000)).getHours() + ":00"
you need to replace ":00" with... something else Tongue

Check out gocoin - my original project of a bitcoin client written in Go, with some unique features.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
Clipse
Hero Member
*****
Offline Offline

Activity: 504


View Profile
March 11, 2012, 01:21:35 PM
 #140

piotr_n, one last thing, Ive got everything set to 300(5mins) rather than 3600(60mins), I just need to figure out where to adjust the updates to reflect the 5min periods rather than 12periods displayed as the same hour ie. 13:00 is displayed 12times since it shows 12 periods of 5mins, can you show me where to adjust it so that it would write 13:05 , 13:10 etc.
popup.html - this line:
Code:
r.insertCell(-1).innerHTML=(new Date(bp.tim[i]*3600*1000)).getHours() + ":00"
you need to replace ":00" with... something else Tongue

Sweet, lets see how much failcake I can produce Tongue

...In the land of the stale, the man with one share is king... >> Clipse

We pay miners at 130% PPS | Signup here : Bonus PPS Pool (Please read OP to understand the current process)
Pages: « 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 »
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!