yesmider

profit_trailer_backtesting v2

yesmider Uppdaterad   
As a result of I can't update my previous post,just post new one,change the visibility to protected.

Features:
Backtesting in profit trailer's strategy.

Support profit trailer's buy strategy :
HIGHBB,LOWBB,EMAGAIN,EMASPREAD,EMACROSS,SMAGAIN,SMASPREAD,SMACROSS

Sell strategy:
GAIN,HIGHBB

DCA_buy strategy:
LOWBB,EMAGAIN,EMASPREAD,SMAGAIN,SMASPREAD,SMACROSS

DCA_sell strategy:
GAIN,HIGHBB

SOM(Sell only mode),Use BTCUSD data in specific time range, because of the limit of tradingview,you will need to change the data resolution by BTC_data_source_resolution to backtest further date from now,but the result will be inaccurate.

trailing buy > This method may not be in the same way as PT itself,because we can't truly get the bid and ask in order book by tradingview. set it to 0 if you don't want to use it.

Indicators of those strategy.

PLEASE READ THE NOTE BELOW IF YOU WANT TO USE DCA STRATEGY

DCA_enabled_value (negative number) should be ALWAYS > ALL_stop_limit_trigger or the script will just do stop loss,this follow the setting of PT.
And it means the value of net loss you want to let the trade to be DCA. if second trade (DCA trade) be made, all setting prefix by ALL_ will be ignored exclude ALL_BTC_XXX prefix for sell only mode.

CA_buy_contracts will overwrite the value you set in script option > properties > order size to number of contract,default is 100% in qty_percent.

DCA_buy_value work like same thing ALL_buy_value does.

DCA_buy_trigger is the net loss value (negative number) of open trades,if statement of strategy reach and net loss < DCA_buy_trigger,the DCA will buy.

DCA_sell_trigger will only work when DCA sell strategy is HIGHBB,it work like ALL_min_profit.

DCA_sell_value means % profit in GAIN, % of BB in HIGHBB.

DCA_stop_loss_trigger will only work when ALL BUYS have be completed,that means if you set DCA_max_buy_times = 10 ,the script will buy 11 times include the first buy(not DCA buy).

The indicators of DCA may looks terrible,you can turn them off in option.

comment if you got bug or anything suggestion.

ToDo:
rebuy_time,stop_loss_timeout

Feel free to buy me some redbull.
ETH:
0xd793607CBA1d07fE5A94884076AE94C36B6e7D8d



Versionsinformation:
minor fix.
Versionsinformation:
Notice here:
I'm NOT responsible for any financial losses cause by this script,this script is made for research.
Versionsinformation:
fix an bug that DCA indicator show when DCA enabled == false.
Improve the trailing method,the script will suppose that price will always reach open > high> low > close or open>low>high>close on current candle depends on the strategy in ideal situation.
trailing is now disabled in DCA.
The meaning of trailing value will be different in different strategy, and trailing only support LOWBB,MAGAIN ,MASPREAD method according to PT's wiki.

From my understanding:

In LOWBB,the value of trailing should be the % of the price lower than BB.

In MAGAIN,it should be the % of price higher or lower than the lowest MA.

In MASPREAD,it should be the % of MA_1 and MA_2 spread.

tell me if something wrong.

I will finish the sell trailing and DCA trailng later.
Versionsinformation:
Add trailing for sell and DCA.
Trailing sell is not supported in HIGHBB.
Versionsinformation:
fix a buy that spread strategy won't work when ALL_buy_value_limit == 0.
Versionsinformation:
try to fix an issue that MASPREAD strategy does not work when ALL_buy_value==0 and ALL_buy_value_limit !=0.
fix a bug that trailing was not working normally in MASPREAD strategy.

thanks for report.
Versionsinformation:
minor fix.
Versionsinformation:
fix a bug that SOM does not support when BTC_data_source_resolution == 30
Versionsinformation:
fix an issue of the MAGAIN strategy caused by my misunderstanding. it should work well now.
Versionsinformation:
minor fix.
Versionsinformation:
fix macross strategy not work when all_buy_value_limit == 0
change macross strategy will buy if all_buy_value==0 when ma2 cross over ma1(spread > 0)
Versionsinformation:
Remove DCA_buy_contracts.
Add ALL_max_cost.
Please use ALL_max_cost now, DONT FORGET to change the initial capital in the setting to the value you want as your start balance.
Tradingview doesn't support the amount of coin you buying < 1, so there are maybe some difference to the PT really do.
Versionsinformation:
Add ALL_max_cost_percentage,it only works when ALL_max_cost = 0.

Skyddat skript
Detta skript publiceras med stängd källkod och du kan använda det fritt. Du kan ange den som favorit för att använda den i ett diagram. Du kan inte visa eller ändra dess källkod.
Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?