0 beğenilme 0 beğenilmeme
34 kez görüntülendi
//@version=5

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// © reees

//@version=5

 

indicator("Harmonic Pattern Detection, Prediction, and Backtesting System","Harmonics",overlay=true,max_lines_count=500,max_labels_count=500,max_bars_back=500)

 

import reees/TA/85 as t

import reees/Draw/27 as draw

import reees/Utilities/5 as u

import reees/Pattern/1 as p

import reees/Obj_XABCD_Harmonic/10 as h

//import reees/Algebra/3 as alg

 

//-----------------------------------------

// inputs and vars  

//-----------------------------------------

 

// Pattern Type Inputs

var bullOn = input.bool(true, "Bullish", inline="type_b", group="Include")

var bearOn = input.bool(true, "Bearish", inline="type_b", group="Include")

var incOn = input.bool(true, "Potential/Incomplete", inline="type_b", group="Include")

var hsOn = input.bool(true, "Only high scoring", inline="type_b", group="Include",tooltip="Only show patterns that meet your 'If score is above' entry requirement.")

var i_lb = input.bool(false,"Lookback bars",group="Include",inline="h")

var i_lbn = input.int(100,"",group="Include",inline="h")

var gartOn = input.bool(true, "Gartley:    ", inline="gart", group="Types & Targets")

var gart_t1 = input.string(".618 AD", "Target 1", inline="gart", group="Types & Targets", options=[".382 AD",".5 AD",".618 AD",".382 XA",".5 XA",".618 XA","1.272 XA","1.618 XA",".382 CD",".5 CD",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var gart_t2 = input.string("1.272 AD", " Target 2", inline="gart", group="Types & Targets", options=["None",".618 AD","1.272 AD","1.618 AD",".618 XA","1.272 XA","1.618 XA",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var batOn = input.bool(true, "Bat:          ", inline="bat", group="Types & Targets")

var bat_t1 = input.string(".618 AD", "Target 1", inline="bat", group="Types & Targets", options=[".382 AD",".5 AD",".618 AD",".382 XA",".5 XA",".618 XA","1.272 XA","1.618 XA",".382 CD",".5 CD",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var bat_t2 = input.string("1.272 AD", " Target 2", inline="bat", group="Types & Targets", options=["None",".618 AD","1.272 AD","1.618 AD",".618 XA","1.272 XA","1.618 XA",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var bflyOn = input.bool(true, "Butterfly:  ", inline="bfly", group="Types & Targets")

var bfly_t1 = input.string(".618 AD", "Target 1", inline="bfly", group="Types & Targets", options=[".382 AD",".5 AD",".618 AD",".382 XA",".5 XA",".618 XA","1.272 XA","1.618 XA",".382 CD",".5 CD",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var bfly_t2 = input.string("1.272 AD", " Target 2", inline="bfly", group="Types & Targets", options=["None",".618 AD","1.272 AD","1.618 AD",".618 XA","1.272 XA","1.618 XA",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var crabOn = input.bool(true, "Crab:        ", inline="crab", group="Types & Targets")

var crab_t1 = input.string(".618 AD", "Target 1", inline="crab", group="Types & Targets", options=[".382 AD",".5 AD",".618 AD",".382 XA",".5 XA",".618 XA","1.272 XA","1.618 XA",".382 CD",".5 CD",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var crab_t2 = input.string("1.618 AD", " Target 2", inline="crab", group="Types & Targets", options=["None",".618 AD","1.272 AD","1.618 AD",".618 XA","1.272 XA","1.618 XA",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var sharkOn = input.bool(true, "Shark:       ", inline="shark", group="Types & Targets")

var shark_t1 = input.string(".382 AD", "Target 1", inline="shark", group="Types & Targets", options=[".382 AD",".5 AD",".618 AD",".382 XA",".5 XA",".618 XA","1.272 XA","1.618 XA",".382 CD",".5 CD",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var shark_t2 = input.string("C", " Target 2", inline="shark", group="Types & Targets", options=["None",".618 AD","1.272 AD","1.618 AD",".618 XA","1.272 XA","1.618 XA",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var cyphOn = input.bool(true, "Cypher:     ", inline="cyph", group="Types & Targets")

var cyph_t1 = input.string(".618 CD", "Target 1", inline="cyph", group="Types & Targets", options=[".382 AD",".5 AD",".618 AD",".382 XA",".5 XA",".618 XA","1.272 XA","1.618 XA",".382 CD",".5 CD",".618 CD","1.272 CD","1.618 CD","A","B","C"])

var cyph_t2 = input.string("1.618 XA", " Target 2", inline="cyph", group="Types & Targets", options=["None",".618 AD","1.272 AD","1.618 AD",".618 XA","1.272 XA","1.618 XA",".618 CD","1.272 CD","1.618 CD","A","B","C"])

// Entry/Stop Inputs

var e_afterC = input.bool(true,"Enter after Point C",group="Entry/Stop")

var e_lvlc = input.string("Nearest confluent PRZ level","       Enter at",options=["Nearest confluent PRZ level","Farthest confluent PRZ level","Between the two confluent PRZ levels","Nearest PRZ level","Farthest PRZ level"],group="Entry/Stop")

var e_aboveC = input.float(90,"       If score is above",group="Entry/Stop",tooltip="A trade will only be entered if the pattern's score is above the specified value. Note that when entering a trade after Point C, we have an incomplete score because we can't yet measure Point D's confluence with the PRZ. Therefore the final pattern score may differ from the incomplete score at the time of entry. Set this to 0 if you wish to enter a trade on every pattern.")

var e_afterD = input.bool(true,"Enter after Point D",group="Entry/Stop")

var e_lvldPct = input.float(1.0,"       Enter at limit % away from D",minval=0.0,step=.1,group="Entry/Stop",tooltip="Enter the trade after a valid point D has been confirmed, up to the limit of this % away from Point D. E.g. for a bullish pattern (long entry), if this value is set to 5%, an entry will be placed at the best possible price up to 5% above point D. If 'Entry after Point C' is also set, the entry will be at whichever level is reached first. \n\nIf the entry level is not reached, the pattern will not be included in the Success Rate and Return % statistics.")

var e_aboveD = input.float(90,"       If score is above",group="Entry/Stop",tooltip="A trade will only be entered if the pattern's score is above the specified value. Set this to 0 if you wish to enter a trade on every pattern.")

var e_tLimit = input.float(.5,"       Entry window (time limit)",group="Entry/Stop",tooltip="Time limit for order entry, specified in pattern lengths (e.g. '0.5' means half the total pattern length). If the time limit expires before the order is filled, it will be cancelled and no trade will be entered for the pattern.")

var stopPct = input.float(75,"Stop",step=1.0,minval=0.0,group="Entry/Stop",inline="stop")

var stopB = input.string("% of distance to target 1, beyond entry","",options=["% beyond X or D","% beyond Farthest PRZ level","% beyond Point D","% beyond entry","% of distance to target 1, beyond entry"],group="Entry/Stop",inline="stop",tooltip="Set stop-loss % beyond the specified level. If price reaches this level before the first target is hit, or before the target timeout period expires, the pattern will be considered a failure.\n\n'% beyond X or D' = percentage below Point X or Point D, whichever is farther from entry\n\n'% of distance to target 1' = a percentage of the distance from the entry level to target 1. \n\n'% beyond entry' = percentage above/below the entry level. \n\n'% beyond Point D' = percentage above/below Point D. \n\n'beyond Farthest PRZ level' = percentage above/below the Farthest PRZ level")

// Pattern Inputs

var t_b = input.int(1,"Pattern validation length (# trailing bars)",minval=1,group="Pattern",tooltip="The number of bars after pivot point D (or point C for incomplete patterns) before a pattern is considered valid. This affects how soon patterns will be drawn and entries can be placed.")

var pctErr = input.float(15.0,"Allowed fib ratio error %",step=1.0,minval=0.0,maxval=50.0,group="Pattern",inline="err")

var pctAsym = input.float(250.0,"Allowed leg length asymmetry %",step=1.0,minval=0.0,maxval=1000.0,group="Pattern",inline="asym",tooltip="A leg is considered valid if its length (ΔX/number of bars) is within this % of the average length of the other legs in the pattern.")

var w_e = input.float(4.0,"Weight",step=.1,minval=0.0,group="Pattern",inline="err",tooltip="A leg is considered valid if its retracement (ΔY) ratio is within this % of the defined harmonic ratio. Weight determines the weight of retracement % error in the total score calculation for a pattern.")

//var w_a = input.float(0.0,"Weight",step=.1,minval=0.0,group="Pattern",inline="asym",tooltip="A leg is considered valid if its length (ΔX/number of bars) is within this % of the average length of the other legs in the pattern. Weight determines the weight of length asymmetry in the total score calculation for a pattern.")

var tLimitMult = input.float(3,"Pattern time limit",group="Pattern",step=.1,minval=.1,tooltip="Time limit for a completed pattern to reach the projected targets. Value is specified in terms of total pattern length (point X to point D), i.e. a value of 1 will allow one pattern length to elapse before the pattern times out and can no longer be considered successful. Patterns that time out will not count towards the success rates in the results table.")

var w_p = input.float(2.0,"Weight of PRZ level confluence",step=.1,minval=0.0,group="Pattern",tooltip="Weight applied to Potential Reversal Zone fib level confluence in the total score calculation for a pattern. The closer together the two closest PRZ fib levels are, the higher the score.")

var w_d = input.float(3.0,"Weight of point D / PRZ level confluence",step=.1,minval=0.0,group="Pattern",tooltip="Weight applied to the confluence of point D with the Potential Reversal Zone levels in the total score calculation for a pattern. The closer point D is to either of the two confluent PRZ fib levels, the higher the score. ")

 

// Alert Inputs

//var a_on = input.bool(true, "Alert", inline="alert", group="Alerts")

var a_type = input.string("Both", "Alert for", options=["Potential patterns","Complete patterns","Both"], inline="alert", group="Alerts")

 

// Display Inputs

var c_bline = input.color(color.new(color.green,20), "Bullish lines", group="Display")

var c_beline = input.color(color.new(color.red,20), "Bearish lines", group="Display")

var c_blab = input.color(color.new(color.green,75), "Bullish labels", group="Display")

var c_belab = input.color(color.new(color.red,75), "Bearish labels", group="Display")

var l_txt = input.color(color.new(color.white,20), "Label text", group="Display")

 

var int[] includeTps = array.new_int()

if barstate.isfirst

    if gartOn

        array.push(includeTps,1)

    if batOn

        array.push(includeTps,2)

    if bflyOn

        array.push(includeTps,3)

    if crabOn

        array.push(includeTps,4)

    if sharkOn

        array.push(includeTps,5)

    if cyphOn

        array.push(includeTps,6)

var h.harmonic_params params = h.init_params(pctErr,pctAsym,includeTps,w_e,w_p,w_d)     // scoring and validation parameters for xabcd_harmonic objects

 

// xabcd_harmonic object pointers

var h.xabcd_harmonic[] bullGart = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bullBat = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bullBfly = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bullCrab = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bullShark = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bullCyph = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bearGart = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bearBat = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bearBfly = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bearCrab = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bearShark = array.new<h.xabcd_harmonic>()

var h.xabcd_harmonic[] bearCyph = array.new<h.xabcd_harmonic>()

// var int[] lastX = array.new_int(5,0)

 

// temp/last/incomplete pattern structures

var h.xabcd_harmonic[] pending = array.new<h.xabcd_harmonic>()

var label[] f
önce Grafik kategorisinde (14 puan) tarafından | 34 kez görüntülendi

1 cevap

0 beğenilme 0 beğenilmeme
Merhabalar,

Sizlere maalesef olumsuz dönüş yapıyoruz

iyi çalışmalar
önce (33,088 puan) tarafından
9,140 soru
9,095 cevap
5,026 yorum
27,720 kullanıcı