OPEN-SOURCE SCRIPT

ComiCo - Joel on Crypto - MACD Scalping

מעודכן
This is a modified (hopefully improved) version of the "Joel on Crypto - MACD Scalping" indicator. It got turned into a strategy, and added some extra filters, like number of trades after EMA cross, minimal EMA distance (EMA 50's distance from the EMA 200). It is just an experiment to see how good this scalping strategy can get.

Play around with it and let me know if you found good settings, or just have a comment on it.


I could get fairly good results on BTCUSDT 5m with these settings (all others left on default values):

Ticks Avg. Multiplier = 1.4
Max trades after EMA cross = 16
Limit Price Difference = 0
Take Profit = 0.0065
Stop Loss = 0.0085
Min EMA difference = 110

Pyramiding = 3
הערות שחרור
Updated some inputs to be more meaningfull, expressed in %
New "best " values (based on deep backtest between 2019-01-01 and 2022-07-12) (all the other values left default):

Ticks Avg . Multiplier = 1.4
Max trades after EMA cross = 22
Limit Price Difference (%) = 0
Take Profit (%) = 0.65
Stop Loss (%) = 0.9
Min EMA difference (%) = 0.85

Pyramiding = 3
הערות שחרור
Added a new parameter: "Max. EMA difference" to limit value from the top as well. It was worth it.
I am doing deep backtesting from 2019-01-01 till today (2022-07-15) and the backtested profit seems to be not only comfortably high, but also fairly consistent throughout the years. Of course as a scalping strategy, it is very sensitive to broker fees. (And past results are no way a guarantee of future performance, of course:) )

I could reach good results with the following settings (all the other values left default):

Ticks Avg . Multiplier = 1.4
Max trades after EMA cross = 20
Limit Price Difference (%) (0-> market order) = 0
Take Profit (%) = 0.85
Stop Loss (%) = 1.1
Min. EMA difference (%) = 0.8
Max. EMA difference (%) = 3.1
הערות שחרור
Added controls to limit which signals to take as valid in case there are signals directly after each other.

I could reach good results with the following settings (all the other values left default):

Ticks Avg . Multiplier = 1.4
Max trades after EMA cross = 19
Act on the first N signal (min) = 1
Act on the first N signal (max) = 5
Limit Price Difference (%) (0-> market order) = 0
Take Profit (%) = 0.85
Stop Loss (%) = 1.25
Min. EMA difference (%) = 0.82
Max. EMA difference (%) = 3.1
הערות שחרור
Adapted the strategy to the aleeert service, a connector between trading view and binance.

Parameters are mostly the same, but here is a guide how to enter my tested parameters:
Change the following settings (all the other values left default):

Ticks Avg . Multiplier = 1.4
Max trades after EMA cross = 19
Act on the first N signal (min) = 1
Act on the first N signal (max) = 5
Limit Price Difference (%) (0-> market order) = 0
Take Profit (%) = 0.9
Stop Loss (%) = 1.3
Min. EMA difference (%) = 0.82
Max. EMA difference (%) = 3.1

Pyramiding = 20

the "ALEERT" section is for aleeert specific settings, you will probably get it if you got aleeert.

Of course ask if anything is unclear :)
הערות שחרור
minor typo corrections
הערות שחרור
Added a basic User's Guide, if you get lost any time, try to use it, hopefully it will help.
הערות שחרור
Chart and User's Guide updated.
הערות שחרור
Chart updated again.
הערות שחרור
Added a new Time Filter, so that you can restrict trading to weekdays, and to two time-periods.

Parameters are mostly the same, but here is a guide on how to enter my favourite parameters (your favourite may differ from these):
Apply the following settings (all the other values left default):

Symbol: BTCBUSD PERPETUAL FUTURES from Binance
Timezone: UTC-4
Timeframe: 5 min

Ticks Avg . Multiplier = 1.39
Max trades after EMA cross = 19
Act on the first N signal (min) = 1
Act on the first N signal (max) = 6
Limit Price Difference (%) (0-> market order) = 0
Take Profit (%) = 0.9
Stop Loss (%) = 1.3
Min. EMA difference (%) = 0.82
Max. EMA difference (%) = 3.1
Use Weekdays filter? = true
Weekdays to select: Mon, Tue, Wed, Thu, Fri
Use Session Filter = true
Time Period: 02:00-11:30
Use 2ND Session Filter = true
Time Period: 13:00-00:00

Pyramiding = 14

The "ALEERT" section is for aleeert specific settings, you will probably get it if you got aleeert.

Of course ask if anything is unclear :)

The User's Guide is updated as well.
הערות שחרור
Added a new option to be able to switch from EMA to SMA, DEMA, TEMA for determining the overall trend. I don't have the best settings for it, but go on and experiment with it :)

The values that need to be readjusted after changing a moving average method are at least the following:
Fast MA lenght
Slow MA lenght
Min. MA difference (%)
Max. MA difference (%)

The default value is still EMA, so all the old settings function like before.
הערות שחרור
Added another automated trading option, namely "TradingView To Anywhere" - mt4 version.
Added an economic news event effect avoidance option, where you can select which events to exclude from trading using an adjustable time window. These events had to be added to the source code, so it can only contain the latest news schedule available right now. It is "2022 Feb 02, 15:30 - Continuing Jobless Claims". After this event, the strategy will work like it worked before without "news effect avoidance". Of course I plan to give you an update before that date:)
The "best" values I concluded to with my backtestings are the actual default values.
הערות שחרור
There is an economic news event effect avoidance option, where you can select which events to exclude from trading using an adjustable time window by selecting the "true" or "false" values. These events had to be added to the source code, so it can only contain the latest news schedule available right now. It is "2023 Feb 28, 15:30 - Goods Trade Balance (Jan)". After this event, the strategy will work like it worked before without "news effect avoidance". Of course I plan to give you an update before that date:)
The "best" values I concluded to with my backtestings are the actual default values.
הערות שחרור
Fixed a bug in the News Avoidance module.
הערות שחרור
Economic calendar updated till the 14th of April 2023.
הערות שחרור
Fixed a problem on the aleeert automaiton side:
Rarely by closing the positions, a tiny portion was left open. Than if the stategy wanted to open an opposing direction position, aleeert gave an error, because of the position that was unintentionally left there. Now it is fixed by intentionally always closing the opposing direction position.
הערות שחרור
Added an extra time filter for Friday market close.
הערות שחרור
Added a dedicated time filter for Sundays.
הערות שחרור
Economic calendar updated till the 26th of May 2023.
Changed Sunday to be selected together with the active the Sunday filter.
הערות שחרור
It is a hotfix for the situation if the price moves so fast, that aleeert can't place the TP or SL, as the price is over the trigger price. Now with the fix whenever TradingView detects that a trade should be closed, a maket close is sent to aleeert. Than either the TP or SL order is executed, or the market close, whichever if faster. Most probably the TP or SL will be faster, but if for whatever reason it couldn't be placed, the market close kicks in.
הערות שחרור
Economic calendar updated till 2023.07.07.
הערות שחרור
- Added a way to limit how many trade groups can be traded after the EMA cross. Couldn't find a profitable way to use it, however just try it out :)
- Added trailing stop as well. The aleeert automated trading is adapted to it, but I never tested, be aware if you plan to use it. First it's better to play around with the settings. Be aware, that the trailing stop backtesting can return greatly differing results if you don't know what you do. Bar Magnifier is your friend in this case, but also be sure you understand how it works ;)
הערות שחרור
The economic news calendar was accidentally used from an older version. It got fixed now, the new last date of the economic calendar is 2023.07.07.
Please update to this version if you use the previous one. Otherwise the news effect avoidance won't work.
הערות שחרור
It should be a usual update of the economic calendar, but my source of the calendar website is not available, so I had to fabricate the next some events by hand. So, now we are only covered till the 18th of july 2023.
הערות שחרור
Economic calendar updated till 2023.09.14.
הערות שחרור
Added optional display for the actual TP and SL levels.
הערות שחרור
advanced the TP and SL display
הערות שחרור
Added experimental features - doesn't effect the normal operation.
הערות שחרור
Economic calendar updated until 2023.11.22.
הערות שחרור
Updated till the end on January 2024.
Exponential Moving Average (EMA)Moving Average Convergence / Divergence (MACD)Moving Averagestimefilter

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור