# Introduction to AI: Refining our Linear Regression Algorithm

Original Source Here

According to this, our last trade is a buy, which is true:

Does the OHLC data match to actual OHLC?

Not at all — the last trade exported by the bot is actually the trade before the last trade, however, there are exactly 456 exported trades and the RSI values are all over the place in exported data:

Seems like we found a problem — it’s in our data. Now let’s modify the data manually and make sure the algorithm works, I set all buy RSI values to 5 and all sell RSI values to 95, if AI identifies the entry conditions correctly, it works perfectly and we just need to fix the data export issues, our output shows 456 trades indeed, let’s check the rest…

`2021–06–05 03:31:59 displaying final raw results..2021–06–05 03:31:59 # of sell trades is 2412021–06–05 03:31:59 # of buy trades is 2152021–06–05 03:31:59 displaying the number of trades by side..2021–06–05 03:31:59 Array ( [1] => 215 [-1] => 241 [0] => 0 )`

Buy conditions minus (without) sell conditions:

`l2 > l &&h3 > h &&c2 > c &&l3 > l &&o > c &&o2 > c &&c3 > c &&o3 > c &&o3 > l2 &&h3 > o &&h3 > c2 &&o3 > l &&o2 > l &&h2 > c &&h3 > c &&c3 > l &&h3 > l &&10 > RSI5[1] &&20 > RSI5[1] &&40 > RSI5[1] &&60 > RSI5[1] &&80 > RSI5[1]`

# Perfect!

And now sell conditions minus (without) buy conditions:

`c2 > o3 &&o > o3 &&c > o &&h > h2 &&c > c2 &&h > h3 &&c > o2 &&c > c3 &&c > o3 &&h2 > o3 &&c2 > l3 &&o > l3 &&c > l2 &&c > l3 &&h > o2 &&h > o3 &&h > c3 &&h > l3 &&RSI5[1] > 5 &&RSI5[1] > 10 &&RSI5[1] > 20 &&RSI5[1] > 40 &&RSI5[1] > 60 &&RSI5[1] > 80`

Perfect again! As you can see, this is actual source code (trading logic) generated by our AI algorithm that we can just copy and paste in Metaeditor IDE, it also generates JSON output with detailed information about statistics and accuracy that we went through in the previous tutorial.

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot