Coder Social home page Coder Social logo

Comments (3)

conor19w avatar conor19w commented on July 26, 2024

I've removed the typo, still need to fix trailing stop in the back tester seems to result in inflated profits the logic is messed up somehow.

from binance-futures-trading-bot.

luki009 avatar luki009 commented on July 26, 2024

I've got idea why profits are inflated or maybe even deflated. I see that in backtester is calculation if SL, TP, TSL is triggered based on candle close. This might be issue because if you look on candles there are swings up and down. In real time data those swings could trigger either SL or TP/TSL but in backtest will not because are not catched. Considering 1 minute candle as you do in backtest was great idea and it make good precision for calculation. What can make it even more precise is to consider also 1 minute candle High and Low values for decision if SL, TP, TSL was triggered or not .. Let see example:

takeprofitvalue = 0.2
entry_price = 4.3
take_profit_price = 4.3 +0.2 = 4.5
backtest 1 minute candle close = 4.49 - in backtest this will not be considered / calculated as TP triggered.
real situation:
backtest 1 minute candle high = 4.51 - which should trigger TP but in backtest will not

This can be solved with:
LONG POSITION
TP condition: High >=TP instead of Close >= TP or
SL condition: Low <= SL instead of Close <= SL
Same goes for opposite way.

Issue here is how to decide which swing was first .. either Low or High but this is irrelevant in case that you are not doing backtest for 1m interval (really close SL and TP to each other).
If interval is set to 5m and higher trigger point can be calculated just based on high values if candle is Bullish or Low value if candle is Bearish
In case you would want to solve this also for 1m interval. I would do estimated guess what was first :
if candle is Bullish then first swing was Low then High and then Close
if candle is Bearish then first swing was high then Low and then Close
there is not other option to estimate it without tick in time data.

Correct me if i'm wrong or wrongly understood logic for calculation.... I did not found any other possible error in calculations logic.

from binance-futures-trading-bot.

conor19w avatar conor19w commented on July 26, 2024

Yeah your logic is sound I had a similar thought recently the highs and lows would be a better price value to consider.
Yeah I can't find any errors either, but if you run any of the strategys with the trailing stop it just explodes into the millions currently I'm fairly sure, heres a screenshot I just ran haha no way these results are correct so must be a rounding error.
image

It does hint at a bug though, opens a position on doge and doesnt close it but then opens a position on rose which shouldn't happen in the backtester... so maybe we can find the bug. Trailing stop is huge on doge and python is prone to rounding errors, if this is the issue in order to solve I may need to use a decimal library to represent the numbers.

from binance-futures-trading-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.