WilsonFisk
Lurker From The Deep
- Joined
- 24 June 2008
- Posts
- 19
- Reactions
- 87
MAfilter = MA( C, 10 ); // 10 week lookback period
IndexBuyFilter = C > MAfilter; // Index Filter = ON: When the close is greater than the 10 week simple moving average the Index Filter is ON [trailing stop set to 20%] + [buy + sell signals generated]
IndexSellFilter = C < MAfilter; // Index Filter = OFF: When the close is less than the 10 week simple moving average the Index Filter is OFF [shortens trailing stop to 10%] + [only sell signals generated]
I think you may be right as those calcuations came after:
RestorePriceArrays( True );
I'm pretty sure those calcs have to be done before you restore the arrays to the default symbol?
Maybe something like this
IndexCode = ParamStr("Index Symbol","$XAO.au");
Index = Foreign(IndexCode,"C");
MAFilter = MA( C, 10);
IndexBuyFilter = Index > MAFilter;
IndexSellFilter = Index < MAFilter;
RestorePriceArrays( True );
//2. The "Index Filter" - decides when we will trade & also our trailing stop levels
//=================================================================================
SetForeign( "$XAO.au", True , True ); // I've used the new Norgate Updater (NDU) format - change if the format is different to your data supplier
MAfilter = MA( C, 10 ); // 10 week lookback period
IndexBuyFilter = C > MAfilter; // Index Filter = ON: When the close is greater than the 10 week simple moving average the Index Filter is ON [trailing stop set to 20%] + [buy + sell signals generated]
IndexSellFilter = C < MAfilter; // Index Filter = OFF: When the close is less than the 10 week simple moving average the Index Filter is OFF [shortens trailing stop to 10%] + [only sell signals generated]
RestorePriceArrays( True ); // Restores original price and volume arrays after the call to SetForeign.
As to your WTT I have run a series of backtests to see particular statistics over different time frames. Hopefully they will be of interest
I may be missing something, but it doesn't look like your code for the index filter is actually referencing the index, rather just the individual symbol?? I am by no means an Amibroker expert so if I am missing it somewhere please let me know.
@Skate you've inspired me to start a trial of Norgate and Amibroker. I've started running a few simple backtests, pretty straight forward. The code that you have shared will give me a LOT to chew on, as I want to understand every line. At the same time, I'm researching strategies and generally educating myself...so my hope is to learn a strategy/system, then code it as a way to learn both the strategy and Amibroker.
Hint
If you do a search I have uploaded a few different strategies that may help you understand a strategy a little better.
Make sure you include a search around psychology/behaviour as part of that, as you need to have a strategy for how you will act whilst implementing the trading strategy. Knowing how you will behave when the market or a trade moves against you, will do wonders for constructing a system as it will give you a baseline of what you are working towards.
'Trading in the Zone' is a great book for that.
Hi would this work?View attachment 107483
The original code
@WilsonFisk you are correct the "BUYFilter" references individual positions & not an Index. To keep the version as is - you can change "Index" to "Buy" as it makes no difference running the code - The terminology (Index) got through to the keeper. Sorry about that. If you prefer (a) you can substitute an Index Filter, (b) remove the Buy Filter (c) reword "Index to Buy" or (d) leave the strategy as is "as it makes no difference when running the strategy".
The Index Filter is really a Buy Filter (terminology corrected)
Everywhere Index is written you can change Index to Buy as the example below displays
//=================================================================================
//2. The "Buy Filter" - decides when we will trade & also our trailing stop levels
//=================================================================================
MAfilter = MA( C, 10 ); // 10 week lookback period
BuyFilter = C > MAfilter; // Buy Filter = ON: When the close is greater than the 10 week simple moving average the Buy Filter is ON [trailing stop set to 20%] + [buy + sell signals generated]
SellFilter = C < MAfilter; // Buy Filter = OFF: When the close is less than the 10 week simple moving average the Buy Filter is OFF [shortens trailing stop to 10%] + [only sell signals generated]
Skate.
Yep but I use PremuimWouldn't it be $XAO ? or $XAO.au for norgate users. but otherwise I believe that is right.
@Skate , Nick Radge has posted his current positions as at 10 August 2020 on his Twitter feed. As a cross check on coding you could see what positions your WTT coded portfolio held against those in Nick's. I will have a look tomorrow, at first glance I'm thinking my coding is only a 60% MATCHHere is a link to his post https://t.co/tKhbff8VEX
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?