답변완료
감사합니다 지표 변환 부탁드립니다
// INPUT SETTINGS
period = input.int(10, "Period", minval=2)
color lineUpColor = input(title="Color ↑", defval=#6ba583, inline="lines", group="♦︎ lines")
color lineDnColor = input(title="↓", defval=#d75442, inline="lines", group="♦︎ lines")
lw = input.int(2, "Width", [1, 2, 3, 4], inline="lines", group="♦︎ lines")
bool rangeLines = input.bool(true, "Range Lines", inline = 'rangelines', group = "♦︎ lines")
color rnglineColor = input(title="", defval=#000000, inline="rangelines", group="♦︎ lines")
//bool rnglineextend = input.bool(false, "Extend", inline = 'rangelines', group = "lines")
delta = input.string('Percent', '𝜟 Format', options = [ 'Percent', 'Absolute'], group = '♦︎ labels', inline = 'st')
txtsz = input.string("Small", title="Text Size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group = "♦︎ labels", inline = 'st')
bool cyclelab = input.bool(false, "Display Cycle", "Add Highs/Lows Cycle to the labels", group = "♦︎ labels")
showtable = input.bool(true, 'Show Stats table', group = '♦︎ statistics table')
locationtable = input.string('Top Right', 'Location', ['Top Right','Top Left', 'Bottom Right', 'Bottom Left'], group = '♦︎ statistics table', inline = 'tbpr')
sizetable = input.string('Normal', 'Size', ['Large', 'Normal', 'Small', 'Tiny'], group = '♦︎ statistics table', inline = 'tbpr')
avgln = input.int(10, "Averaging", minval=2, step=1, tooltip="Number of past occurrences to average", group = '♦︎ statistics table')
ts = txtsz == "Tiny" ? size.tiny :txtsz == "Small" ? size.small :txtsz == "Normal" ? size.normal:txtsz == "Large" ? size.large : size.huge
// Variables {
// LAST SWING TYPE
var string lastSwingType = ""
// SWING HIGHS
var float[] swingHighValues = array.new_float(0)
var int[] swingHighBarIndexes = array.new_int(0)
var label[] swingHighLabels = array.new_label(0)
// SWING LOWS
var float[] swingLowValues = array.new_float(0)
var int[] swingLowBarIndexes = array.new_int(0)
var label[] swingLowLabels = array.new_label(0)
// LINES
var line[] highToHighLines = array.new_line(0)
var line[] lowToLowLines = array.new_line(0)
var line[] bullishLines = array.new_line(0)
var line[] bearishLines = array.new_line(0)
// STS
var float[] highToHighPriceDiffs = array.new_float(0)
var int[] highToHighTimeDiffs = array.new_int(0)
var float[] lowToLowPriceDiffs = array.new_float(0)
var int[] lowToLowTimeDiffs = array.new_int(0)
var float[] bullishPriceDiffs = array.new_float(0)
var float[] bullishPrcDiffs = array.new_float(0)
var int[] bullishTimeDiffs = array.new_int(0)
var float[] bearishPriceDiffs = array.new_float(0)
var float[] bearishPrcDiffs = array.new_float(0)
var int[] bearishTimeDiffs = array.new_int(0)
//}
pH = high == ta.highest(high, period) ? high : na
pL = low == ta.lowest(low, period) ? low : na
// Adds a new swing high point, calculates differences (same-type and cross-type), creates a label, and draws connecting lines{
f_addHighSwingPoint(highValue, barIndex) =>
// Calculate opposite-type differences (with most recent low)
oppPriceDiff = (array.size(swingLowValues) > 0) ? highValue - array.get(swingLowValues, 0) : 0.0
oppPctDiff = (array.size(swingLowValues) > 0) ? oppPriceDiff / array.get(swingLowValues, 0) * 100 : 0.0
oppTimeDiff = (array.size(swingLowBarIndexes) > 0) ? barIndex - array.get(swingLowBarIndexes, 0) : 0
// Calculate same-type differences (with previous high)
samePriceDiff = (array.size(swingHighValues) > 0) ? highValue - array.get(swingHighValues, 0) : 0.0
sameTimeDiff = (array.size(swingHighBarIndexes) > 0) ? barIndex - array.get(swingHighBarIndexes, 0) : 0
patternH = ""
if array.size(swingHighValues) > 0
patternH := (highValue > array.get(swingHighValues, 0)) ? "ʜʜ" : "ʟʜ"
labelText = ""
if array.size(swingLowValues) > 0
textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##")
labelText := str.tostring(patternH) + "₩n+" + textx + "₩n⏱" + str.tostring(oppTimeDiff) //"L↑H " + str.tostring(oppPriceDiff, "#.##")
if array.size(swingHighValues) > 0 and cyclelab
labelText := labelText + "₩nʜɪɢʜ ᴄʏᴄʟᴇ₩n" + "⏱" + str.tostring(sameTimeDiff) //+ str.tostring(samePriceDiff, "#.##")
// Create label at swing high point
newLabel = label.new(barIndex, highValue, labelText, textcolor = #6ba583,
style=label.style_label_down, color=color.new(#000000, 100), size=ts, text_formatting = text.format_bold)
// Store swing high data
array.unshift(swingHighValues, highValue)
array.unshift(swingHighBarIndexes, barIndex)
array.unshift(swingHighLabels, newLabel)
// Draw lin connection betwn cons swing highs
// if previous high exists
if array.size(swingHighValues) > 1
prevBar = array.get(swingHighBarIndexes, 1)
prevValue = array.get(swingHighValues, 1)
newLine = rangeLines?line.new(prevBar, prevValue, barIndex, highValue, color=rnglineColor, width=1, style = line.style_solid):na
array.unshift(highToHighLines, newLine)
// Calculate and store differences for this high-to-high line
priceDiff = highValue - prevValue
timeDiff = barIndex - prevBar
array.unshift(highToHighPriceDiffs, priceDiff)
array.unshift(highToHighTimeDiffs, timeDiff)
// Draw bullish line if the last swing was
// (from a low to this high)
if array.size(swingLowValues) > 0 and lastSwingType != "high"
prevLowBar = array.get(swingLowBarIndexes, 0)
prevLowValue = array.get(swingLowValues, 0)
newBullishLine = line.new(prevLowBar, prevLowValue, barIndex, highValue, color=lineUpColor, width=lw, style = line.style_solid)
array.unshift(bullishLines, newBullishLine)
bullishPdiff = highValue - prevLowValue
bullishTdiff = barIndex - prevLowBar
array.unshift(bullishPriceDiffs, bullishPdiff)
array.unshift(bullishPrcDiffs, oppPctDiff)
array.unshift(bullishTimeDiffs, bullishTdiff)
//}
// 업데이트 the current swing high point
// if a new candidate is more extreme, recalculates differences,
// 업데이트 the label text, and 업데이트 connecting lines{
f_업데이트HighSwingPoint(highValue, barIndex) =>
if highValue > array.get(swingHighValues, 0)
array.set(swingHighValues, 0, highValue)
array.set(swingHighBarIndexes, 0, barIndex)
oppPriceDiff = (array.size(swingLowValues) > 0) ? highValue - array.get(swingLowValues, 0) : 0.0
oppPctDiff = (array.size(swingLowValues) > 0) ? oppPriceDiff / array.get(swingLowValues, 0) * 100 : 0.0
oppTimeDiff = (array.size(swingLowBarIndexes) > 0) ? barIndex - array.get(swingLowBarIndexes, 0) : 0
samePriceDiff = (array.size(swingHighValues) > 1) ? highValue - array.get(swingHighValues, 1) : 0.0
sameTimeDiff = (array.size(swingHighBarIndexes) > 1) ? barIndex - array.get(swingHighBarIndexes, 1) : 0
labelText = ""
patternH = ""
if array.size(swingHighValues) > 1
patternH := (highValue > array.get(swingHighValues, 1)) ? "ʜʜ" : "ʟʜ"
if array.size(swingLowValues) > 0
textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##")
labelText := str.tostring(patternH) + "₩n+"+ textx + "₩n⏱" + str.tostring(oppTimeDiff) //+ str.tostring(oppPriceDiff, "#.##")
if array.size(swingHighValues) > 1 and cyclelab
labelText := labelText + "₩nʜɪɢʜ ᴄʏᴄʟᴇ₩n" + "⏱" + str.tostring(sameTimeDiff) //str.tostring(samePriceDiff, "#.##") +
// 업데이트 label for current swing high
lbl = array.get(swingHighLabels, 0)
label.set_xy(lbl, barIndex, highValue)
label.set_text(lbl, labelText)
// 업데이트 high-to-high connection if it exists
if array.size(swingHighValues) > 1 and array.size(highToHighLines) > 0
prevBar = array.get(swingHighBarIndexes, 1)
prevValue = array.get(swingHighValues, 1)
line.set_xy1(array.get(highToHighLines, 0), array.get(swingHighBarIndexes, 1), array.get(swingHighValues, 1))
line.set_xy2(array.get(highToHighLines, 0), barIndex, highValue)
// Upd stored diffs for high-to-high connection
array.set(highToHighPriceDiffs, 0, highValue - prevValue)
array.set(highToHighTimeDiffs, 0, barIndex - prevBar)
// Upd bullish connection
if array.size(swingLowValues) > 0 and array.size(bullishLines) > 0
prevLowBar = array.get(swingLowBarIndexes, 0)
prevLowValue = array.get(swingLowValues, 0)
line.set_xy1(array.get(bullishLines, 0), prevLowBar, prevLowValue)
line.set_xy2(array.get(bullishLines, 0), barIndex, highValue)
array.set(bullishPriceDiffs, 0, highValue - prevLowValue)
array.set(bullishPrcDiffs, 0, (highValue - prevLowValue)/prevLowValue * 100)
array.set(bullishTimeDiffs, 0, barIndex - prevLowBar)
0.
//}
// Adds a new swing low point, calculates differences (same-type and cross-type),creates a label, and draws connecting lines{
f_addLowSwingPoint(lowValue, barIndex) =>
// Calculate opposite-type differences (with most recent high)
oppPriceDiff = (array.size(swingHighValues) > 0) ? lowValue - array.get(swingHighValues, 0) : 0.0
oppPctDiff = (array.size(swingHighValues) > 0) ? oppPriceDiff / array.get(swingHighValues, 0) * 100 : 0.0
oppTimeDiff = (array.size(swingHighBarIndexes) > 0) ? barIndex - array.get(swingHighBarIndexes, 0) : 0
// Calculate same-type differences (with previous low)
samePriceDiff = (array.size(swingLowValues) > 0) ? lowValue - array.get(swingLowValues, 0) : 0.0
sameTimeDiff = (array.size(swingLowBarIndexes) > 0) ? barIndex - array.get(swingLowBarIndexes, 0) : 0
labelText = ""
patternL = ""
if array.size(swingLowValues) > 0
patternL := (lowValue < array.get(swingLowValues, 0)) ? "ʟʟ" : "ʜʟ"
if array.size(swingHighValues) > 0
textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##")
labelText := str.tostring(patternL) + "₩n" + textx + "₩n⏱" + str.tostring(oppTimeDiff) //"H↓L "+ str.tostring(oppPriceDiff, "#.##")
if array.size(swingLowValues) > 0 and cyclelab
labelText := labelText + "₩nʟᴏᴡ ᴄʏᴄʟᴇ₩n" + "⏱" + str.tostring(sameTimeDiff) //+ str.tostring(samePriceDiff, "#.##")
// Create label at swing low point
newLabel = label.new(barIndex, lowValue, labelText, textcolor = #d75442,
style=label.style_label_up, color=color.new(#000000, 100), size=ts, text_formatting = text.format_bold)
// Store swing low data
array.unshift(swingLowValues, lowValue)
array.unshift(swingLowBarIndexes, barIndex)
array.unshift(swingLowLabels, newLabel)
// connection line betwn consecutive swing lows
if array.size(swingLowValues) > 1
prevBar = array.get(swingLowBarIndexes, 1)
prevValue = array.get(swingLowValues, 1)
newLine = rangeLines?line.new(prevBar, prevValue, barIndex, lowValue, color=rnglineColor, width=1, style = line.style_solid):na
array.unshift(lowToLowLines, newLine)
// Calculate and store differences for this low-to-low line
priceDiff = lowValue - prevValue
timeDiff = barIndex - prevBar
array.unshift(lowToLowPriceDiffs, priceDiff)
array.unshift(lowToLowTimeDiffs, timeDiff)
// Draw bearish line if the last swing was of the opposite type (from a high to this low)
if array.size(swingHighValues) > 0 and lastSwingType != "low"
prevHighBar = array.get(swingHighBarIndexes, 0)
prevHighValue = array.get(swingHighValues, 0)
newBearishLine = line.new(prevHighBar, prevHighValue, barIndex, lowValue, color=lineDnColor, width=lw, style = line.style_solid)
array.unshift(bearishLines, newBearishLine)
bearishPdiff = lowValue - prevHighValue
bearishTdiff = barIndex - prevHighBar
array.unshift(bearishPriceDiffs, bearishPdiff)
array.unshift(bearishPrcDiffs, oppPctDiff)
array.unshift(bearishTimeDiffs, bearishTdiff)
//}
// 업데이트 the current swing low point if a new is more extreme, recalculates differences, 업데이트 the lab text, and connecting lines{
f_업데이트LowSwingPoint(lowValue, barIndex) =>
if lowValue < array.get(swingLowValues, 0)
array.set(swingLowValues, 0, lowValue)
array.set(swingLowBarIndexes, 0, barIndex)
oppPriceDiff = (array.size(swingHighValues) > 0) ? lowValue - array.get(swingHighValues, 0) : 0.0
oppPctDiff = (array.size(swingHighValues) > 0) ? oppPriceDiff / array.get(swingHighValues, 0) * 100 : 0.0
oppTimeDiff = (array.size(swingHighBarIndexes) > 0) ? barIndex - array.get(swingHighBarIndexes, 0) : 0
samePriceDiff = (array.size(swingLowValues) > 1) ? lowValue - array.get(swingLowValues, 1) : 0.0
sameTimeDiff = (array.size(swingLowBarIndexes) > 1) ? barIndex - array.get(swingLowBarIndexes, 1) : 0
labelText = ""
patternL = ""
if array.size(swingLowValues) > 1
patternL := (lowValue < array.get(swingLowValues, 1)) ? "ʟʟ" : "ʜʟ"
if array.size(swingHighValues) > 0
textx = delta=="Percent"?(str.tostring(oppPctDiff, format.percent)):str.tostring(oppPriceDiff, "#.##")
labelText := str.tostring(patternL)+ "₩n"+ textx + "₩n⏱" + str.tostring(oppTimeDiff) //"L↑H "+ str.tostring(oppPriceDiff, "#.##")
if array.size(swingLowValues) > 1 and cyclelab
labelText := labelText + "₩nʟᴏᴡ ᴄʏᴄʟᴇ₩n" + "⏱" + str.tostring(sameTimeDiff) //+ str.tostring(samePriceDiff, "#.##")
// 업데이트 label for current swing low
lbl = array.get(swingLowLabels, 0)
label.set_xy(lbl, barIndex, lowValue)
label.set_text(lbl, labelText)
// 업데이트 low-to-low connection if it exists
if array.size(swingLowValues) > 1 and array.size(lowToLowLines) > 0
prevBar = array.get(swingLowBarIndexes, 1)
prevValue = array.get(swingLowValues, 1)
line.set_xy1(array.get(lowToLowLines, 0), prevBar, prevValue)
line.set_xy2(array.get(lowToLowLines, 0), barIndex, lowValue)
array.set(lowToLowPriceDiffs, 0, lowValue - prevValue)
array.set(lowToLowTimeDiffs, 0, barIndex - prevBar)
// 업데이트 bearish connection if exists
if array.size(swingHighValues) > 0 and array.size(bearishLines) > 0
prevHighBar = array.get(swingHighBarIndexes, 0)
prevHighValue = array.get(swingHighValues, 0)
line.set_xy1(array.get(bearishLines, 0), prevHighBar, prevHighValue)
line.set_xy2(array.get(bearishLines, 0), barIndex, lowValue)
array.set(bearishPriceDiffs, 0, lowValue - prevHighValue)
array.set(bearishPrcDiffs, 0, (lowValue - prevHighValue)/prevHighValue * 100)
array.set(bearishTimeDiffs, 0, barIndex - prevHighBar)
0.
//}
if array.size(highToHighLines) > 0 and array.size(lowToLowLines) > 0
linefill.new(array.get(highToHighLines, 0), array.get(lowToLowLines, 0), color.rgb(0, 0, 0, 95))
// Process pivs {
var int direction = 0
direction := (not na(pH) and na(pL)) ? 1 : (not na(pL) and na(pH)) ? -1 : direction
bool directionChanged = direction != nz(direction[1])
bool bullish = direction == 1
bool bearish = direction == -1
bool bull = direction[1]==-1 and direction==1
bool bear = direction[1]==1 and direction==-1
if direction==1
if lastSwingType != "high"
f_addHighSwingPoint(pH, bar_index)
lastSwingType := "high"
else
f_업데이트HighSwingPoint(pH, bar_index)
if direction==-1
if lastSwingType != "low"
f_addLowSwingPoint(pL, bar_index)
lastSwingType := "low"
else
f_업데이트LowSwingPoint(pL, bar_index)
//}
// Function for geometric averaging {
f_geometric_avg(_source, _condition, _length) =>
var float geom_avg = na
var float[] valuesArray = array.new_float()
if _condition
if _source > 0
array.push(valuesArray, _source)
while array.size(valuesArray) > _length
array.shift(valuesArray)
n = array.size(valuesArray)
if n > 0
logSum = 0.0
for val in valuesArray
logSum += math.log(val)
geom_avg := math.exp(logSum / n)
else
geom_avg := na
geom_avg
var float sourcebull = na
var float sourcebear = na
var int sourcebullt = na
var int sourcebeart = na
if array.size(bullishPriceDiffs)>0 and array.size(bullishPrcDiffs)>0
sourcebull := delta=="Percent"?array.get(bullishPrcDiffs, 0) : array.get(bullishPriceDiffs, 0)
sourcebullt:=array.get(bullishTimeDiffs, 0)
conditionbull = lastSwingType=="low" and lastSwingType[1]== "high"
rma_valuebull = f_geometric_avg(sourcebull, conditionbull, avgln)
rma_valuebullt = f_geometric_avg(sourcebullt, conditionbull, avgln)
if array.size(bearishPriceDiffs)>0 and array.size(bearishPrcDiffs)>0
sourcebear := delta=="Percent"?array.get(bearishPrcDiffs, 0) : array.get(bearishPriceDiffs, 0)
sourcebeart:=array.get(bearishTimeDiffs, 0)
conditionbear = lastSwingType=="high" and lastSwingType[1] == "low"
rma_valuebear = f_geometric_avg(math.abs(sourcebear), conditionbear, avgln)
rma_timebear = f_geometric_avg(sourcebeart, conditionbear, avgln)
//}
//Table{
var table_loc = locationtable == 'Top Right' ? position.top_right : locationtable == 'Bottom Right' ? position.bottom_right : locationtable == 'Top Center' ? position.top_center : locationtable == 'Top Left' ? position.top_left : position.bottom_left
var table_size = sizetable == 'Large' ? size.large : sizetable == 'Normal' ? size.normal : sizetable == 'Small' ? size.small : size.tiny
var table = showtable ? table.new(table_loc, 16, 16, #2a2e39, #1e1e1e, 2, #1f232f, 2) : na
table_cell(column, row, txt, signal = false) =>
table.cell(table, column, row, txt, 0, 0, signal ? #ffffff : #ffffff, text_size = table_size)
table_cell_bg(column, row, col) =>
table.cell_set_bgcolor(table, column, row, col)
if barstate.islast and showtable
table_cell(0, 0, "STATISTICS TABLE")
table_cell(0, 1, "ɢᴇᴏᴍᴇᴛʀɪᴄ₩nᴀᴠᴇʀᴀɢɪɴɢ")
table_cell(1, 1, "𝞓 ᴘʀɪᴄᴇ")
table_cell(2, 1, "𝞓 ᴛɪᴍᴇ")
table_cell(0, 2, 'ᴜᴘᴛʀᴇɴᴅ')
table_cell(0, 3, 'ᴅᴏᴡɴᴛʀᴇɴᴅ')
table_cell(1, 2, "+"+str.tostring(rma_valuebull, delta=="Percent"?format.percent:format.mintick))
table_cell(1, 3, "-"+str.tostring(rma_valuebear, delta=="Percent"?format.percent:format.mintick))
table_cell(2, 2, str.tostring(rma_valuebullt, format.mintick))
table_cell(2, 3, str.tostring(rma_timebear, format.mintick))
table.cell_set_text_font_family(table, 0,0, font.family_monospace)
table.cell_set_text_formatting(table, 1, 1, text.format_bold)
table.cell_set_text_formatting(table, 2, 1, text.format_bold)
table.cell_set_text_formatting(table, 0, 2, text.format_bold)
table.cell_set_text_formatting(table, 0, 3, text.format_bold)
table.cell_set_text_color(table, 0, 1, color.gray)
table.cell_set_text_size(table, 0, 1, size.small)
table.merge_cells(table, 0,0,2,0)
//}
2025-05-21
301
글번호 191027
지표
답변완료
부탁드립니다 항상 감사합니다
Input:
rsiLen(14), rsiCut(50),
macdFastLen(12), macdSlowLen(26), macdSignalLen(9),
tp1Ratio(0.995), tp2Ratio(0.990), tp3Ratio(0.985), slRatio(1.01),
volumeMultiplier(2.0), 평균거래량기간(20),
시작시간(93000), 종료시간(150000);
Var:
rsiVal(0), macdFastEMA(0), macdSlowEMA(0),
macdMain(0), macdSignal(0), macdHist(0),
진입가(0), TP1(0), TP2(0), TP3(0), SL(0),
거래량기준(0), 텍스트ID(0),
TL1(0), TL2(0), TL3(0), TL4(0), 손익라벨(0),
매도조건(false), 청산1(false), 청산2(false), 청산3(false);
// 1. RSI + MACD 계산
rsiVal = RSI(rsiLen);
If CurrentBar = 1 Then
Begin
macdFastEMA = Close;
macdSlowEMA = Close;
End
Else
Begin
macdFastEMA = (Close * (2 / (macdFastLen + 1))) + macdFastEMA[1] * (1 - (2 / (macdFastLen + 1)));
macdSlowEMA = (Close * (2 / (macdSlowLen + 1))) + macdSlowEMA[1] * (1 - (2 / (macdSlowLen + 1)));
macdMain = macdFastEMA - macdSlowEMA;
macdSignal = (macdMain * (2 / (macdSignalLen + 1))) + macdSignal[1] * (1 - (2 / (macdSignalLen + 1)));
macdHist = macdMain - macdSignal;
End;
// 2. 거래량 조건
거래량기준 = Average(Volume, 평균거래량기간);
// 3. 조건 진입
If sTime >= 시작시간 and sTime <= 종료시간 and 매도조건 = false Then
Begin
If rsiVal < rsiCut and macdHist < 0 and macdHist[1] > 0 and Volume > 거래량기준 * volumeMultiplier Then
Begin
진입가 = Close;
TP1 = 진입가 * tp1Ratio;
TP2 = 진입가 * tp2Ratio;
TP3 = 진입가 * tp3Ratio;
SL = 진입가 * slRatio;
// 자동 매도 포지션 진입
SellShort("ShortEntry") Next Bar at Market;
// 손익비 박스
TL_Delete(TL1); TL_Delete(TL2); TL_Delete(TL3); TL_Delete(TL4); Text_Delete(손익라벨);
TL1 = TL_New(Date, Time, SL, Date + 1, Time, SL);
TL2 = TL_New(Date, Time, TP3, Date + 1, Time, TP3);
TL3 = TL_New(Date, Time, SL, Date, Time, TP3);
TL4 = TL_New(Date + 1, Time, SL, Date + 1, Time, TP3);
TL_SetColor(TL1, RGB(255,200,200)); TL_SetColor(TL2, RGB(255,200,200));
TL_SetColor(TL3, RGB(255,200,200)); TL_SetColor(TL4, RGB(255,200,200));
TL_SetSize(TL1, 1); TL_SetSize(TL2, 1); TL_SetSize(TL3, 1); TL_SetSize(TL4, 1);
// 손익비 계산 및 라벨 표시
손익라벨 = Text_New(Date, Time, (SL + TP3)/2, "손익비 " + NumToStr((진입가 - TP3) / (SL - 진입가), 1) + ":1");
Text_SetStyle(손익라벨, 1, 0);
Text_SetColor(손익라벨, RGB(200, 0, 0));
매도조건 = true;
청산1 = false; 청산2 = false; 청산3 = false;
End;
End;
// 4. 청산 조건 (비율 분할 청산 시뮬레이션)
If 매도조건 Then
Begin
// TP1 도달 시
If 청산1 = false and Close <= TP1 Then
Begin
Alert("TP1 도달: 30% 청산");
청산1 = true;
End;
// TP2 도달 시
If 청산2 = false and Close <= TP2 Then
Begin
Alert("TP2 도달: 50% 청산");
청산2 = true;
End;
// TP3 도달 시
If 청산3 = false and Close <= TP3 Then
Begin
Alert("TP3 도달: 나머지 전량 청산");
청산3 = true;
매도조건 = false;
End;
// SL 도달 시 전체 손절
If Close >= SL Then
Begin
Alert("손절가 도달: 전량 청산");
청산1 = true; 청산2 = true; 청산3 = true;
매도조건 = false;
End;
End;
검증시 오류가나서 구현할수있게 부탁드립니다 감사합니다
2025-05-21
229
글번호 191026
지표