Python

for i in dataset: if i < i+1 and: print ('yes'), if i > i+1: print ('no')

`i`

is a value from `dataset`

, `i+1`

is the value +1, not the next value in `dataset`

.
See more:

Hello Folks,

i want to create a script, that can look/iterate over datasets from Stocks/Charts and count/identifies Waveform-Patterns in them. I wanted to base that on Elliott Wave Rules.

So there are some basic rules like:

"

This is the most basic rule,underlying most other rules. Why is that? Because Elliott Wave´s have a fractal nature, that means, that WITHIN lets say, the wave that would count as wave number 1, one can find the same 5 step wave, just, in this case, on a lower timeframe/candlesize.

That means, it should be possible to set up basic rules, and apply them onto the smallest datapoints that can be found in the dataset, and depending on that outcome, also find the same pattern structure in a higher timeframe.

What do you think, does this thoughts make any sense?

And most importantly: how would i set up this basic rules in a way, in which the script iterates over the whole dataset and places "setpoints" as identifiers or as, so to speak, "counting" of the waves?

I was thinking of a very simple loop that just goes over every datapoint and checks if i+1 is greater or smaller than i, the previous one. If it is smaller, then the first rule would apply which is: wave 2 never exceeds wave one (which means, the lowest point of wave 2 cannot be lower than the start of the wavecounting which would be position 0).

IF this condition is met, and the datapoints would go up again, then the second rule would apply which is: wave 3 cannot be the shortest wave of the upgoing (the impulse) waves.

IF this condition is also met, then the third rule would apply, which is, that the lowest (of the next ieteratet) datapoint of wave 4, that means the minima in that area, cannot be lower or equal than the maxima of wave 1.

And so on.... this would mean, i would check for lokal minima and maxima, according to the "setpoints" that the script set in the data before (within the process of checking every datapoint for its values, related to the previous values if beeing lower or higher).

I really dont know, what could be a more simple or elegant solution, because i am a totall beginner.

I also thought of applying analysis and taking derivaties and so on to find minima and maxima, but this would always need a certain region wihin the dataset, because it is always just a "lokal" minima or lokal maxima.

Also i thought of how to really apply the fractal structure? just by using different charts with different timeframes? or can i just "cut out" more and more datapoints to kind of "zoom out" the perspective?

Furthermore i would also think, that some sort of "smoothing" would be nice, because it always happens, that the above mentioned conditions are not EXACTLY met, but more, that some irregularities arise, but still the overall pattern is visible and according to the rules.

How do i start?

And please, dont tell me just to start by doing "how do i learn python in 2 hours" tutorials on youtube. I was going through the whole "head first python" book and still dont know how to start.

I somehow still think it could be reduced to some simple loops that relate to each another.

I appreaciate your suggestions and give thanks,

Benjamin

**What I have tried:**

I tried the very simple loop, that by the way does not work:

i want to create a script, that can look/iterate over datasets from Stocks/Charts and count/identifies Waveform-Patterns in them. I wanted to base that on Elliott Wave Rules.

So there are some basic rules like:

"

Wave 2 never retraces more than 100% of wave 1. Wave 3 cannot be the shortest of the three impulse waves, namely waves 1, 3 and 5. Wave 4 does not overlap with the price territory of wave 1, except in the rare case of a diagonal triangle formation.

This is the most basic rule,underlying most other rules. Why is that? Because Elliott Wave´s have a fractal nature, that means, that WITHIN lets say, the wave that would count as wave number 1, one can find the same 5 step wave, just, in this case, on a lower timeframe/candlesize.

That means, it should be possible to set up basic rules, and apply them onto the smallest datapoints that can be found in the dataset, and depending on that outcome, also find the same pattern structure in a higher timeframe.

What do you think, does this thoughts make any sense?

And most importantly: how would i set up this basic rules in a way, in which the script iterates over the whole dataset and places "setpoints" as identifiers or as, so to speak, "counting" of the waves?

I was thinking of a very simple loop that just goes over every datapoint and checks if i+1 is greater or smaller than i, the previous one. If it is smaller, then the first rule would apply which is: wave 2 never exceeds wave one (which means, the lowest point of wave 2 cannot be lower than the start of the wavecounting which would be position 0).

IF this condition is met, and the datapoints would go up again, then the second rule would apply which is: wave 3 cannot be the shortest wave of the upgoing (the impulse) waves.

IF this condition is also met, then the third rule would apply, which is, that the lowest (of the next ieteratet) datapoint of wave 4, that means the minima in that area, cannot be lower or equal than the maxima of wave 1.

And so on.... this would mean, i would check for lokal minima and maxima, according to the "setpoints" that the script set in the data before (within the process of checking every datapoint for its values, related to the previous values if beeing lower or higher).

I really dont know, what could be a more simple or elegant solution, because i am a totall beginner.

I also thought of applying analysis and taking derivaties and so on to find minima and maxima, but this would always need a certain region wihin the dataset, because it is always just a "lokal" minima or lokal maxima.

Also i thought of how to really apply the fractal structure? just by using different charts with different timeframes? or can i just "cut out" more and more datapoints to kind of "zoom out" the perspective?

Furthermore i would also think, that some sort of "smoothing" would be nice, because it always happens, that the above mentioned conditions are not EXACTLY met, but more, that some irregularities arise, but still the overall pattern is visible and according to the rules.

How do i start?

And please, dont tell me just to start by doing "how do i learn python in 2 hours" tutorials on youtube. I was going through the whole "head first python" book and still dont know how to start.

I somehow still think it could be reduced to some simple loops that relate to each another.

I appreaciate your suggestions and give thanks,

Benjamin

I tried the very simple loop, that by the way does not work:

for i in dataset: if i < i+1 and: print ('yes'), if i > i+1: print ('no')

In

Python

for i in dataset: if i < i+1 and: print ('yes'), if i > i+1: print ('no')

`i`

is a value from `dataset`

, `i+1`

is the value +1, not the next value in `dataset`

.
Permalink

Share this answer

How on earth do you expect that to work?

Think about it logically: if you have a number

None of them did, did they?

So how do you expect your data to do that? Your code sample - if it prints anything - will only ever print "yes" - it can't print "no" under normal maths.

What you need to do is compare**adjacent** elements of your data. If you have an set of integers you can spot the transition from "rising" to "falling" pretty easily manually by comparing the current value with the previous one:

So go back to your course notes, and think about how you access "this element" and "the previous element" than work out how to compare them.

Think about it logically: if you have a number

`N`

under what circumstances can `N`

be greater than `N + 1`

? If you still aren't sure what I'm saying, take random numbers and check them: 3:3 + 1, 666:666 + 1, ... If you generate yourself 100 numbers and try it, how many of them said that `N`

was greater than `N + 1`

?None of them did, did they?

So how do you expect your data to do that? Your code sample - if it prints anything - will only ever print "yes" - it can't print "no" under normal maths.

What you need to do is compare

1 ------ 10 Rising 100 Rising 101 Rising 100 Falling 101 Rising 1 Falling 2 RisingAnd so on.

So go back to your course notes, and think about how you access "this element" and "the previous element" than work out how to compare them.

Permalink

Share this answer

Comments

Benjamin di Lorenzo
6-Oct-21 6:40am

okay, thanks man, i did not see the forest for the trees.

my Solution to the iteration now is simply:

for x in range(0,len(dataset)):

if dataset[x]<dataset[x+1]:

print('rising')

elif dataset[x]>dataset[x+1]:

print('falling')

That works so far, because it prints coherently "rising" or "falling",

when the corresponding values rise or drop.

Do you have some other hints on how to proceed or to set up this structure?

Thanks a lot, Benjamin

my Solution to the iteration now is simply:

for x in range(0,len(dataset)):

if dataset[x]<dataset[x+1]:

print('rising')

elif dataset[x]>dataset[x+1]:

print('falling')

That works so far, because it prints coherently "rising" or "falling",

when the corresponding values rise or drop.

Do you have some other hints on how to proceed or to set up this structure?

Thanks a lot, Benjamin

OriginalGriff
6-Oct-21 6:56am

Think about exactly what you are trying to do, and work from there. Think abotu what you would do in the real world to do it manually, and what you woudl need to write down to help you do that.

This may help as well: How to Write Code to Solve a Problem, A Beginner's Guide[^]

This may help as well: How to Write Code to Solve a Problem, A Beginner's Guide[^]

Richard Deeming
6-Oct-21 6:49am

`N`

be greater than `N + 1`

?"Well,

`N`

is an integer type, is set to the maximum value for the type, and overflow checking is off, then `N > N + 1`

will be true. 😁
OriginalGriff
6-Oct-21 6:55am

Yes, it can - but ... "lies to children" are going on here!

He's clearly a beginner, and explaining that computer number are limited just confuses the issue when his understanding of what is going on is so awry to start with (IMO).

He's clearly a beginner, and explaining that computer number are limited just confuses the issue when his understanding of what is going on is so awry to start with (IMO).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900