sonnyparlin

SMA Offset Strategy

sonnyparlin تم تحديثه   
This strategy uses simple moving averages and some math to determine buy/sell points. We keep a SMA 100 day line as our basis for our offset. If the close price is below the line, we choose our open position based on how low below the line it is goes, this value (Low Offset) is a percentage and can be configured by the user. Same for closing your position, when the close is above our SMA 100 line, we determine how high above the line before selling. If we try to sell too early (while the price is still rising), the trailing stop loss will kick in. Backtested with Bitcoin and Ethereum.

Configurable variables:
  • SMA Fast (default is 14 days)
  • SMA Slow (default is 100)
  • SMA Reference (default is 30)
  • Low Offset % (default is 0.001)
  • High Offset % (default is 0.0164)
  • Order Stake % (default is 0.96)
  • Trailing stop loss % (default is 1.35)
ملاحظات الأخبار:
Modified it to guard that we're under the slow line instead of the reference line.
ملاحظات الأخبار:
Clean chart for publishing.
ملاحظات الأخبار:
Pretty big rewrite, now contains both stoploss and trailing stoploss. Tailing stoploss is defined by ticks, so it's going to play different with different pairs. I back tested this with ADAUSDT and that's how it's set up at the moment. On a side note, I couldn't get the stoploss and trailing stoploss to work using strategy.exit() so I had to do it manually using if/else conditions. Curious if anyone else has had this problem or if I'm just doing something incorrect.
ملاحظات الأخبار:
Made the dialog a little more clear. Also wanted to remind you to use 1 hour candles.
ملاحظات الأخبار:
Added comments for clarity.
ملاحظات الأخبار:
Last note, the stop loss, trailing stoploss and trailing start line are all plots you can turn on in the settings.
ملاحظات الأخبار:
Another note: we no longer use a high offset for selling, we basically stay in the trade until our trailing stoploss gets triggered. A couple of other exit conditions exist, we have a stoploss and we also have a micro stoploss for trades that go above the trailing stoploss start line but come back down before the trailing stoploss gets triggerred, that little hack backfires once in a while and you miss a nice climb, but the money it saves you in the long run is worth it.
ملاحظات الأخبار:
Added ability for the user to use the micro stop or not. The micro stop gets triggered when a candle goes above the trailing stop loss start line, but the trailing stop hasn't yet activated, it will sell if it crosses back under the trailing stop loss start line. The trailing stop loss seems to get triggered once the stoploss line itself goes above the trailing stop loss start line, not when the candles do. Not sure why.
ملاحظات الأخبار:
Removed unused input.
ملاحظات الأخبار:
Removed all references to unused moving average.
ملاحظات الأخبار:
Updated default values fo chart.
ملاحظات الأخبار:
New chart.
ملاحظات الأخبار:
Added link to tutorial videos loom.com/share/folde...4313a4c2ab217d33a527
ملاحظات الأخبار:
Modified step values for easier to use interface.
ملاحظات الأخبار:
Updated step values so we can have negative ticks for setting the trailing stop start point.
ملاحظات الأخبار:
Added a note for ADAUSDT users on BINANCE_US. This chart is using BINANCE, which may be using different tick settings than BINANCE_US, I added a comment with settings you can use for BINANCE_US. Also updated the chart and the default values.
ملاحظات الأخبار:
Added additional condition to buy if our slow moving average is rising.
ملاحظات الأخبار:
Pretty big update here. Big thanks to Paul D Mendes for his guidance on how to properly set up stops and trailing stops. Also set up a take profit option and modified the offset code slightly to have more of an effect when you play with the numbers. I advise you to really spend time playing with the numbers, you can really dial it in per pair. I have it set up (as of this release date) making over 66000% in returns over the backtest period with a Sortino ratio of over 9. For reference, a Sortino ratio greater than 1.0 is considered acceptable, 2.0 is considered very good and 3.0 or higher is considered excellent. I find this strategy works best on a 1 hour timeframe.
ملاحظات الأخبار:
Removed buy condition #2 brings about more overall profit, I left the code in there in case anyone wants to turn it back on. I just don't think it's needed.
ملاحظات الأخبار:
chart update
ملاحظات الأخبار:
Ran into an order limit error so I edited the code for that specific error. Not sure if it's exhange/pair related or it's a Tradingview limit. Either way, I added lines 45 and 46 to get rid of it. Also changed the chart to a 5 minute chart and have the settings set for ETHUSD on Tradestation. Sharpe is over 1, Sortino is over 18, net profit is 122732% and percent profitable is over 90%.
ملاحظات الأخبار:
Updated to Pinescript 5 and made a couple of changes, best with Day long candles.
ملاحظات الأخبار:
Added fee structure to strategy.
ملاحظات الأخبار:
Removed comment....
ملاحظات الأخبار:
Small code change for readability.
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟