backtest | A simple & fast bitcoin trading strategy | Cryptocurrency library
kandi X-RAY | backtest Summary
kandi X-RAY | backtest Summary
A simple & fast bitcoin trading strategy backtesting tool.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of backtest
backtest Key Features
backtest Examples and Code Snippets
Community Discussions
Trending Discussions on backtest
QUESTION
My strategy looks like this:
...ANSWER
Answered 2021-Jun-08 at 18:13Every time your buy_signal
variable became true, barssince()
would return zero, so now we use the bar count from the previous bar.
We added something for your longStop
variable because it was missing. Keep in mind this is the stop-buy level, as well as debugging plots at the end:
QUESTION
I have two questions:
- I wanna replace
redCandlesCounter
with barssince, because it looks better. The thing is when I do that:if (barssince(not isCandleGreen and close > middleBand and open < upperBand) > 2 and isLong)
kinda breaks the logic by selling on the next candle, which is not what I want. By the way, the tests were done on GTO/USDT (Binance) 30m interval, pictures are at 30 Mar '21 18:30.
- A sexier way to replace
isCandleGreen = close > open
?
ANSWER
Answered 2021-Apr-15 at 14:15I guess, you can try to use barssince like this:
QUESTION
I'm reading PineCoders' FAQ and more precisely how to optimize the code. I want to replace valuewhen
in the following scenario. I assume they mentioned it because of the warning about repainting when creating alerts?
Use techniques like this one whenever you can, to avoid using valuewhen().
How should I avoid valuewhen
in the following case?
ANSWER
Answered 2021-May-31 at 16:38See how we use:
QUESTION
I'm trying to accomplish trade direction (Long/Short/Both) in study mode, just like LucF and PineCoders did here.
Issues:- When I select "Longs Only", I expect it to show only long trades, but it doesn't due to the missing the part which finds the range of the candles in the long trade. If you check the link I gave above (Backtesting & Trading Engine [PineCoders]), LucF uses InLong, InShort, InTrade variables. The problem is that his code is older and too overengineered for me and I don't get the idea on how to recreate it.
I said overengineered, because his code includes pyramiding, slippage and other stuff that are now built-in TradingView, probably because back in 2019, PineScript didn't have such features.
The actual idea behind that indicator is to plot alerts and another script which backtests it using that indicator as a source.
- The bar coloring part is not working and it is currently commented, so the code can compile. The problem is the same as above's description. I need to know whether I'm in a long trade direction or short or not in a trade at all. I don't know how to accomplish that part.
ANSWER
Answered 2021-May-31 at 16:13This will get you started. We:
- Follow the states of shorts/longs, which makes it possible to plot stop and entry levels only when we are in a trade.
- Made the
doLongs/doShorts
inputs part of the entry conditions. - Added the breach of stops to the exit conditions.
Note that this logic does not replicate that of the Engine, as here you are entering on closes, whereas the Engine is entering on the next bar following the detection of the entry/exit conditions, which is more realistic. You can also adapt your code to proceed that way:
QUESTION
I have written several python scripts that will backtest trading strategies. I am attempting to deploy these through docker compose.
The feeder container copies test files to a working directory where the backtester containers will pick them up and process them. The processed test files are then sent to a "completed work" folder. Some CSV files that the backtester outputs are then written to an NFS share on another computer. I should mention that this is all running on Ubuntu 20.04.
As far as I can tell everything should be working, but for some reason the "docker-compose up" command hangs up on "Attaching to". There should be further output with print statements (I've unbuffered the Dockerfiles so those should show up). I've also left it running for a while to see if anything was getting processed and it looks like the containers never started up. I've looked at all the other threads dealing with this and have not found a solution that has worked to resolve this.
Any insight is very very appreciated. Thanks.
Here is the docker-compose file:
...ANSWER
Answered 2021-May-28 at 13:48It's been three weeks with no responses, but I just wanted to update with what I've found. In all cases where I've left "docker-compose up" running it eventually started.
At times it took 30 minutes, but it started every time.
QUESTION
So this is driving me crazy now, cause I really don't see the problem.
I have the following code:
...ANSWER
Answered 2021-May-14 at 14:54There is a typo:
QUESTION
I was trying to backtest a Strategy that relies on Depth of Market (DOM) data.
Unfortunatley that data can't be accessed in Pinescript, nor can I access by calling an API (please correct me if wrong!)...
So instead I am trying to hardcode the values into my script as per this FAQ: https://www.pinecoders.com/faq_and_code/#how-can-i-initialize-a-series-on-specific-dates-using-external-data
I'm playing around with a modified version of the code taken from the above link, but I can't get it to display correctly.
What I expect to happen: I thought it would print 5 single dots at 1am, 2am, 3am, 4am, and 5am on the 5th of May. Each dot would be 1 step higher than the next.
What happens instead: It prints 24 dots, one for each hour of the 5th of May. All the dots are in the same level, there is no stepping.
Here is the code I am using:
...ANSWER
Answered 2021-May-11 at 14:46Your timestamp
has no hour
variable, so it's always fixed at May 1st, 00:00h.
That only matches your first line, so the output will always be 1
.
This will work:
QUESTION
Is there any reading you recommend about the following issue? I still did not find an answer to it
strategy.exit (or also strategy.order) parameter "qty". I am passing qty as 25% of the initial position size.
Example: position size is 11, then exit qty is 2.75. After 4 times (4 orders triggered) it should be completely out (meaning exited the full position). Strategy backtest is taking only -2 out each time. Leaving positionsize higher than 0 after 4 times.
...ANSWER
Answered 2021-May-10 at 18:19There is a minimum position size associated with each market. The value isn't visible to scripts or through the charts UI, but the broker emulator uses it in strategies. Your market may not allow fractional position sizes.
QUESTION
How to backtest Strategy in pine script more than a year?
I have strategy for nifty in 5 mins chart. when I am running it, it shows result only for last 100 days.. previous data not visible in the chart.
but, if I keep chart time frame more than 5 mins data (candles) come more than that, more time frame more dates back shows.. but my strategy works in 5 mins. I would like to test it for last two / five years.. How to do it?
...ANSWER
Answered 2021-May-05 at 09:56The depth of history is measured in bars—not time. The quantity of bars on charts varies with your type of account. See this PineCoders FAQ entry for more information.
Disclosure: the link in this answer points to a PineCoders FAQ entry.
I am a member of the PineCoders community and I most probably wrote that FAQ entry. PineCoders is a TradingView-supported group of volunteer Pine coders and PineCoders' website is strictly educational. Neither TradingView nor PineCoders benefits financially from sending traffic to pinecoders.com, and the site contains no affiliate/referral links.
QUESTION
I have a csv file / pandas dataframe
which looks like this. It contains various portfolio compositions for a portfolio which is re-balanced everyday according to my own calculations.
ANSWER
Answered 2021-Apr-22 at 15:55The first thing you will want to do it load your targets with your datas. I like personally to attach the target to the dataline as I add it to backtrader.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install backtest
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page