I am trying to create a signal in EasyLanguage that replicates Marty Zweig's Four Percent Model.
The signal is applied to a weekly chart of an index.
The approach gives a buy signal when the weekly close of the stock market is four percent above low points (local minima) and a sell signal when the weekly close is four percent below high points (local maxima). For example, the Value Line Index closed at a low point of 1016 on March 6, 2009. The index closed more than 4 percent higher the next week on March 13th, producing a buy signal. That buy signal remained in effect until the index closed down more than 4 percent on May 15th from the closing high of May 8th. The sell signal from that decline was reversed when the market closed up on May 29th more than 4 percent above the May 15th closing low.
See: http://www.trendprognosis.com/2009/05/f ... indicator/
Question: Does anyone have a suggestion for how to find the recent highs/lows from which a 4% signal should be given. Do I need to choose an arbitrary "lookback" period such as "find lowest price within past 6 bars" or is there a better way to find the "local minima" and "local maxima".
Thanks
Zweig's Four Percent Model in EasyLanguage?
-
- Posts: 9
- Joined: 17 Mar 2014
- Has thanked: 3 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Zweig's Four Percent Model in EasyLanguage?
That's not difficult to do.I am trying to create a signal in EasyLanguage that replicates Marty Zweig's Four Percent Model.
The signal is applied to a weekly chart of an index.
The approach gives a buy signal when the weekly close of the stock market is four percent above low points (local minima) and a sell signal when the weekly close is four percent below high points (local maxima). For example, the Value Line Index closed at a low point of 1016 on March 6, 2009. The index closed more than 4 percent higher the next week on March 13th, producing a buy signal. That buy signal remained in effect until the index closed down more than 4 percent on May 15th from the closing high of May 8th. The sell signal from that decline was reversed when the market closed up on May 29th more than 4 percent above the May 15th closing low.
See: http://www.trendprognosis.com/2009/05/f ... indicator/
Question: Does anyone have a suggestion for how to find the recent highs/lows from which a 4% signal should be given. Do I need to choose an arbitrary "lookback" period such as "find lowest price within past 6 bars" or is there a better way to find the "local minima" and "local maxima".
Thanks
Go to Wiki... find the section on:
PowerLanguage Keyword Reference
https://www.multicharts.com/trading-sof ... /Main_Page
Look for the keywords:
HIGHEST
LOWEST
Re: Zweig's Four Percent Model in EasyLanguage?
Hope this helps.
Code: Select all
inputs: perOffLo(4.00), { percent off lowest close }
perOffHi(4.00); { percent off highest close }
variables: LC(0), { lowest close }
HC(0), { highest close }
trend(0); { 0 = no trades yet, +1 = up, -1 = down }
{ initialize variables }
if currentBar = 1 then begin
LC = close;
HC = close;
trend = 0;
end;
{ update trend variable and place trading orders }
if trend = 0 then begin
if ((close-LC) / LC) >= (perOffLo / 100) then trend = +1;
if ((HC-close) / HC) >= (perOffHi / 100) then trend = -1;
end
else if trend = +1 and ((HC-close) / HC) >= (perOffHi / 100) then begin
sell short this bar on close;
trend = -1;
LC = close;
end
else if trend = -1 and ((close-LC) / LC) >= (perOffLo / 100) then begin
buy this bar on close;
trend = +1;
HC = close;
end;
{ update LC & HC variables }
if close < LC then LC = close;
if close > HC then HC = close;
-
- Posts: 9
- Joined: 17 Mar 2014
- Has thanked: 3 times
-
- Posts: 9
- Joined: 17 Mar 2014
- Has thanked: 3 times
Re: Zweig's Four Percent Model in EasyLanguage?
Super, because I'm new to EasyLanguage I am trying to understand all your code. I have a few questions if you wouldn't mind.
1. Am I right in thinking this code misses the first buy or sell signal.
i.e. should there not be a buy or sell order placed here?
As I read it, the script waits for this up or down trend signal and THEN looks for the first trade... i.e. if the initial trend is up on a chart the first signal will be a sell?
2.
On the above block, I don't understand why you have the line highlighted in bold.
Thanks!
1. Am I right in thinking this code misses the first buy or sell signal.
Code: Select all
if trend = 0 then begin
if ((close-LC) / LC) >= (perOffLo / 100) then trend = +1;
if ((HC-close) / HC) >= (perOffHi / 100) then trend = -1;
end
As I read it, the script waits for this up or down trend signal and THEN looks for the first trade... i.e. if the initial trend is up on a chart the first signal will be a sell?
2.
Code: Select all
else if trend = +1 and ((HC-close) / HC) >= (perOffHi / 100) then begin
sell short this bar on close;
trend = -1;
[b]LC = close; [/b]
end
Thanks!
Re: Zweig's Four Percent Model in EasyLanguage?
1. Yes your assumption is correct.Super, because I'm new to EasyLanguage I am trying to understand all your code. I have a few questions if you wouldn't mind.
1. Am I right in thinking this code misses the first buy or sell signal.
i.e. should there not be a buy or sell order placed here?Code: Select all
if trend = 0 then begin
if ((close-LC) / LC) >= (perOffLo / 100) then trend = +1;
if ((HC-close) / HC) >= (perOffHi / 100) then trend = -1;
end
As I read it, the script waits for this up or down trend signal and THEN looks for the first trade... i.e. if the initial trend is up on a chart the first signal will be a sell?
2.
On the above block, I don't understand why you have the line highlighted in bold.Code: Select all
else if trend = +1 and ((HC-close) / HC) >= (perOffHi / 100) then begin
sell short this bar on close;
trend = -1;
[b]LC = close; [/b]
end
Thanks!
2. I have not highlighted any thing at all-I don't see it that way on my screen.
-
- Posts: 9
- Joined: 17 Mar 2014
- Has thanked: 3 times
Re: Zweig's Four Percent Model in EasyLanguage?
2. Sorry I meant this bit which I tried to highlight in bold:
Code: Select all
LC = close;
Re: Zweig's Four Percent Model in EasyLanguage?
to track high and low points2. Sorry I meant this bit which I tried to highlight in bold:
Code: Select all
LC = close;