Subversion Repositories Integrator Subversion

Rev

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

Rev 764 Rev 767
Line 193... Line 193...
193
            Candle c = candles.get(i);
193
            Candle c = candles.get(i);
194
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
194
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
195
                continue;
195
                continue;
196
            }
196
            }
197
197
198
            // 🔹 OUTSIDE em relação ao GR (APENAS ATÉ G1)
-
 
-
 
198
            // OUTSIDE em relação ao GR (até G3)
199
            if (isOutsideReferencia(ref, c)) {
199
            if (isOutsideReferencia(ref, c)) {
200
                lastIndex = i;
200
                lastIndex = i;
201
                log(String.format(
201
                log(String.format(
202
                        "RefC[%d]: OUTSIDE em [%d] antes da mudança de tendência. Padrão descartado.",
202
                        "RefC[%d]: OUTSIDE em [%d] antes da mudança de tendência. Padrão descartado.",
203
                        idxRef, i));
203
                        idxRef, i));
Line 234... Line 234...
234
        Candle g1 = null;
234
        Candle g1 = null;
235
235
236
        for (int i = idxPrimeiroVendedor; i < n; i++) {
236
        for (int i = idxPrimeiroVendedor; i < n; i++) {
237
            Candle c = candles.get(i);
237
            Candle c = candles.get(i);
238
238
239
            // 🔹 OUTSIDE em relação ao GR (APENAS ATÉ G1)
-
 
-
 
239
            // OUTSIDE em relação ao GR (até G3)
240
            if (isOutsideReferencia(ref, c)) {
240
            if (isOutsideReferencia(ref, c)) {
241
                lastIndex = i;
241
                lastIndex = i;
242
                log(String.format(
242
                log(String.format(
243
                        "RefC[%d]: OUTSIDE em [%d] durante busca de G1. Padrão descartado.",
243
                        "RefC[%d]: OUTSIDE em [%d] durante busca de G1. Padrão descartado.",
244
                        idxRef, i));
244
                        idxRef, i));
Line 263... Line 263...
263
        if (idxG1 == -1) {
263
        if (idxG1 == -1) {
264
            return new ResultadoPadrao(null, lastIndex);
264
            return new ResultadoPadrao(null, lastIndex);
265
        }
265
        }
266
266
267
        log(String.format("RefC[%d] (GR) => G1 (vendedor) em [%d]", idxRef, idxG1));
267
        log(String.format("RefC[%d] (GR) => G1 (vendedor) em [%d]", idxRef, idxG1));
268
-
 
269
        // =====================================================
-
 
270
        // A PARTIR DAQUI (G2, G3, G4) NÃO VERIFICAMOS MAIS OUTSIDE
-
 
271
        // =====================================================
-
 
272
268
273
        // 2) Encontrar G2 (retorno comprador à região do GR)
269
        // 2) Encontrar G2 (retorno comprador à região do GR)
274
        int idxPrimeiroComprador = -1;
270
        int idxPrimeiroComprador = -1;
275
        for (int i = idxG1 + 1; i < n; i++) {
271
        for (int i = idxG1 + 1; i < n; i++) {
276
            Candle c = candles.get(i);
272
            Candle c = candles.get(i);
-
 
273
-
 
274
            // OUTSIDE em relação ao GR (até G3)
-
 
275
            if (isOutsideReferencia(ref, c)) {
-
 
276
                lastIndex = i;
-
 
277
                log(String.format(
-
 
278
                        "RefC[%d]: OUTSIDE em [%d] antes da tendência de G2. Padrão descartado.",
-
 
279
                        idxRef, i));
-
 
280
                return new ResultadoPadrao(null, lastIndex);
-
 
281
            }
277
282
278
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
283
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
279
                continue;
284
                continue;
280
            }
285
            }
281
            if (c.isCandleComprador()) {
286
            if (c.isCandleComprador()) {
Line 294... Line 299...
294
        Candle ultimoCompradorTrend = null;
299
        Candle ultimoCompradorTrend = null;
295
        int idxUltimoCompradorTrend = -1;
300
        int idxUltimoCompradorTrend = -1;
296
301
297
        for (int i = idxPrimeiroComprador; i < n; i++) {
302
        for (int i = idxPrimeiroComprador; i < n; i++) {
298
            Candle c = candles.get(i);
303
            Candle c = candles.get(i);
-
 
304
-
 
305
            // OUTSIDE em relação ao GR (até G3)
-
 
306
            if (isOutsideReferencia(ref, c)) {
-
 
307
                lastIndex = i;
-
 
308
                log(String.format(
-
 
309
                        "RefC[%d]: OUTSIDE em [%d] durante formação de G2. Padrão descartado.",
-
 
310
                        idxRef, i));
-
 
311
                return new ResultadoPadrao(null, lastIndex);
-
 
312
            }
299
313
300
            if (!c.isCandleComprador()) {
314
            if (!c.isCandleComprador()) {
301
                break;
315
                break;
302
            }
316
            }
303
317
Line 329... Line 343...
329
343
330
        // 3) Encontrar G3 (vendedor rompendo fundo de G2, topo <= topo do GR)
344
        // 3) Encontrar G3 (vendedor rompendo fundo de G2, topo <= topo do GR)
331
        int idxPrimeiroVendedorAposG2 = -1;
345
        int idxPrimeiroVendedorAposG2 = -1;
332
        for (int i = idxG2 + 1; i < n; i++) {
346
        for (int i = idxG2 + 1; i < n; i++) {
333
            Candle c = candles.get(i);
347
            Candle c = candles.get(i);
-
 
348
-
 
349
            // OUTSIDE em relação ao GR (até G3)
-
 
350
            if (isOutsideReferencia(ref, c)) {
-
 
351
                lastIndex = i;
-
 
352
                log(String.format(
-
 
353
                        "RefC[%d]: OUTSIDE em [%d] antes da sequência vendedora de G3. Padrão descartado.",
-
 
354
                        idxRef, i));
-
 
355
                return new ResultadoPadrao(null, lastIndex);
-
 
356
            }
334
357
335
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
358
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
336
                continue;
359
                continue;
337
            }
360
            }
338
361
Line 355... Line 378...
355
        int idxG3 = -1;
378
        int idxG3 = -1;
356
        Candle g3 = null;
379
        Candle g3 = null;
357
380
358
        for (int i = idxPrimeiroVendedorAposG2; i < n; i++) {
381
        for (int i = idxPrimeiroVendedorAposG2; i < n; i++) {
359
            Candle c = candles.get(i);
382
            Candle c = candles.get(i);
-
 
383
-
 
384
            // OUTSIDE em relação ao GR (ATÉ IDENTIFICAR G3)
-
 
385
            if (isOutsideReferencia(ref, c)) {
-
 
386
                lastIndex = i;
-
 
387
                log(String.format(
-
 
388
                        "RefC[%d]: OUTSIDE em [%d] durante formação de G3. Padrão descartado.",
-
 
389
                        idxRef, i));
-
 
390
                return new ResultadoPadrao(null, lastIndex);
-
 
391
            }
-
 
392
360
            if (!c.isCandleVendedor()) {
393
            if (!c.isCandleVendedor()) {
361
                lastIndex = i - 1;
394
                lastIndex = i - 1;
362
                break;
395
                break;
363
            }
396
            }
364
397
Line 380... Line 413...
380
        }
413
        }
381
414
382
        log(String.format("RefC[%d], G1[%d], G2[%d] => G3 (vendedor) em [%d]",
415
        log(String.format("RefC[%d], G1[%d], G2[%d] => G3 (vendedor) em [%d]",
383
                idxRef, idxG1, idxG2, idxG3));
416
                idxRef, idxG1, idxG2, idxG3));
384
417
385
        // 4) G4 – próximo candle rompe topo do GR
-
 
-
 
418
        // 4) G4 – próximo candle rompe topo do GR (aqui já não precisamos mais checar outside)
386
        Candle g4 = null;
419
        Candle g4 = null;
387
        int proxIdx = idxG3 + 1;
420
        int proxIdx = idxG3 + 1;
388
        if (proxIdx < n) {
421
        if (proxIdx < n) {
389
            Candle c = candles.get(proxIdx);
422
            Candle c = candles.get(proxIdx);
390
            lastIndex = proxIdx;
423
            lastIndex = proxIdx;
Line 406... Line 439...
406
        padrao.setGatilho3(g3);
439
        padrao.setGatilho3(g3);
407
        padrao.setGatilho4(g4);
440
        padrao.setGatilho4(g4);
408
441
409
        return new ResultadoPadrao(padrao, lastIndex);
442
        return new ResultadoPadrao(padrao, lastIndex);
410
    }
443
    }
-
 
444
411
445
412
    // =====================================================================
446
    // =====================================================================
413
    // CASO 2 – GR VENDEDOR (candle B)
447
    // CASO 2 – GR VENDEDOR (candle B)
414
    // =====================================================================
448
    // =====================================================================
415
449
Line 439... Line 473...
439
            Candle c = candles.get(i);
473
            Candle c = candles.get(i);
440
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
474
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
441
                continue;
475
                continue;
442
            }
476
            }
443
477
444
            // 🔹 OUTSIDE em relação ao GR (APENAS ATÉ G1)
-
 
-
 
478
            // OUTSIDE em relação ao GR (até G3)
445
            if (isOutsideReferencia(ref, c)) {
479
            if (isOutsideReferencia(ref, c)) {
446
                lastIndex = i;
480
                lastIndex = i;
447
                log(String.format(
481
                log(String.format(
448
                        "RefV[%d]: OUTSIDE em [%d] antes da mudança de tendência. Padrão descartado.",
482
                        "RefV[%d]: OUTSIDE em [%d] antes da mudança de tendência. Padrão descartado.",
449
                        idxRef, i));
483
                        idxRef, i));
Line 480... Line 514...
480
        Candle g1 = null;
514
        Candle g1 = null;
481
515
482
        for (int i = idxPrimeiroComprador; i < n; i++) {
516
        for (int i = idxPrimeiroComprador; i < n; i++) {
483
            Candle c = candles.get(i);
517
            Candle c = candles.get(i);
484
518
485
            // 🔹 OUTSIDE em relação ao GR (APENAS ATÉ G1)
-
 
-
 
519
            // OUTSIDE em relação ao GR (até G3)
486
            if (isOutsideReferencia(ref, c)) {
520
            if (isOutsideReferencia(ref, c)) {
487
                lastIndex = i;
521
                lastIndex = i;
488
                log(String.format(
522
                log(String.format(
489
                        "RefV[%d]: OUTSIDE em [%d] durante busca de G1. Padrão descartado.",
523
                        "RefV[%d]: OUTSIDE em [%d] durante busca de G1. Padrão descartado.",
490
                        idxRef, i));
524
                        idxRef, i));
Line 508... Line 542...
508
        if (idxG1 == -1) {
542
        if (idxG1 == -1) {
509
            return new ResultadoPadrao(null, lastIndex);
543
            return new ResultadoPadrao(null, lastIndex);
510
        }
544
        }
511
545
512
        log(String.format("RefV[%d] (GR) => G1 (comprador) em [%d]", idxRef, idxG1));
546
        log(String.format("RefV[%d] (GR) => G1 (comprador) em [%d]", idxRef, idxG1));
513
-
 
514
        // =====================================================
-
 
515
        // A PARTIR DAQUI (G2, G3, G4) NÃO VERIFICAMOS MAIS OUTSIDE
-
 
516
        // =====================================================
-
 
517
547
518
        // 2) Encontrar G2 (retorno vendedor à região do GR)
548
        // 2) Encontrar G2 (retorno vendedor à região do GR)
519
        int idxPrimeiroVendedor = -1;
549
        int idxPrimeiroVendedor = -1;
520
        for (int i = idxG1 + 1; i < n; i++) {
550
        for (int i = idxG1 + 1; i < n; i++) {
521
            Candle c = candles.get(i);
551
            Candle c = candles.get(i);
-
 
552
-
 
553
            // OUTSIDE em relação ao GR (até G3)
-
 
554
            if (isOutsideReferencia(ref, c)) {
-
 
555
                lastIndex = i;
-
 
556
                log(String.format(
-
 
557
                        "RefV[%d]: OUTSIDE em [%d] antes da tendência de G2. Padrão descartado.",
-
 
558
                        idxRef, i));
-
 
559
                return new ResultadoPadrao(null, lastIndex);
-
 
560
            }
522
561
523
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
562
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
524
                continue;
563
                continue;
525
            }
564
            }
526
565
Line 540... Line 579...
540
        Candle ultimoVendedorTrend = null;
579
        Candle ultimoVendedorTrend = null;
541
        int idxUltimoVendedorTrend = -1;
580
        int idxUltimoVendedorTrend = -1;
542
581
543
        for (int i = idxPrimeiroVendedor; i < n; i++) {
582
        for (int i = idxPrimeiroVendedor; i < n; i++) {
544
            Candle c = candles.get(i);
583
            Candle c = candles.get(i);
-
 
584
-
 
585
            // OUTSIDE em relação ao GR (até G3)
-
 
586
            if (isOutsideReferencia(ref, c)) {
-
 
587
                lastIndex = i;
-
 
588
                log(String.format(
-
 
589
                        "RefV[%d]: OUTSIDE em [%d] durante formação de G2. Padrão descartado.",
-
 
590
                        idxRef, i));
-
 
591
                return new ResultadoPadrao(null, lastIndex);
-
 
592
            }
545
593
546
            if (!c.isCandleVendedor()) {
594
            if (!c.isCandleVendedor()) {
547
                break;
595
                break;
548
            }
596
            }
549
597
Line 575... Line 623...
575
623
576
        // 3) Encontrar G3 (comprador rompendo topo de G2, fundo >= fundo do GR)
624
        // 3) Encontrar G3 (comprador rompendo topo de G2, fundo >= fundo do GR)
577
        int idxPrimeiroCompradorAposG2 = -1;
625
        int idxPrimeiroCompradorAposG2 = -1;
578
        for (int i = idxG2 + 1; i < n; i++) {
626
        for (int i = idxG2 + 1; i < n; i++) {
579
            Candle c = candles.get(i);
627
            Candle c = candles.get(i);
-
 
628
-
 
629
            // OUTSIDE em relação ao GR (até G3)
-
 
630
            if (isOutsideReferencia(ref, c)) {
-
 
631
                lastIndex = i;
-
 
632
                log(String.format(
-
 
633
                        "RefV[%d]: OUTSIDE em [%d] antes da sequência compradora de G3. Padrão descartado.",
-
 
634
                        idxRef, i));
-
 
635
                return new ResultadoPadrao(null, lastIndex);
-
 
636
            }
580
637
581
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
638
            if (!c.isCandleComprador() && !c.isCandleVendedor()) {
582
                continue;
639
                continue;
583
            }
640
            }
584
641
Line 600... Line 657...
600
        int idxG3 = -1;
657
        int idxG3 = -1;
601
        Candle g3 = null;
658
        Candle g3 = null;
602
659
603
        for (int i = idxPrimeiroCompradorAposG2; i < n; i++) {
660
        for (int i = idxPrimeiroCompradorAposG2; i < n; i++) {
604
            Candle c = candles.get(i);
661
            Candle c = candles.get(i);
-
 
662
-
 
663
            // OUTSIDE em relação ao GR (ATÉ IDENTIFICAR G3)
-
 
664
            if (isOutsideReferencia(ref, c)) {
-
 
665
                lastIndex = i;
-
 
666
                log(String.format(
-
 
667
                        "RefV[%d]: OUTSIDE em [%d] durante formação de G3. Padrão descartado.",
-
 
668
                        idxRef, i));
-
 
669
                return new ResultadoPadrao(null, lastIndex);
-
 
670
            }
-
 
671
605
            if (!c.isCandleComprador()) {
672
            if (!c.isCandleComprador()) {
606
                lastIndex = i - 1;
673
                lastIndex = i - 1;
607
                break;
674
                break;
608
            }
675
            }
609
676
Line 651... Line 718...
651
        padrao.setGatilho3(g3);
718
        padrao.setGatilho3(g3);
652
        padrao.setGatilho4(g4);
719
        padrao.setGatilho4(g4);
653
720
654
        return new ResultadoPadrao(padrao, lastIndex);
721
        return new ResultadoPadrao(padrao, lastIndex);
655
    }
722
    }
-
 
723
656
724
657
    // =====================================================================
725
    // =====================================================================
658
    // HELPER – Candle outside em relação ao GR
726
    // HELPER – Candle outside em relação ao GR
659
    // =====================================================================
727
    // =====================================================================
660
728