今天抓了一個策略語法,只先大致上看過去,打算周末無聊時仔細研究。我先po出來,大家研究一下,如果有不錯的想法,歡迎教學相長。
New market paradigm 策略說明及程式碼:
To implement the strategies from my article, "Mutated variables, volatility and a new market paradigm," first write the programs that will generate studies and systems. Begin by building a function that indicates the current state of the market. Use this function to build indicators, paintbars and systems. Use of the BollingerBand function saves some programming time, but you could also insert your own standard deviation function here if you want to be more precise.
Type: Function, Name: NewMarketParadigm, Output: Numeric
Input: Price(NumericSeries),Length(NumericSimple),StdDevUp (NumericSimple),StdDevDn(NumericSimple);
value1 = BollingerBand(Price,Length,StdDevUp);
value2 = BollingerBand(Price,Length,StdDevDn);
Condition1 = value1 < value1[1] and value2 > value2[1]; {Contraction}{Built as conditions for later revision --WD}
Condition2 = value1 > value1[1] and value2 < value2[1]; {Expansion}
Condition3 = Condition1 = False and Condition2 = False; {Transition}
IF Condition1 then NewMarketParadigm = 1; {Contraction}
IF Condition2 then NewMarketParadigm = 2; {Expansion}
IF Condition3 then NewMarketParadigm = 3; {Transition}
New market paradigm system
This system will eventually be the finished model. It is very flexible, allowing the trader to either write systems based solely on the NMP phases, or plug in existing systems using the NMP as a filter.
Setting Defaults for NMP system:
Properties: Check "Allow multiple entries...." and "Generate orders for next bar"
This system will eventually be the finished model. It is very flexible, allowing the trader to either write systems based solely on the NMP phases, or plug in existing systems using the NMP as a filter.
Setting Defaults for NMP system:
Properties: Check "Allow multiple entries...." and "Generate orders for next bar"
Name: NMP SYSTEM, Stops: None
Input: Price(close),Length(28),StdDevUp(2),StdDevDn(-2);
Vars: NmpC(0),NmpE(0),NmpT(0),Trigger(0);
{*1.}
If NewMarketParadigm(Price,Length,StdDevUp,StdDevDn) = 1 then NmpC = NmpC + 1
Else NmpC = 0; {Contraction phase}
If NewMarketParadigm(Price,Length,StdDevUp,StdDevDn) = 2 then NmpE = NmpE + 1
Else NmpE = 0; {Expansion Phase}
If NewMarketParadigm(Price,Length,StdDevUp,StdDevDn) = 3 then NmpT = 1
Else NmpT = 0; {Transition Phase}{Reversal traders will be using this phase, so I left it in, although I donOt use it. No Counter is implemented, but one could certainly do that N WD}
{*2.}
Condition1 = NmpE > 1; {2 consecutive NmpE ranges qualify as an Expansion Phase. -- WD}
If Condition1 then begin
Trigger = 1;
End;
{*3.}
If Trigger = 1 then begin
Buy Highest(High,10) + 1 point Stop;
Sell Lowest(Low,10) - 1 point Stop;
End;
Notes to the code
First, write a set of algorithms that will make the rather lengthy NMP function strings easy to work with. Note that a counter has been added to the contraction and expansion strings. This counter holds a short-term record of the number of consecutive occurrences. Use the counts in constructing the system.
Next, establish the basic setup that will allow our systems to recognize a forming NMP state.
The following code implements a simple intraday channel breakout system. Many market false breakouts can be eliminated by changing this to a channel break "on close only" system. Once the trigger has been set to "1," it will remain in that state. In the initial testing phases, this experiments with phasing a simple system into the market. The theory is that by introducing a system into the market at the right time, it should be in sync with prevalent market cycles.
The original CIS bow-tie/parabolic
Setting Defaults for NMP system:
Properties: Check "Do not allow multiple entries" and "generate orders for next bar"
First, write a set of algorithms that will make the rather lengthy NMP function strings easy to work with. Note that a counter has been added to the contraction and expansion strings. This counter holds a short-term record of the number of consecutive occurrences. Use the counts in constructing the system.
Next, establish the basic setup that will allow our systems to recognize a forming NMP state.
The following code implements a simple intraday channel breakout system. Many market false breakouts can be eliminated by changing this to a channel break "on close only" system. Once the trigger has been set to "1," it will remain in that state. In the initial testing phases, this experiments with phasing a simple system into the market. The theory is that by introducing a system into the market at the right time, it should be in sync with prevalent market cycles.
The original CIS bow-tie/parabolic
Setting Defaults for NMP system:
Properties: Check "Do not allow multiple entries" and "generate orders for next bar"
Name: NMP SYSTEM 2, Stops: None
Input: Price(close),Length(28),DevSet(2),Accfactr(.02);
value1 = StdDev(Price,Length)*DevSet - StdDev(Price,Length)*-DevSet;
If value1 = Lowest(value1,Length) and Adx(14) < 23 then begin
If SlowD(Length) > 75 OR SlowD(Length) < 25 then begin
IncludeSystem: "Parabolic",ACCFACTR;
End;
End;
0 留言:
張貼留言
如果有私人問題想請教,請透過網站右方『與站長聯絡』之表單,謝謝!