Good Day
So a about a week ago I got the idea to code a strategy to exclusively trade XBTUSD (Bitcoin). The idea was to write an algorithm that will keep up with the tremendous bullish momentum of the price while reducing drawdown compared to a buy and hold strategy, but at the same time to be ready to short the hell out of it when things start going south! So yesterday I finally got to see it in action as we saw a minor crash and the result was simply glorious!
The strategy is actually quite simple as it is primarily based around 3 moving averages (5 minutes apart) along with a ADX check for volatility.
//Bitcoin Tripple MA Miner 1Min
//Author: Juan Jacobs
//Exchange: XBTUSD Mini
//Timeframe: 1Min
//Spread: 10 or 20
DEFPARAM FLATBEFORE = 100000 //Adjust for your timezone (currently set for GMT+2)
DEFPARAM FLATAFTER = 230000 //Adjust for your timezone (currently set for GMT+2)
FMA = Average[12,4](close) //Fast Moving Average
MMA = Average[17,4](close) //Medium Moving Average
SMA = Average[22,4](close) //Slow Moving Average
stp = 2 //Points away to place stop orders
If hour < 10 or hour > 23 then //Adjust to match Flat Before/After
possize = 0
If longonmarket then
SELL AT MARKET
ElsIf shortonmarket then
EXITSHORT AT MARKET
EndIf
Else
If ADXR[14] > 18 Then //Check for enough volatility
possize = 1
Else
possize = 0
EndIf
EndIf
If countofposition = 0 or shortonmarket and FMA > MMA and MMA > SMA Then
If shortonmarket then
If close > close[3] and close > close[5] Then
Exitshort at market
Buy possize contract at open - stp stop
EndIf
Else
Buy possize contract at open - stp stop
EndIf
ElsIf countofposition = 0 or Longonmarket and FMA < MMA and FMA < SMA Then
If longonmarket then
If close < close[3] and close < close[5] Then
Sell AT MARKET
Sellshort possize contract at open + stp stop
EndIf
Else
Sellshort possize contract at open + stp stop
EndIf
EndIf
SET STOP $LOSS 100*possize
SET TARGET $PROFIT 1500*possize
You must be logged in to post a comment.
Okay, so I revisited this strategy today and it appears to have started working again on the Bitcoin USD (1) instrument. I literally haven't touched the code in more than 6 months and the result I am getting on the 1Hr Timeframe with a spread of 10 is very interesting especially from December.
Good Morning,
The strategy seems very interesting, thanks Juanj for sharing it. But unless I'm wrong, I think the results of the backtest do not correspond to reality. This morning I put it to work demo account and there is a very big difference in the results with the backtest.
Regards
if the bitcoins are quoted in hundreds of thousand, asthey are now in ig uk, the spread is 2000, if they are quoted in thousands like in your code the spread is 20.
that is the message from IG
| Due to the rise in bitcoin’s price over the past year, we are changing the way we quote the price for this market to make it easier to trade. From Saturday 3 June, we’ll be quoting bitcoin in a larger currency domination. So if you deal in USD, instead of quoting bitcoin in cents (ie a six-digit number) we will be quoting in dollars (a four-digit number). So for example, instead of seeing 267038, you’ll see 2670.38. |
|
What does this mean for bitcoin positions?
|
| If you have any open spread bets or working orders on bitcoin at close of business on Friday 2 June, the next time you log in you’ll see the following changes: • The market price will have been downscaled by a factor of 100 • Your position size will have been upscaled by a factor of 100. So £1.50/point of bitcoin at 267038, will change to £150/point of bitcoin at 2670.38. Your overall exposure will remain exactly the same as it is now. The market will reopen for trading at 8am on Sunday as normal. |
Ah I thought you meant 20 is too small as a spread for Bitcoin, I traded them since last agoust, I can confirm the spread is most of the time 10, but in the recent explosion of cryptocurrency prices it was very often 20 ans sometime even 40. IG uk decided that from next week the price quotes will be divided by a factor 100 as the pricese increases by 100% in a couple of weeks.
Interestingly I noticed that the spread usually quotes as 10 and lately sometimes as 20, probably due to the reasons Maz so eloquently explained. Funny thing is I just ran the code this morning and my result now looks different compared to when I posted the strategy. It is still equally as profitable and even made a bucket load of money in the last trading session but it didn't open any trades during the first correction as can be seen in the screenshot I made. It did open trades during the latest ones which is good. Overall I find this strategy quite enjoyable seeing it is literally raking in money in every session (albeit I have to admit I am not trading it Live). The pure size of the XBTUSD contracts makes it rather dangerous to a mere mortal account size such as my own. Price jumps amounting to around $1000 in a matter of minutes is a bit too exuberant for me. Although It still brings me joy to watch it trade my paper account of $100k
At this time trading BTC/crosses via leveraged spread betting or CFD derivatives is very expensive to the directional trader. This is due to the huge counter-party risk that is posed to risk-averse brokers. They offset this risk (and the huge volatility) by offering massive spreads. On the other hand they are giving you leveraged liquidity (100x and more) on BTC, 24 hours a day - so its their privilege to quote you whatever spread they like. With the offer of 7 figure accounts I found it hard to convince certain brokerages otherwise - plus they were unwilling to provide us with the liquidity we were asking for. The CFD and SB offerings are really just for buy and holders. The way we trade bitcoin is directly with the exchanges around the world - you get tiny spreads now - but market depth can be an issue at certain times of day. The system needs more market makers, more liquidity. If investment banks jump on board and if we see ETFs, spreads may come down in retail shops.
Looks like his quotes are in thousands instead then hundredsthousands.. so spread of 20 might make sense
Bonjour et merci pour votre partage ! J'ai constaté qu'en 1 seconde, on avait quelque chose de très bon ! Mais pas dans le bon sens du marché... est-il possible de retourner les achats/ventes pour rendre les ordres positifs ? Merci d'avance