OPEN-SOURCE SCRIPT

geebtest

От paahv_winmost
Обновлено
geebtest //version=5
indicator(title="geebtest", shorttitle="geebtest", overlay=true)

// การตั้งค่าอินพุต
countBackPeriod = input.int(defval=20, minval=1, title="จำนวนแท่งเทียนที่จะนับย้อนหลัง", group="การตั้งค่า")
endOffset = input.int(defval=0, minval=0, title="สิ้นสุดที่แท่งที่ (offset จากแท่งปัจจุบัน)", group="การตั้งค่า")

// สร้างอาร์เรย์สำหรับเก็บข้อมูลสีของแท่งเทียน
var int[] isGreenArray = array.new_int()
var int[] isRedArray = array.new_int()
var int[] isYellowArray = array.new_int()

// ตรวจสอบสีของแท่งเทียนปัจจุบัน
currIsGreen = close > open ? 1 : 0
currIsRed = close < open ? 1 : 0
currIsYellow = close == open ? 1 : 0

// ใส่ค่าเข้าไปในอาร์เรย์
array.unshift(isGreenArray, currIsGreen)
array.unshift(isRedArray, currIsRed)
array.unshift(isYellowArray, currIsYellow)

// จำกัดขนาดของอาร์เรย์ให้ไม่เกิน (countBackPeriod + endOffset)
maxLength = countBackPeriod + endOffset
if array.size(isGreenArray) > maxLength
array.pop(isGreenArray)
array.pop(isRedArray)
array.pop(isYellowArray)

// คำนวณจำนวนแท่งเทียนของแต่ละสีในช่วงที่กำหนด
greenCount = 0
redCount = 0
yellowCount = 0

for i = endOffset to endOffset + countBackPeriod - 1
if i < array.size(isGreenArray)
greenCount += array.get(isGreenArray, i)
redCount += array.get(isRedArray, i)
yellowCount += array.get(isYellowArray, i)

// เงื่อนไขการเปิดและปิดสถานะ
var bool inPosition = false
buySignal = false
exitSignal = false

if not inPosition and greenCount >= 13
inPosition := true
buySignal := true
else if inPosition and greenCount == 11 and redCount == 9
inPosition := false
exitSignal := true

// แสดงสัญลักษณ์การซื้อและขายบนกราฟ
plotshape(buySignal, title="สัญญาณซื้อ", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="Buy")
plotshape(exitSignal, title="สัญญาณขาย", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="Exit")

// แสดงจำนวนแท่งเทียนแต่ละสี
if barstate.islast
label.new(bar_index, high, text="เขียว: " + str.tostring(greenCount) + "\nแดง: " + str.tostring(redCount) + "\nเหลือง: " + str.tostring(yellowCount), style=label.style_label_left, color=color.white, textcolor=color.black)
Информация о релизе
//version=5
indicator(title="geebtest", shorttitle="geebtest", overlay=true)

// การตั้งค่าอินพุต
countBackPeriod = input.int(defval=20, minval=1, title="จำนวนแท่งเทียนที่จะนับย้อนหลัง", group="การตั้งค่า")
endOffset = input.int(defval=1, minval=1, title="สิ้นสุดที่แท่งที่ (offset จากแท่งปัจจุบัน)", group="การตั้งค่า")
maxTableRows = input.int(defval=10, minval=1, title="จำนวนแถวสูงสุดในตาราง", group="การตั้งค่า")

// เงื่อนไขสำหรับ Buy และ Exit
buyGreenCount = input.int(defval=13, minval=1, title="จำนวนแท่งเขียวขั้นต่ำสำหรับ Buy", group="เงื่อนไขการเทรด")
exitGreenCount = input.int(defval=11, minval=1, title="จำนวนแท่งเขียวสำหรับ Exit", group="เงื่อนไขการเทรด")
exitRedCount = input.int(defval=9, minval=1, title="จำนวนแท่งแดงสำหรับ Exit", group="เงื่อนไขการเทรด")

// สร้างอาร์เรย์สำหรับเก็บข้อมูลสีของแท่งเทียน
var int[] greenCandleArray = array.new_int()
var int[] redCandleArray = array.new_int()
var int[] dojiFlatCandleArray = array.new_int()

// อาร์เรย์สำหรับเก็บข้อมูลประวัติ
var int[] historicalGreenCounts = array.new_int()
var int[] historicalRedCounts = array.new_int()
var int[] historicalDates = array.new_int()

// ตรวจสอบสีของแท่งเทียนที่แล้ว
prevIsGreen = close[1] > open[1] ? 1 : 0
prevIsRed = close[1] < open[1] ? 1 : 0
prevIsDoji = close[1] == open[1] ? 1 : 0

// ใส่ค่าเข้าไปในอาร์เรย์
array.unshift(greenCandleArray, prevIsGreen)
array.unshift(redCandleArray, prevIsRed)
array.unshift(dojiFlatCandleArray, prevIsDoji)

// จำกัดขนาดของอาร์เรย์
maxLength = countBackPeriod + endOffset
if array.size(greenCandleArray) > maxLength
array.pop(greenCandleArray)
array.pop(redCandleArray)
array.pop(dojiFlatCandleArray)

// คำนวณจำนวนแท่งเทียนของแต่ละสี
greenCount = 0
redCount = 0
dojiCount = 0

for i = endOffset to endOffset + countBackPeriod - 1
if i < array.size(greenCandleArray)
greenCount += array.get(greenCandleArray, i)
redCount += array.get(redCandleArray, i)
dojiCount += array.get(dojiFlatCandleArray, i)

// เงื่อนไขการเปิดและปิดสถานะ
var bool inPosition = false
buySignal = false
exitSignal = false

if not inPosition and greenCount >= buyGreenCount
inPosition := true
buySignal := true
// บันทึกข้อมูลประวัติ
array.unshift(historicalGreenCounts, greenCount)
array.unshift(historicalRedCounts, redCount)
array.unshift(historicalDates, time)
else if inPosition and greenCount == exitGreenCount and redCount == exitRedCount
inPosition := false
exitSignal := true
// บันทึกข้อมูลประวัติ
array.unshift(historicalGreenCounts, greenCount)
array.unshift(historicalRedCounts, redCount)
array.unshift(historicalDates, time)

// จำกัดขนาดของอาร์เรย์ประวัติ
if array.size(historicalGreenCounts) > maxTableRows
array.pop(historicalGreenCounts)
array.pop(historicalRedCounts)
array.pop(historicalDates)

// สร้างและอัพเดทตาราง
var table historyTable = table.new(position.top_right, columns=3, rows=maxTableRows+1, border_width=1)

if barstate.islast
table.cell(historyTable, 0, 0, "Date", bgcolor=color.blue, text_color=color.white)
table.cell(historyTable, 1, 0, "Green", bgcolor=color.blue, text_color=color.white)
table.cell(historyTable, 2, 0, "Red", bgcolor=color.blue, text_color=color.white)

for i = 0 to math.min(maxTableRows - 1, array.size(historicalDates) - 1)
date = array.get(historicalDates, i)
greenCount = array.get(historicalGreenCounts, i)
redCount = array.get(historicalRedCounts, i)

table.cell(historyTable, 0, i+1, str.format("{0,date,yyyy-MM-dd}", date))
table.cell(historyTable, 1, i+1, str.tostring(greenCount))
table.cell(historyTable, 2, i+1, str.tostring(redCount))

// แสดงสัญลักษณ์การซื้อและขายบนกราฟ
plotshape(buySignal, title="สัญญาณซื้อ", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="Buy")
plotshape(exitSignal, title="สัญญาณขาย", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="Exit")

// แสดงจำนวนแท่งเทียนแต่ละสีสำหรับแท่งปัจจุบัน
if barstate.islast
label.new(bar_index, high, text="เขียว: " + str.tostring(greenCount) + "\nแดง: " + str.tostring(redCount) + "\nเหลือง (Doji Flat): " + str.tostring(dojiCount), style=label.style_label_left, color=color.white, textcolor=color.black)
Информация о релизе
//version=5
indicator("แท่งเทียนนับจากน้อยไปมาก", overlay=true)

// ตัวแปร input
total_candles = input.int(100, "จำนวนแท่งรวมที่จะนับ", minval=1)
num_count = input.int(20, "จำนวนแท่งที่จะนับในแต่ละครั้ง", minval=1)
table_rows = input.int(25, "จำนวนแถวในตาราง", minval=1, maxval=25)
start_row = input.int(0, "แถวเริ่มต้นที่จะแสดง", minval=0)

// ฟังก์ชันนับแท่งเทียน
getCandleCounts(start, end) =>
green = 0
red = 0
doji = 0
for i = start to end
if close > open
green += 1
else if close < open
red += 1
else
doji += 1
[green, red, doji]

// สร้างตาราง
var table results = table.new(position.top_right, columns=2, rows=table_rows+1, border_width=1)

// อัพเดทตาราง
if barstate.islast
table.cell(results, 0, 0, "แท่งที่", bgcolor=color.new(color.blue, 70), text_color=color.white)
table.cell(results, 1, 0, "ผลการนับ", bgcolor=color.new(color.blue, 70), text_color=color.white)

for i = 0 to table_rows - 1
row_index = i + start_row
if row_index < total_candles - num_count
start = row_index + 1
end = start + num_count - 1
[green, red, doji] = getCandleCounts(start, end)

candle_text = str.tostring(row_index + 1)
result_text = "เขียว: " + str.tostring(green) + ", แดง: " + str.tostring(red) + ", Doji: " + str.tostring(doji) + "\n(นับแท่ง " + str.tostring(start) + " ถึง " + str.tostring(end) + ")"

table.cell(results, 0, i + 1, candle_text)
table.cell(results, 1, i + 1, result_text)
else
table.cell(results, 0, i + 1, "")
table.cell(results, 1, i + 1, "")

// แสดงผลการนับแท่งปัจจุบัน
if barstate.islast
[current_green, current_red, current_doji] = getCandleCounts(1, num_count)
label.new(bar_index, high,
text="แท่งปัจจุบัน:\nเขียว: " + str.tostring(current_green) +
"\nแดง: " + str.tostring(current_red) +
"\nDoji: " + str.tostring(current_doji) +
"\n(นับแท่ง 1 ถึง " + str.tostring(num_count) + ")",
style=label.style_label_down,
color=color.new(color.blue, 70),
textcolor=color.white)

plot(close, color=color.new(color.purple, 0), linewidth=2, title="ราคาปิด")
Информация о релизе
//version=5
indicator("แท่งเทียนนับจากน้อยไปมาก", overlay=true)

// ตัวแปร input
total_candles = input.int(100, "จำนวนแท่งรวมที่จะนับ", minval=1)
num_count = input.int(20, "จำนวนแท่งที่จะนับในแต่ละครั้ง", minval=1)
table_rows = input.int(25, "จำนวนแถวในตาราง", minval=1, maxval=25)
start_row = input.int(0, "แถวเริ่มต้นที่จะแสดง", minval=0)

// ฟังก์ชันนับแท่งเทียน
getCandleCounts(start, end) =>
green = 0
red = 0
doji = 0
for i = start to end
if close > open
green += 1
else if close < open
red += 1
else
doji += 1
[green, red, doji]

// สร้างตาราง
var table results = table.new(position.top_right, columns=2, rows=table_rows+1, border_width=1)

// กำหนดขนาดอักษรที่เล็กลง
var reduced_text_size = size.tiny

// อัพเดทตาราง
if barstate.islast
table.cell(results, 0, 0, "แท่งที่", bgcolor=color.new(color.blue, 70), text_color=color.white, text_size=reduced_text_size)
table.cell(results, 1, 0, "ผลการนับ", bgcolor=color.new(color.blue, 70), text_color=color.white, text_size=reduced_text_size)

for i = 0 to table_rows - 1
row_index = i + start_row
if row_index < total_candles - num_count
start = row_index + 1
end = start + num_count - 1
[green, red, doji] = getCandleCounts(start, end)

candle_text = str.tostring(row_index + 1)
result_text = "เขียว: " + str.tostring(green) + ", แดง: " + str.tostring(red) + ", Doji: " + str.tostring(doji) + "\n(นับแท่ง " + str.tostring(start) + " ถึง " + str.tostring(end) + ")"

table.cell(results, 0, i + 1, candle_text, text_size=reduced_text_size)
table.cell(results, 1, i + 1, result_text, text_size=reduced_text_size)
else
table.cell(results, 0, i + 1, "", text_size=reduced_text_size)
table.cell(results, 1, i + 1, "", text_size=reduced_text_size)

// แสดงผลการนับแท่งปัจจุบัน
if barstate.islast
[current_green, current_red, current_doji] = getCandleCounts(1, num_count)
label.new(bar_index, high,
text="แท่งปัจจุบัน:\nเขียว: " + str.tostring(current_green) +
"\nแดง: " + str.tostring(current_red) +
"\nDoji: " + str.tostring(current_doji) +
"\n(นับแท่ง 1 ถึง " + str.tostring(num_count) + ")",
style=label.style_label_down,
color=color.new(color.blue, 70),
textcolor=color.white,
size=reduced_text_size)

plot(close, color=color.new(color.purple, 0), linewidth=2, title="ราคาปิด")
Информация о релизе
//version=5
indicator("แท่งเทียนนับจากน้อยไปมาก", overlay=true)

// ตัวแปร input
total_candles = input.int(100, "จำนวนแท่งรวมที่จะนับ", minval=1)
num_count = input.int(20, "จำนวนแท่งที่จะนับในแต่ละครั้ง", minval=1)
table_rows = input.int(25, "จำนวนแถวในตาราง", minval=1, maxval=25)
start_row = input.int(0, "แถวเริ่มต้นที่จะแสดง", minval=0)

// Input สำหรับสีข้อความ
text_color = input.color(color.blue, "สีข้อความ")

// Input สำหรับขนาดตัวอักษร
use_larger_font = input.bool(false, "ใช้ตัวอักษรขนาดใหญ่ขึ้น")

// ฟังก์ชันนับแท่งเทียน
getCandleCounts(start, end) =>
green = 0
red = 0
doji = 0
for i = start to end
if close > open
green += 1
else if close < open
red += 1
else
doji += 1
[green, red, doji]

// สร้างตาราง
var table results = table.new(position.top_right, columns=2, rows=table_rows+1, border_width=1)

// กำหนดขนาดอักษร
text_size = use_larger_font ? size.normal : size.small

// อัพเดทตาราง
if barstate.islast
table.cell(results, 0, 0, "แท่งที่", bgcolor=color.new(color.blue, 70), text_color=color.white, text_size=text_size)
table.cell(results, 1, 0, "ผลการนับ", bgcolor=color.new(color.blue, 70), text_color=color.white, text_size=text_size)

for i = 0 to table_rows - 1
row_index = i + start_row
if row_index < total_candles - num_count
start = row_index + 1
end = start + num_count - 1
[green, red, doji] = getCandleCounts(start, end)

candle_text = str.tostring(row_index + 1)
result_text = "เขียว: " + str.tostring(green) + ", แดง: " + str.tostring(red) + ", Doji: " + str.tostring(doji) + "\n(นับแท่ง " + str.tostring(start) + " ถึง " + str.tostring(end) + ")"

table.cell(results, 0, i + 1, candle_text, text_color=text_color, text_size=text_size, text_halign=text.align_center, bgcolor=color.new(color.gray, 90))
table.cell(results, 1, i + 1, result_text, text_color=text_color, text_size=text_size, text_halign=text.align_left, bgcolor=color.new(color.gray, 90))
else
table.cell(results, 0, i + 1, "", text_size=text_size)
table.cell(results, 1, i + 1, "", text_size=text_size)

// แสดงผลการนับแท่งปัจจุบัน
if barstate.islast
[current_green, current_red, current_doji] = getCandleCounts(1, num_count)
label.new(bar_index, high,
text="แท่งปัจจุบัน:\nเขียว: " + str.tostring(current_green) +
"\nแดง: " + str.tostring(current_red) +
"\nDoji: " + str.tostring(current_doji) +
"\n(นับแท่ง 1 ถึง " + str.tostring(num_count) + ")",
style=label.style_label_down,
color=color.new(color.blue, 70),
textcolor=color.white,
size=size.small)

plot(close, color=color.new(color.purple, 0), linewidth=2, title="ราคาปิด")
Информация о релизе
//version=5
indicator("แท่งเทียนนับตามเงื่อนไข", overlay=true)

// ตัวแปร input
num_count = input.int(20, "จำนวนแท่งที่จะนับในแต่ละครั้ง", minval=1)
input_green = input.int(13, "จำนวนแท่งเขียว (G)", minval=0)
input_red = input.int(7, "จำนวนแท่งแดง (R)", minval=0)
input_doji = input.int(0, "จำนวนแท่ง Doji (Y)", minval=0)

// Input สำหรับสีกล่องและตัวอักษร
box_color = input.color(color.new(color.blue, 70), "สีกล่อง")
text_color = input.color(color.white, "สีตัวอักษร")

// ฟังก์ชันนับแท่งเทียน
getCandleCounts(start, end) =>
green = 0
red = 0
doji = 0
for i = start to end
if close > open
green += 1
else if close < open
red += 1
else
doji += 1
[green, red, doji]

// ฟังก์ชันตรวจสอบเงื่อนไข
checkCondition(green, red, doji) =>
green == input_green and red == input_red and doji == input_doji

// วนลูปตรวจสอบแต่ละแท่งเทียน
for i = 0 to 500 // จำกัดการตรวจสอบที่ 500 แท่งย้อนหลังเพื่อประสิทธิภาพ
[green, red, doji] = getCandleCounts(i, i + num_count - 1)
if checkCondition(green, red, doji)
label.new(bar_index, high,
"แท่งที่ตรงเงื่อนไข:\nG: " + str.tostring(green) +
"\nR: " + str.tostring(red) +
"\nY: " + str.tostring(doji) +
"\n(นับแท่ง " + str.tostring(i + 1) + " ถึง " + str.tostring(i + num_count) + ")",
style=label.style_label_down,
color=box_color,
textcolor=text_color,
size=size.small)

// แสดงผลการนับแท่งปัจจุบัน
if barstate.islast
[current_green, current_red, current_doji] = getCandleCounts(0, num_count - 1)
label.new(bar_index, high,
"แท่งปัจจุบัน:\nG: " + str.tostring(current_green) +
"\nR: " + str.tostring(current_red) +
"\nY: " + str.tostring(current_doji) +
"\n(นับแท่ง 1 ถึง " + str.tostring(num_count) + ")",
style=label.style_label_down,
color=box_color,
textcolor=text_color,
size=size.small)

plot(close, color=color.new(color.purple, 0), linewidth=2, title="ราคาปิด")
Bands and ChannelsCandlestick analysisChart patterns
paahv_winmost

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?

Отказ от ответственности