Subversion Repositories Integrator Subversion

Rev

Rev 773 | Rev 779 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 773 Rev 776
Line 31... Line 31...
31
            return sinais;
31
            return sinais;
32
        }
32
        }
33
33
34
        for (PadraoGatilho p : padroes) {
34
        for (PadraoGatilho p : padroes) {
35
            if (p == null) continue;
35
            if (p == null) continue;
-
 
36
           
-
 
37
            // só interessa padrão completo até G3
-
 
38
            if (p.getTipoPadrao() != PadraoGatilho.TipoPadrao.COMPLETO_G3) {
-
 
39
                continue;
-
 
40
            }
36
41
37
            Candle ref = p.getReferencia();
42
            Candle ref = p.getReferencia();
38
            Candle g1  = p.getGatilho1();
43
            Candle g1  = p.getGatilho1();
39
            Candle g2  = p.getGatilho2();
44
            Candle g2  = p.getGatilho2();
40
            Candle g3  = p.getGatilho3();
45
            Candle g3  = p.getGatilho3();
Line 63... Line 68...
63
    }
68
    }
64
69
65
    /**
70
    /**
66
     * Monta sinal de VENDA (referência comprador):
71
     * Monta sinal de VENDA (referência comprador):
67
     *  - Fibo preço com base nos candles G2 e G3.
72
     *  - Fibo preço com base nos candles G2 e G3.
68
     *  - 0% no topo de G3
-
 
69
     *  - 100% no fundo de G2
-
 
-
 
73
     *  - 0% no topo de G2
-
 
74
     *  - 100% no fundo de G3
70
     */
75
     */
71
    private SinalTradeGatilho3 montarSinalVenda(Candle ref, Candle g1, Candle g2, Candle g3, PadraoGatilho padrao) {
76
    private SinalTradeGatilho3 montarSinalVenda(Candle ref, Candle g1, Candle g2, Candle g3, PadraoGatilho padrao) {
72
        BigDecimal topoG3   = g3.getMaxima();
-
 
73
        BigDecimal fundoG2  = g2.getMinima();
-
 
-
 
77
        BigDecimal topoG2   = g2.getMaxima();
-
 
78
        BigDecimal fundoG3  = g3.getMinima();
74
79
75
        // Garantia mínima de geometria: topo > fundo
80
        // Garantia mínima de geometria: topo > fundo
76
        if (BigDecimalUtils.ehMenorOuIgualQue(topoG3, fundoG2)) {
-
 
-
 
81
        if (BigDecimalUtils.ehMenorOuIgualQue(topoG2, fundoG3)) {
77
            return null;
82
            return null;
-
 
83
        }
-
 
84
       
-
 
85
        if (g3.getContadorCandle().equals(524)) {
-
 
86
                System.out.println("524");
78
        }
87
        }
79
88
80
        // Orientação: 0% = topo (G3), 100% = fundo (G2)
89
        // Orientação: 0% = topo (G3), 100% = fundo (G2)
81
        BigDecimal base0   = topoG3;
-
 
82
        BigDecimal base100 = fundoG2;
-
 
-
 
90
        BigDecimal base0   = topoG2;
-
 
91
        BigDecimal base100 = fundoG3;
83
92
84
        BigDecimal entrada1 = nivelFibo(base0, base100, 50.0);    // 50%
93
        BigDecimal entrada1 = nivelFibo(base0, base100, 50.0);    // 50%
85
        BigDecimal entrada2 = nivelFibo(base0, base100, 25.0);    // 25%
94
        BigDecimal entrada2 = nivelFibo(base0, base100, 25.0);    // 25%
86
        BigDecimal alvo1    = nivelFibo(base0, base100, 100.0);   // 100%
95
        BigDecimal alvo1    = nivelFibo(base0, base100, 100.0);   // 100%
87
        BigDecimal alvo2    = nivelFibo(base0, base100, 123.6);   // 123,6%
96
        BigDecimal alvo2    = nivelFibo(base0, base100, 123.6);   // 123,6%
88
        BigDecimal stopFib  = nivelFibo(base0, base100, -100.0);  // -100%
97
        BigDecimal stopFib  = nivelFibo(base0, base100, -100.0);  // -100%
89
98
90
        // Stop alternativo: 25% acima do último fundo relevante (aqui uso fundo de G2)
99
        // Stop alternativo: 25% acima do último fundo relevante (aqui uso fundo de G2)
91
        BigDecimal stopAlt = fundoG2.add(
-
 
92
                topoG3.subtract(fundoG2).multiply(BigDecimal.valueOf(0.25))
-
 
-
 
100
        BigDecimal stopAlt = fundoG3.add(
-
 
101
                        topoG2.subtract(fundoG3).multiply(BigDecimal.valueOf(0.25))
93
        );
102
        );
94
103
95
        SinalTradeGatilho3 s = new SinalTradeGatilho3();
104
        SinalTradeGatilho3 s = new SinalTradeGatilho3();
96
        s.setPadrao(padrao);
105
        s.setPadrao(padrao);
97
        s.setReferencia(ref);
106
        s.setReferencia(ref);
Line 115... Line 124...
115
    }
124
    }
116
125
117
    /**
126
    /**
118
     * Monta sinal de COMPRA (referência vendedor):
127
     * Monta sinal de COMPRA (referência vendedor):
119
     *  - Fibo preço com base nos candles G2 e G3.
128
     *  - Fibo preço com base nos candles G2 e G3.
120
     *  - 0% no fundo de G3
-
 
121
     *  - 100% no topo de G2
-
 
-
 
129
     *  - 0% no fundo de G2
-
 
130
     *  - 100% no topo de G3
122
     */
131
     */
123
    private SinalTradeGatilho3 montarSinalCompra(Candle ref, Candle g1, Candle g2, Candle g3, PadraoGatilho padrao) {
132
    private SinalTradeGatilho3 montarSinalCompra(Candle ref, Candle g1, Candle g2, Candle g3, PadraoGatilho padrao) {
124
        BigDecimal topoG2   = g2.getMaxima();
-
 
125
        BigDecimal fundoG3  = g3.getMinima();
-
 
-
 
133
        BigDecimal topoG3   = g3.getMaxima();
-
 
134
        BigDecimal fundoG2  = g2.getMinima();
126
135
127
        if (BigDecimalUtils.ehMenorOuIgualQue(topoG2, fundoG3)) {
-
 
-
 
136
        if (BigDecimalUtils.ehMenorOuIgualQue(topoG3, fundoG2)) {
128
            return null;
137
            return null;
129
        }
138
        }
130
139
131
        // Orientação: 0% = fundo (G3), 100% = topo (G2)
140
        // Orientação: 0% = fundo (G3), 100% = topo (G2)
132
        BigDecimal base0   = fundoG3;
-
 
133
        BigDecimal base100 = topoG2;
-
 
-
 
141
        BigDecimal base0   = fundoG2;
-
 
142
        BigDecimal base100 = topoG3;
134
143
135
        BigDecimal entrada1 = nivelFibo(base0, base100, 50.0);    // 50%
144
        BigDecimal entrada1 = nivelFibo(base0, base100, 50.0);    // 50%
136
        BigDecimal entrada2 = nivelFibo(base0, base100, 25.0);    // 25%
145
        BigDecimal entrada2 = nivelFibo(base0, base100, 25.0);    // 25%
137
        BigDecimal alvo1    = nivelFibo(base0, base100, 100.0);   // 100%
146
        BigDecimal alvo1    = nivelFibo(base0, base100, 100.0);   // 100%
138
        BigDecimal alvo2    = nivelFibo(base0, base100, 123.6);   // 123,6%
147
        BigDecimal alvo2    = nivelFibo(base0, base100, 123.6);   // 123,6%
139
        BigDecimal stopFib  = nivelFibo(base0, base100, -100.0);  // -100%
148
        BigDecimal stopFib  = nivelFibo(base0, base100, -100.0);  // -100%
140
149
141
        // Stop alternativo: 25% abaixo do último topo relevante (aqui uso topo de G2)
150
        // Stop alternativo: 25% abaixo do último topo relevante (aqui uso topo de G2)
142
        BigDecimal stopAlt = topoG2.subtract(
-
 
143
                topoG2.subtract(fundoG3).multiply(BigDecimal.valueOf(0.25))
-
 
-
 
151
        BigDecimal stopAlt = topoG3.subtract(
-
 
152
                        topoG3.subtract(fundoG2).multiply(BigDecimal.valueOf(0.25))
144
        );
153
        );
145
154
146
        SinalTradeGatilho3 s = new SinalTradeGatilho3();
155
        SinalTradeGatilho3 s = new SinalTradeGatilho3();
147
        s.setPadrao(padrao);
156
        s.setPadrao(padrao);
148
        s.setReferencia(ref);
157
        s.setReferencia(ref);