Перебор фигур.
Данный материал является демонстрацией серии тщетных усилий по нахождению простых и доступных методов “побеждения” рынка. Особо рьяных последователей должен предупредить, что представленный метод “поголовного” перебора цен открытия и закрытия за несколько дней оказался тупиковым. Большинство выявляемых паттернов и их “наборов” не выдерживают проверки на Out-of-Sample. Тем не менее, отрицательный результат – тоже результат.
Итак. Идея была такая. Последовательно сравнивать цены Open и Close дня на предмет образования
повторяющихся одно-, двух- и трех-дневных паттернов. Позиция открывается на Open дня (которое тоже учитывается в фигуре),
закрытие позиции на Close
дня. Например: “Если вчерашнее закрытие выше вчерашнего открытия и сегодняшнее
открытие ниже вчерашнего закрытия, то Buy at Market, со стоп-лоссом Х%, ExitLong at Close”. Это пример
одно-дневной фигуры. Аналогичным образом формируются двух- и трех-дневные
паттерны. Так как в коде сигнала на вход присутствует функция “Open of Tomorrow”, то команды на
закрытие позиции по Close
дня выделены в отдельный сигнал стратегии. Таким образом, стратегия состоит из
двух сигналов: на вход 1_NRSTP и на выход 1_Patterns_Exit.
Порядок работы со стратегией.
Вот, собственно и все. Так как весь опыт программирования для меня начался и закончился около 20 лет назад в виде единственной курсовой работы (кажется на фортране) с использованием перфокарт, то вполне может оказаться, что вся методика или отдельные ее элементы содержат критические ошибки. Поэтому, прошу не судить строго, а лучше, указать на таковые.
Коды:
Файл ELA включающий в себя два сигнала и стратегию.
Сигнал на вход (и тестирование): 1_NRSTP
{******************
NRSTP (Nick Rypock Short Term
Patterns) Entry Signal
Copyright (c) konkop 2001
Coded by Konstantin Kopyrkin (aka
konkop) 08.01.2001
konkop@mail.ur.ru http://konkop.narod.ru (russian only)
This Code realized popular trading
method Short-Term Pattern Trading.
In this case we Entry Long or Short
at Open and Exit position at Close in one trading day, with MM StopLoss.
For detect tradable patterns we
consecutively compared Open and Close in one-day, two-days and three-days
"patterns".
First step - set "Test"
to True and optimizing "Flag1" from 1 to 84 for testing patterns.
Next step - set "Test" to
False and set numbers of best patterns (from 1 to 84) for Buy to B1...B6 inputs
and numbers of best patterns for
Sell to S1...S6 inputs.
For example: Buy patterns - first
six (or less) best ProfitFactors
and for Sell patterns - last six
(or less) most dramatic ProfitFactors from Strategy Optimization Report
This signal must use with separate
Exit Signal (ExitLong/Short on Close) in TS strategy, because
this code include "Open of
Tomorrow" function
****************}
Inputs:
Test
(True), {Test or Trade}
Flag1(0), {Entry Pattern from 1 to 84 (optimize)}
StpLoss(10), {Stop
Loss in percent (optimize)}
B1(0),
B2(0), B3(0), B4(0), B5(0), B6(0), {Buy
Petterns}
S1(0),
S2(0), S3(0), S4(0), S5(0), S6(0);
{Sell Patterns}
Vars: P(0), Code1(1), Code2(1),
Code3(1), StopLong(0), StopShort(0);
P = Open of Tomorrow;
{OneDay patterns}
If P>C and C>O then Code1 =
1;
If P>C and C<O then Code1 =
2;
If P<C and C>O then Code1 =
3;
If P<C and C<O then Code1 =
4;
{TwoDays patterns}
If O>C[1] and C[1]>O[1] and
Code1 = 1 Then Code2 = 5;
If O>C[1] and C[1]>O[1] and
Code1 = 2 Then Code2 = 6;
If O>C[1] and C[1]>O[1] and
Code1 = 3 Then Code2 = 7;
If O>C[1] and C[1]>O[1] and
Code1 = 4 Then Code2 = 8;
If O>C[1] and C[1]<O[1] and
Code1 = 1 Then Code2 = 9;
If O>C[1] and C[1]<O[1] and
Code1 = 2 Then Code2 = 10;
If O>C[1] and C[1]<O[1] and
Code1 = 3 Then Code2 = 11;
If O>C[1] and C[1]<O[1] and
Code1 = 4 Then Code2 = 12;
If O<C[1] and C[1]<O[1] and
Code1 = 1 Then Code2 = 13;
If O<C[1] and C[1]<O[1] and
Code1 = 2 Then Code2 = 14;
If O<C[1] and C[1]<O[1] and
Code1 = 3 Then Code2 = 15;
If O<C[1] and C[1]<O[1] and
Code1 = 4 Then Code2 = 16;
If O<C[1] and C[1]>O[1] and
Code1 = 1 Then Code2 = 17;
If O<C[1] and C[1]>O[1] and
Code1 = 2 Then Code2 = 18;
If O<C[1] and C[1]>O[1] and
Code1 = 3 Then Code2 = 19;
If O<C[1] and C[1]>O[1] and
Code1 = 4 Then Code2 = 20;
{ThreeDays patterns}
If O[1]>C[2] and C[2]>O[2]
and Code2 = 5 Then Code3 = 21;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 6 Then Code3 = 22;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 7 Then Code3 = 23;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 8 Then Code3 = 24;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 9 Then Code3 = 25;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 10 Then Code3 = 26;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 11 Then Code3 = 27;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 12 Then Code3 = 28;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 13 Then Code3 = 29;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 14 Then Code3 = 30;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 15 Then Code3 = 31;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 16 Then Code3 = 32;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 17 Then Code3 = 33;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 18 Then Code3 = 34;
If O[1]>C[2] and C[2]>O[2] and
Code2 = 19 Then Code3 = 35;
If O[1]>C[2] and C[2]>O[2]
and Code2 = 20 Then Code3 = 36;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 5 Then Code3 = 37;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 6 Then Code3 = 38;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 7 Then Code3 = 39;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 8 Then Code3 = 40;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 9 Then Code3 = 41;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 10 Then Code3 = 42;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 11 Then Code3 = 43;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 12 Then Code3 = 44;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 13 Then Code3 = 45;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 14 Then Code3 = 46;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 15 Then Code3 = 47;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 16 Then Code3 = 48;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 17 Then Code3 = 49;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 18 Then Code3 = 50;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 19 Then Code3 = 51;
If O[1]>C[2] and C[2]<O[2]
and Code2 = 20 Then Code3 = 52;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 5 Then Code3 = 53;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 6 Then Code3 = 54;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 7 Then Code3 = 55;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 8 Then Code3 = 56;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 9 Then Code3 = 57;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 10 Then Code3 = 58;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 11 Then Code3 = 59;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 12 Then Code3 = 60;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 13 Then Code3 = 61;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 14 Then Code3 = 62;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 15 Then Code3 = 63;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 16 Then Code3 = 64;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 17 Then Code3 = 65;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 18 Then Code3 = 66;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 19 Then Code3 = 67;
If O[1]<C[2] and C[2]<O[2]
and Code2 = 20 Then Code3 = 68;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 5 Then Code3 = 69;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 6 Then Code3 = 70;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 7 Then Code3 = 71;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 8 Then Code3 = 72;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 9 Then Code3 = 73;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 10 Then Code3 = 74;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 11 Then Code3 = 75;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 12 Then Code3 = 76;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 13 Then Code3 = 77;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 14 Then Code3 = 78;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 15 Then Code3 = 79;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 16 Then Code3 = 80;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 17 Then Code3 = 81;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 18 Then Code3 = 82;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 19 Then Code3 = 83;
If O[1]<C[2] and C[2]>O[2]
and Code2 = 20 Then Code3 = 84;
{Test Patterns}
If Test = True Then Begin
If
Code1 = Flag1 or Code2 = Flag1 or Code3 = Flag1 Then Buy at Market ;
End;
{Trade Patterns}
If Test = False Then Begin
StopLong
= (Open of Tomorrow)*(1-StpLoss/100); {Setup StopLong Order}
StopShort
= (Open of Tomorrow)*(1+StpLoss/100);{Setup StopShort Order}
If
Code1=B1 or Code2=B1 or Code3=B1 Then Buy("B1") at Market;
If
Code1=B2 or Code2=B2 or Code3=B2 Then Buy("B2") at Market;
If
Code1=B3 or Code2=B3 or Code3=B3 Then Buy("B3") at Market;
If
Code1=B4 or Code2=B4 or Code3=B4 Then Buy("B4") at Market;
If
Code1=B5 or Code2=B5 or Code3=B5 Then Buy("B5") at Market;
If
Code1=B6 or Code2=B6 or Code3=B6 Then Buy("B6") at Market;
If
Code1=S1 or Code2=S1 or Code3=S1 Then Sell("S1") at Market;
If
Code1=S2 or Code2=S2 or Code3=S2 Then Sell("S2") at Market;
If
Code1=S3 or Code2=S3 or Code3=S3 Then Sell("S3") at Market;
If
Code1=S4 or Code2=S4 or Code3=S4 Then Sell("S4") at Market;
If
Code1=S5 or Code2=S5 or Code3=S5 Then Sell("S5") at Market;
If
Code1=S6 or Code2=S6 or Code3=S6 Then Sell("S6") at Market;
ExitLong("StopL")
at StopLong Stop;
ExitShort("StopS")
at StopShort Stop;
End;
Сигнал на выход (закрытие позиции): 1_Patterns_Exit
{*****************}
ExitLong at Close;
ExitShort at Close;
{*****************}
© konkop, 2001.