rthomson

MA Crossover Strategy

6594 lượt xem
378
Allows you to backtest different SMA & EMA crossover strategies.
Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Bình luận

Hi!

Thanks for the good job. I still have an issue with my script, how do you do to have the signal one period after the cross and not right on the cross?

Thanks!
+4 Phản hồi
rthomson bishlar
@bishlar, it's a fault with Pinescript that on Strategies the entries are always a bar or two late.
Phản hồi
bishlar rthomson
@rthomson, thanks for the answer.
But i mean: i implemented a very simple crossover strategy, kind of MACD.
When i backtest my strategy, the issue is that the signal is given on the entry of the candle which makes the cross. But to be exact, the signal should be given on the close of the candle which makes the cross, or on the open of the next candle. And i dont mange how to do so. (it seems to be that way on your chart).

I hope i am clear enough :)

Phản hồi
rthomson bishlar
@bishlar, that should be automatic if its an actual Strategy and not a Study.
Phản hồi
bishlar rthomson
@rthomson, oh right thanks!
I found my problem, i set an offset on the plot of my MAs but it isnt taken account for the crossover function. Is there a way to add an offset straight when using the sma function or in the crossover function?
Thanks for the help mate
Phản hồi
rthomson bishlar
@bishlar, not as far as I know, but I have never tried
Phản hồi
Hi
1) How far back does this script calculate as there are no settings for it?
2) This script produces a different % to other scripts that are the same?
Phản hồi
rthomson GarethSA
@GarethSA, 1) as many candles as that timeframe has, 2) No comment as I've no idea what other scripts might be doing. This is a very basic script, to give you an idea for something to code from, or screen out some more promising MA crossovers from others.
Phản hồi
GarethSA rthomson
@rthomson, Thanks

Can i calculate strategys on Heiken-Ashi aswell or ONLY candle?
Phản hồi
rthomson GarethSA
@GarethSA, virtually any strategy performed on Heikin Ashi candles gives meaninglessly good results, due to an bug. There are very complex ways round it, which you can discover on @PineCoders telegram group, but not for the beginner.
Phản hồi