INVITE-ONLY SCRIPT
Telah dikemas kini

Miyagi Backtester

1864
Miyagi: The attempt at mastering something for the best results.
Miyagi indicators combine multiple trigger conditions and place them in one toolbox for traders to easily use, produce alerts, backtest, reduce risk and increase profitability.

The Miyagi Backtester is a standalone backtester which is to be applied to the chart after the Miyagi indicator to be backtested.
The backtester can only backtest one script at a time, and is meant to backtest ONCE PER BAR CLOSE entries.
It is currently not possible to backtest ONCE PER BAR entries.

The backtester will allow users to all Miyagi Indicators using DCA strategies to show returns over a selectable time period.
The backtester allows leverage, and as such users should be aware of the Maximum Amount for Bot Usage and Leverage Required Calculations.

The DCA Selector switch will allow users to backtest with, or without DCA.
Static DCA is used within the backtester and allows users to see DCA Statistics on closed trades.


How to use the Miyagi Backtester
Step 1: Apply the Miyagi Indicator of Choice to backtest (4in1/10in1/Strend).

DATE AND TIME RANGE:
-Date and time range to backtest.

TRADE:
-Entry source to backtest. Please select the "Outbound Entry Signal Sender"
-Trade Direction to backtest. This can be helpful to backtest according to your strategy (long or short).
-Take Profit % to backtest. This is the percent take profit to backtest. Slippage can be accounted for on the "Properties" tab.
-Stoploss % to backtest. This is the percent stoploss to backtest.

DCA:
DCA Checkbox: Enable the DCA Checkbox to backtest with DCA. Disable it to backtest without DCA.
Leverage: Input the Leverage you will trade with.
Base Order Size (% Equity): This is the Base order (BO) size to backtest in % of equity.
Safety Order Size (% Equity): This is the Safety order (SO) size to backtest in % of equity.
Number of DCA Orders: This is the maximum amount of DCA orders to place, or total DCA orders.
Price Deviation (% from initial order): This is the percent at which the first safety is placed.
Safety Order Step Scale: This is the scale at which is applied to the deviation for the step calculation to determine next SO placement.
Safety Order Volume Scale: This is the scale at which is applied to the safety orders for the volume calculation to determine SO Volume.

Real world DCA Example:

The process is as follows.
Base Order: This is your initial order size, $100 used for Base Order
Safety Order: This is your first safety order size, which is placed at the deviation. $100 Safety Order, it is good to keep the same size as your BO for your scaling to be effective.
Price deviation: This is the deviation at which your first Safety order is placed. 0.3-0.75% used by most of our members.
Safety Order Volume Scale: This is the scale at which is applied to the safety orders for the volume calculation. Scale of 2 used, which means that SO2 = (SO1) * 2, or $200. This scaling is typical for all following orders and as such SO3 = (SO2) *2, or $400.
Safety Order Step Scale: This is the scale at which is applied to the deviation for the step calculation. This is similar to the volume scale however the last order percentage is added.
Scale of 2 used, which means that SO2 % = ((Deviation) * 2) + (SO1%). (0.5% *2) + (0.5) = 1.5%.
This scaling is typical for all following orders except that the prior deviation is used and as such SO3 = ((Prior%) * 2) + (Deviation). (1.5% * 2) +(0.5%) or 3.5%.
Total SO Number: The calculations will continue going until the last SO. It is helpful to understand the amount of SO’s and scaling determines how efficient your DCA is.


Backtester Outputs include:
Net Profit to display net profit
Daily Net Profit to estimate
Percent Profitable which shows ratio of winning trades to losing trades.
Total Trades
Winning Trades
Losing Trades (only applicable if stoploss is used)
Buy & Hold Return (of the backtested asset) to compare if the strategy used beats buy & hold return.
Avg Trade Time is very helpful to see average trade time.
Max Trade Time is very helpful to see the maximum trade time.
Total Backtested Time will return total backtested time.

Initial Capital which is taken from the Properties tab.
Max amount for Bot Usage which can be helpful to see bot usage.
Leverage Required will show you the leverage required to sustain the DCA configuration.
Total SO Deviation will allow users to see the drop coverage their DCA provides.
Max Spent which is a % of total account spent on one trade.
Max Drawdown which displays the maximum drawdown of any trade.
Max % distance from entry shows the maximum distance price went away from entry prior to the trade closing.
Max SO Used which shows the maximum number of SO's used on a single trade
Avg SO Used which shows the average number of SO's used in all closed trades.
Deals closing with BO Only calculation will show how many trades are closed without DCA.
Deals closing with 1-7 SOs calculation will show how many trades are closed with DCA, and allow for fine-tuning.

Happy Trading!

This script will be effective to backtest and produce the best settings for each timeframe and pair across all STP Scripts.
This will take a lot of the manual work out of backtesting for our users while improving profit potential.

Happy Trading!
Nota Keluaran
leverage calculations removed
Nota Keluaran
Updated minval for DCA
Nota Keluaran
DCA FIX
Nota Keluaran
Update for Percent and Dollar entry sizing on backtests
Update for chart position.

Min value 0.01 update for TP/SL/Price Deviation
Nota Keluaran
Entry fix for percent and dollars
Nota Keluaran
Backtester update for Close Opposite side
Nota Keluaran
added light and dark mode on toggle
added miyagi position summary table for DCA calculations

Nota Keluaran
Updated visuals and DCA Calculations
Nota Keluaran
Tooltip updates
Nota Keluaran
Tooltip updates
Nota Keluaran
Tooltips updated, again
Nota Keluaran
External Signal Source Updates
Nota Keluaran
Stoploss adding Initial Entry price, current entry price, and max bars elapsed feature (time based stoploss)
Allowing up to 2 external signal sources for backtest.
Nota Keluaran
Stoploss/DCA fix and def value changes
Nota Keluaran
-Removed the "Max % from entry" for calculation as it is similar to "Max Drawdown" only without leverage
-Added "Average Drawdown" with tooltip
Nota Keluaran
Backtester adjustments to immediately enter a trade after the trade has closed and if the entry conditions are still present.
Nota Keluaran
Miyagi: The attempt at mastering something for the best results.
Miyagi indicators combine multiple trigger conditions and place them in one toolbox for traders to easily use, produce alerts, backtest, reduce risk and increase profitability.

The Miyagi Backtester with ATR builds upon the original standalone backtester which is to be applied to the chart to backtest an external script.
The new ATR Backtester adds in ATR based backtesting for DCA, TP and SL values.

The original backtester and information can be found here:
Miyagi Backtester


WHAT'S NEW:
-ATR is selectable for viewable as On/Off the chart.
-User selectable timeframe and length allow you to visualize the ATR at time of entry.
-2 External signal sources are able to be used to backtest up to 2 indicators at one time.
-Take profit based ATR is now able to be backtested, as a multiplier of the ATR at time of entry.
-Stop loss based ATR is now able to be backtested, as a multiplier of the ATR at time of entry.
-DCA based ATR is now able to be backtested, as a multiplier of the ATR at time of entry.

The backtester will allow users to all Indicators using DCA strategies to show returns over a selectable time period.
The backtester allows leverage, and as such users should be aware of the Maximum Amount for Bot Usage and Leverage Required Calculations.

The DCA Selector switch will allow users to backtest with, or without DCA.
Static/ATR DCA is used within the backtester and allows users to see DCA Statistics on closed trades.


How to use the Miyagi Backtester
Step 1: Apply the indicator of choice after ensuring your Long and Short conditions are plotted with Outbound_Long/Outbound_Short.

plot(Outbound_Long ? 1 : Outbound_Short ? 2 : 0, title = "🔌External Signal Source (Long 1 | Short 2)🔌", display = display.none, editable = false)
plot(Outbound_Long ? 1 : Outbound_Short ? -1 : 0, title = "🔌External Signal Source (Long 1 | Short -1)🔌", display = display.none, editable = false)

DATE AND TIME RANGE:
-Date and time range to backtest.

TRADE:
-Entry source to backtest. Please select the "Outbound Entry Signal Sender" and ensure your script has either Long 1 | Short 2 or Long 1 | Short -1.
-Trade Direction to backtest. This can be helpful to backtest according to your strategy (long or short).
-Take Profit % to backtest. This is the percent take profit to backtest. Slippage can be accounted for on the "Properties" tab. (ATR is now available as a user selectable option).
-Stoploss % to backtest. This is the percent stoploss to backtest. (ATR is now available).

DCA:
DCA Checkbox: Enable the DCA Checkbox to backtest with DCA. Disable it to backtest without DCA. (ATR is now available as a DCA option).
Leverage: Input the Leverage you will trade with.
Base Order Size (% Equity): This is the Base order (BO) size to backtest in % of equity.
Safety Order Size (% Equity): This is the Safety order (SO) size to backtest in % of equity.
Number of DCA Orders: This is the maximum amount of DCA orders to place, or total DCA orders.
Price Deviation (% from initial order): This is the percent at which the first safety is placed.
Safety Order Step Scale: This is the scale at which is applied to the deviation for the step calculation to determine next SO placement.
Safety Order Volume Scale: This is the scale at which is applied to the safety orders for the volume calculation to determine SO Volume.

Real world DCA Example:

The process is as follows.
Base Order: This is your initial order size, $100 used for Base Order
Safety Order: This is your first safety order size, which is placed at the deviation. $100 Safety Order, it is good to keep the same size as your BO for your scaling to be effective.
Price deviation: This is the deviation at which your first Safety order is placed. 0.3-0.75% used by most of our members.
Safety Order Volume Scale: This is the scale at which is applied to the safety orders for the volume calculation. Scale of 2 used, which means that SO2 = (SO1) * 2, or $200. This scaling is typical for all following orders and as such SO3 = (SO2) *2, or $400.
Safety Order Step Scale: This is the scale at which is applied to the deviation for the step calculation. This is similar to the volume scale however the last order percentage is added.
Scale of 2 used, which means that SO2 % = ((Deviation) * 2) + (SO1%). (0.5% *2) + (0.5) = 1.5%.
This scaling is typical for all following orders except that the prior deviation is used and as such SO3 = ((Prior%) * 2) + (Deviation). (1.5% * 2) +(0.5%) or 3.5%.
Total SO Number: The calculations will continue going until the last SO. It is helpful to understand the amount of SO’s and scaling determines how efficient your DCA is.


Backtester Outputs include:
Net Profit to display net profit
Daily Net Profit to estimate
Percent Profitable which shows ratio of winning trades to losing trades.
Total Trades
Winning Trades
Losing Trades (only applicable if stoploss is used)
Buy & Hold Return (of the backtested asset) to compare if the strategy used beats buy & hold return.
Avg Trade Time is very helpful to see average trade time.
Max Trade Time is very helpful to see the maximum trade time.
Total Backtested Time will return total backtested time.

Initial Capital which is taken from the Properties tab.
Max amount for Bot Usage which can be helpful to see bot usage.
Leverage Required will show you the leverage required to sustain the DCA configuration.
Total SO Deviation will allow users to see the drop coverage their DCA provides.
Max Spent which is a % of total account spent on one trade.
Max Drawdown which displays the maximum drawdown of any trade.
Max % distance from entry shows the maximum distance price went away from entry prior to the trade closing.
Max SO Used which shows the maximum number of SO's used on a single trade
Avg SO Used which shows the average number of SO's used in all closed trades.
Deals closing with BO Only calculation will show how many trades are closed without DCA.
Deals closing with 1-7 SOs calculation will show how many trades are closed with DCA, and allow for fine-tuning.

Happy Trading!

Nota Keluaran
Bug fixes when Safety Orders price reaches zero.
-Bug fixes when SL and TP price reaches zero.
-Added limitations on SL and TP to only max out at Zero.
-Added limitations on Safety Orders to stop placing limit orders if they reached Zero.
-Added error message if the Manual DCA values was not set to incremental values.
Meaning the first Safety Order values should not be more than the next Safety Order values.
This prevents issues on setting the Manual DCA and to ensure the Safety Orders being displayed are in sequence.
-Updated the Total SO Deviation when using ATR into showing the percentage covered on the last trade instead of the ATR Multiplier value.
Nota Keluaran
-Divided the "Take Profit ATR Multiplier" into "Long - Take Profit ATR Multiplier" and "Short - Take Profit ATR Multiplier

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.