OPEN-SOURCE SCRIPT

AI Buy/Sell SIgnals by price prediction

//version=5

indicator("AI Buy/Sell SIgnals by price prediction", overlay=true)

learning_times = input.int(200, "Learning times")

ema_length = input.int(1, "EMA length")

learn_filter_length = input.int(5, "SMA Filter length")

learning_block = input.bool(title="Filter Learning data", defval=true)

reaction = input.int(1, "Reaction (1-3)")

a = close



var input_list = array.new_float(100)

var weights = array.new_float(100)

var outt = array.new_float(2)



//def info table

var tab = label.new(bar_index, high, ".", style=label.style_label_left, color=color.white)

infotable = table.new(position=position.top_right, columns=3, rows=3, bgcolor=color.new(color.white, 0))

label.delete(tab)



get_errg(input_array, weights_array, len_of_both) =>

out = 0

for x = 0 to len_of_both

out += int(array.get(weights_array, x) * array.get(input_array, x))

out



//getting inputs

array.set(input_list, 0, ta.valuewhen(bar_index, close, 10))

array.set(input_list, 1, ta.valuewhen(bar_index, close, 20))

array.set(input_list, 2, ta.valuewhen(bar_index, close, 30))

array.set(input_list, 3, ta.valuewhen(bar_index, close, 40))

array.set(input_list, 4, ta.valuewhen(bar_index, close, 50))

array.set(input_list, 5, ta.valuewhen(bar_index, close, 60))

array.set(input_list, 6, ta.valuewhen(bar_index, close, 70))

array.set(input_list, 7, ta.valuewhen(bar_index, close, 80))

array.set(input_list, 8, ta.valuewhen(bar_index, close, 90))

array.set(input_list, 9, ta.valuewhen(bar_index, close, 100))

array.set(input_list, 10, ta.valuewhen(bar_index, open, 10))

array.set(input_list, 11, ta.valuewhen(bar_index, open, 20))

array.set(input_list, 12, ta.valuewhen(bar_index, open, 30))

array.set(input_list, 13, ta.valuewhen(bar_index, open, 40))

array.set(input_list, 14, ta.valuewhen(bar_index, open, 50))

array.set(input_list, 15, ta.valuewhen(bar_index, open, 60))

array.set(input_list, 16, ta.valuewhen(bar_index, open, 70))

array.set(input_list, 17, ta.valuewhen(bar_index, open, 80))

array.set(input_list, 18, ta.valuewhen(bar_index, open, 90))

array.set(input_list, 19, ta.valuewhen(bar_index, open, 100))



// teaching neural network

sma = ta.sma(ta.ema(close, 10), learn_filter_length)

if math.abs(ta.valuewhen(bar_index, sma, 1) - sma) > close / 10000 or not learning_block

for rn = 0 to learning_times

for list_number = 0 to 19

if rn == 0

array.set(weights, list_number, 1) // Initialisiere die Gewichte mit 1

else

target_output = close[50]

current_output = get_errg(input_list, weights, 19)

current_input = array.get(input_list, list_number)

target_input = target_output / current_output * current_input // Berechne die entsprechende Eingabe für das Gewicht

array.set(weights, list_number, target_input)



// getting new output

array.set(outt, 0, get_errg(input_list, weights, 19))



var col = #ff1100

var table_i_col = ''

var pcol = #ff1100



// getting signals

if ta.ema(ta.valuewhen(bar_index, array.get(outt, 0), 1), ema_length) < ta.sma(ta.ema(array.get(outt, 0), ema_length), 10)

col := #39ff14

table_i_col := 'AI Up'

if ta.ema(ta.valuewhen(bar_index, array.get(outt, 0), 1), ema_length) > ta.sma(ta.ema(array.get(outt, 0), ema_length), 10)

col := #ff1100

table_i_col := 'AI down'



if ta.valuewhen(bar_index, col, 50) == col and ta.valuewhen(bar_index, col, 10) == ta.valuewhen(bar_index, col, 20) and ta.valuewhen(bar_index, col, 30) == ta.valuewhen(bar_index, col, 40) and reaction == 1

pcol := col



if ta.valuewhen(bar_index, col, 50) == col and ta.valuewhen(bar_index, col, 10) == ta.valuewhen(bar_index, col, 20) and reaction == 2

pcol := col



if ta.valuewhen(bar_index, col, 50) == col and reaction == 3

pcol := col



// plotting all info

plot(0, "plot2", col, offset=50)

plot(ta.sma(ta.ema(close, 10), 10), color=ta.valuewhen(bar_index, pcol, 50), linewidth=2)



table.cell(infotable, 0, 0, str.tostring(float(array.get(outt, 0))))

table.cell(infotable, 0, 1, str.tostring(float(ta.valuewhen(bar_index, array.get(outt, 0), 50))))

table.cell(infotable, 0, 2, str.tostring(table_i_col))
Breadth IndicatorsCandlestick analysisMoving Averages

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian