J2897

Strategy Notes

Jan 28th, 2023 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Stoploss

stoploss = -0.121

The stoploss attribute specifies the maximum loss on a trade, expressed as a negative percentage. So this stoploss is set to -12.1%, meaning to close out a trade if the loss on the trade exceeds 12.1%.

Value Meaning
-1 The stoploss is set to 100% of the purchase price. If the price drops by 100% or more, the position will be closed.
-0.5 The stoploss is set to 50% of the purchase price. If the price drops by 50% or more, the position will be closed.
-0.1 The stoploss is set to 10% of the purchase price. If the price drops by 10% or more, the position will be closed.
0 The stoploss would be disabled, which is not possible.

ROI

Return on Investment (ROI) is a measure of the profitability of an investment. It is calculated by dividing the gain from the investment by the cost of the investment, and is usually expressed as a percentage.

minimal_roi = {
    "0": 0.049,
    "5": 0.023,
    "13": 0.014,
    "30": 0
}
timeframe = '1d'

The above values represent a minimum ROI of 0.049 for trades held for 0 days, 0.023 for trades held for 5 days, 0.014 for trades held for 13 days, and 0 for trades held for 30 days.

To express the minimum ROI values as a percentage, you simply multiply them by 100:

  • For 00 days, the minimum ROI is 0.049, which is equivalent to 4.9%.
  • For 05 days, the minimum ROI is 0.023, which is equivalent to 2.3%.
  • For 13 days, the minimum ROI is 0.014, which is equivalent to 1.4%.
  • For 30 days, the minimum ROI is 0, which is equivalent to 0%.

So the values in the minimal_roi dictionary aim for a minimum ROI of 4.9% for trades held for 0 days, 2.3% for trades held for 5 days, 1.4% for trades held for 13 days, and 0% for trades held for 30 days.

Another example on a different timeframe:

minimal_roi = {
    "0": 0.04,        # TP at 4% immediately.
    "20": 0.02,       # TP at 2% after 20 minutes.
    "30": 0.01,       # TP at 1% after 30 minutes.
    "40": 0.0         # TP at break-even after 40 minutes.
}
timeframe = '1m'
  • If a trade has been open for less than 20 minutes, exit the trade as soon as the ROI reaches 4% or greater.
  • If a trade has been open for 20 minutes or more, but less than 30 minutes, exit the trade as soon as the ROI reaches 2% or greater.
  • If a trade has been open for 30 minutes or more, but less than 40 minutes, exit the trade as soon as the ROI reaches 1% or greater.
  • If a trade has been open for 40 minutes or more, exit the trade as soon as it becomes a non-losing trade - i.e. the ROI becomes 0 or greater.

They're basically just countdown timers to take profit at reducing levels.

Add Comment
Please, Sign In to add comment