Pattern algo how work ?

Posted By: faustf

Pattern algo how work ? - 12/25/20 22:08

hi guys , i am new of Zorro , i try to understand a script Workshop7 , what type of pattern is this ?? and how can create it, if i have for example a shouting star ? ?
Code
if(adviseLong(PATTERN+FAST+2+RETURNS,0,
		priceHigh(2),priceLow(2),priceClose(2),
		priceHigh(1),priceLow(1),priceClose(1),
		priceHigh(1),priceLow(1),priceClose(1),
		priceHigh(0),priceLow(0),priceClose(0)) > 50)
		enterLong();


thanks at all
Posted By: danatrader

Re: Pattern algo how work ? - 12/26/20 09:37

That has, as said, nothing to do with traditional patterns.
So you can't create a shouting star, nor the shooting star, or maybe you can.

Maybe you should have a look at the latest article of Petra on the TFH about Perry Kaufmann patterns.
You may find some clear difference.

But the pattern analyzer can also analyze different things, you could use the shooting star and maybe also the shouting star fom TA-LIB and take the return value of that (100 or -100) as one value of your pattern, besides other values, e.g. bool is close above or below SMA and so on.

if(adviseLong(PATTERN+2+RETURNS,0, <<------- PATTERN+2 devides the patterns in two groups, therefore input must be possible to be divided by two, RETURNS is the training target, the 0 is the number of features within a signals array if more than 3 are used.
priceHigh(2),priceLow(2),priceClose(2), <<------- PATTERN+2 means the lines are divided in two groups, which are compared, in this very case, the actual bar, and the previous bar, are grouped (0) and (1), then the other group previous bar (1) and (2) are grouped.
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(0),priceLow(0),priceClose(0)) > 50) <<----- then those price developments are comapred and the advise decides if go long or short on the pattern (compare within pattern groups)
enterLong();
if(adviseShort() > 50)
enterShort();
}


priceHigh(2),priceLow(2),priceClose(2), <<-------- group 1
priceHigh(1),priceLow(1),priceClose(1),


priceHigh(1),priceLow(1),priceClose(1), <<-------- group 2
priceHigh(0),priceLow(0),priceClose(0)
Posted By: faustf

Re: Pattern algo how work ? - 12/26/20 10:13

where i find the article Petra on the TFH about Perry Kaufmann patterns. ??
Posted By: danatrader

Re: Pattern algo how work ? - 12/26/20 12:45

https://financial-hacker.com/petra-on-programming-short-term-candle-patterns/
Posted By: faustf

Re: Pattern algo how work ? - 12/26/20 23:40

thanks , i read it , but i think .......i not undesrtand o_O , i understand she write in article: "from the TA library, the pattern functions return +100 for a bullish pattern, -100 for a bearish pattern, and 0 for no pattern.", but how generate this portion of code ? if(priceLow(0) > priceHigh(1) && priceClose(0) < priceOpen(0))
this part of code , rapresents this ? https://ibb.co/JBJ9zpj
how is possible describe a pattern if you not give min and max pips ? , example priceClose(0) < priceOpen(0) , if priceClose is 0.91235 and priceOpen is 0.91236 is true but have low pips body candel and have a sense , if priceClose is 0.91235 and priceOpen is 0.92325 , is another type of candel and have another sense , how zorro undesrtand what type of pattern i want ?
Posted By: danatrader

Re: Pattern algo how work ? - 12/27/20 00:43

Workshop 7 is just a sequence of highs, lows , close, independant of size, the aim is to identify patterns of high, low, close sequence with a prediction power of three days.
It also states "BTW, this strategy does not work", it is just an example.

So of course you can also do something more exact, e.g. with ranges, if(priceHigh()-priceLow() > ATR(4)) and so on.
One thing is rice candle patterns, the other thing is "patterns".

Patterns can be anything, it can also be, if price on wednesday is lower than on tuesday but higher than on monday.

BTW, the patterns in TA-LIB have the definition as they are delivered by the TA-LIB developers.
Of course you may still code your script to only take the one bigger than, or smaller than ... into account, or just the ones above or below a moving average, and so on.
Posted By: faustf

Re: Pattern algo how work ? - 12/27/20 10:37

i try to insert different expression but return me error
if(adviseLong(PATTERN+FAST+2+RETURNS,0,
price(2)>price(1) && price(1)<priceClose(1)))
enterLong();

Syntax error : cant go flase goto:double
price(2)>price(1) && price(1)<priceClose(1)))
Posted By: danatrader

Re: Pattern algo how work ? - 12/27/20 11:55

Well, first, if(adviseLong(PATTERN+FAST+2+RETURNS,0, <<<---- the "2" defines that you have two pattern groups

price(2)>price(1) && price(1)<priceClose(1))) <<<---- "&&" connects your two statements, so you do not have two pattern groups

if(adviseLong(PATTERN+FAST+2+RETURNS,0,
bla,bla,bla,
bla,bla,bla,
bla,bla,bla,
bla,bla,bla,) > 50) <<<---- replace? you did also remove the condition what to do with the prediction result
enterLong();


And at last, the PATTERN function searches in historic data for patterns, defined by characteristics, so you don't feed a pattern, you define the characteristics you want it to "search" for patterns.

This:
price(2)>price(1) && price(1)<priceClose(1) <<<---- you try to feed it with a pattern.

I would strongly advise you, to read all the TFH, buy the black book, go from there.
BTW, the black book is probably the fastest way to get you up and running.
Posted By: faustf

Re: Pattern algo how work ? - 12/27/20 16:29

another questions sorry , zorro use price = Returns the mean price , but how calculate the mean price ? use high and low /2 is possible ask at price use for example open + close /2 instead of close+open/2 ?
thankz
and why if i use this
Code
if(adviseLong(PATTERN+FAST+1+RETURNS,0,
		price(2)>price(1) && price(1)<priceClose(1))>50)  
		enterLong();


not return nothing like if not open operation o_O
Posted By: danatrader

Re: Pattern algo how work ? - 12/27/20 16:37

if(adviseLong(PATTERN+FAST+1+RETURNS,0, <<---- don't know if 1 works, never tried, but...
price(2)>price(1) && price(1)<priceClose(1))>50) <<---- this is not certeinly characteristics to "search for a pattern" this is a condition
enterLong();


This could work:
if(adviseLong(PATTERN+FAST+1+RETURNS,0,
price(2),price(1),price(0),
priceClose(2),priceClose(1),priceClose(0))>50)
enterLong();
Posted By: faustf

Re: Pattern algo how work ? - 12/27/20 19:05

sorry again i dont arrive to understand how is possible this code is equal at pattern, price(2),price(1),price(0),priceClose(2),priceClose(1),priceClose(0))>50)
Posted By: danatrader

Re: Pattern algo how work ? - 12/28/20 08:34

Don't know what to say anymore... read here:

https://manual.zorro-project.com/advisor.htm

PATTERN (Pattern Analyzer)
Posted By: danatrader

Re: Pattern algo how work ? - 12/29/20 19:20

And here:

https://financial-hacker.com/better-tests-with-oversampling/#more-1055
Price action example
Posted By: faustf

Re: Pattern algo how work ? - 01/05/21 00:02

so let me tell if i thinked good , the code
if(adviseLong(PATTERN+FAST+2,0, // train patterns with trade results
priceHigh(2),priceLow(2),priceClose(2),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(0),priceLow(0),priceClose(0)) > Limit)

tell at zorro look in this 2 group , composed of priceHig(2)......priceClose(1) (first group ) and priceHigh(1)......peiceClose(0) (second group) if exist some relation (over time repetitive) , but this 2 group not indicate for example a classical price action pattern like morning star or other
is correct ? i understund ?
thanks at all
© 2024 lite-C Forums