예스스탁
예스스탁 답변
2023-01-25 15:26:14
안녕하세요
예스스탁입니다.
//Inputs
input : source("Wicks");#'Wicks','Bodys']
input : leftLenH(25);
input : rightLenH(25);
input : leftLenL(25);
input : rightLenL(25);
input : boxLength(30);
input : bullBoxColor(Red);
input : bearBoxColor(Blue);
var : phOption(0),plOption(0);
var : leftBull(0),rightBull(0),topBull(0),bottomBull(0);
var : leftBear(0),rightBear(0),topBear(0),bottomBear(0);
var : ph(0),pl(0),tx(0),box(0);
phOption = iff(source == "Wicks" , high , close);
plOption = iff(source == "Wicks" , low , close);
if swinglow(1,plOption,leftLenL,rightLenL,leftLenL+rightLenL+1) != -1 Then
{
pl = plOption[rightLenL];
tx = text_new(sDate[rightLenL],sTime[rightLenL],pl,"▲");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,bearBoxColor);
topBull = iff(source == "Bodys" , max(close[leftLenL],open[leftLenL]),min(close[leftLenL],open[leftLenL]));
bottomBull = iff(source == "Bodys" , min(close[leftLenL],open[leftLenL]),Low[leftLenL]);
box = Box_New(sDate[rightLenH],sTime[rightLenH],topBull,sDate,sTime,bottomBull);
Box_SetColor(box,bearBoxColor);
Box_SetFill(box,true);
}
if SwingHigh(1,phOption,leftLenH,rightLenH,leftLenH+rightLenH+1) != -1 Then
{
ph = phOption[rightLenH];
tx = text_new(sDate[rightLenH],sTime[rightLenH],pH,"▼");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,bullBoxColor);
topBear = iff(source == "Bodys" , max(close[leftLenL],open[leftLenL]),high[leftLenL]);
bottomBear = iff(source == "Bodys" ,min(close[leftLenL],open[leftLenL]),max(close[leftLenL],open[leftLenL]));
box = Box_New(sDate[rightLenL],sTime[rightLenL],topBear,sDate,sTime,bottomBear);
Box_SetColor(box,bullBoxColor);
Box_SetFill(box,true);
}
즐거운 하루되세요
> 오이도인 님이 쓴 글입니다.
> 제목 : 수식 변환 문의
> 수고 하십니다.
아래 수식 변환 부탁드립니다.
수고하세요...
####################
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MensaTrader
//@version=5
indicator("Pivot Order Blocks", shorttitle="Pivot - OB", overlay=true, max_bars_back=500, max_boxes_count=250)
//Titles
inputGroupTitle = "=== Pivots ==="
plotGroupTitle = "=== Plots ==="
//Inputs
source = input.string("Wicks", options=['Wicks','Bodys'], title="Source", group=inputGroupTitle)
leftLenH = input.int(title="Pivot High", defval=25, minval=1, inline="Pivot High", group=inputGroupTitle)
rightLenH = input.int(title="/", defval=25, minval=1, inline="Pivot High", group=inputGroupTitle)
leftLenL = input.int(title="Pivot Low", defval=25, minval=1, inline="Pivot Low", group=inputGroupTitle)
rightLenL = input.int(title="/", defval=25, minval=1, inline="Pivot Low", group=inputGroupTitle)
boxLength = input.int(30, title="Box Size", tooltip="Amount of candles long", group=plotGroupTitle)
bullBoxColor = input.color(color.new(#00E600,90), title="Bullish Box Color", group=plotGroupTitle, inline="1")
bearBoxColor = input.color(color.new(#FF0000,90), title="Bearish Box Color", group=plotGroupTitle, inline="1")
//Wick / Body option
phOption = source == "Wicks" ? high : close
plOption = source == "Wicks" ? low : close
ph = ta.pivothigh(phOption,leftLenH, rightLenH)
pl = ta.pivotlow(plOption,leftLenL, rightLenL)
//Variables
var leftBull = bar_index
var rightBull = bar_index
var topBull = close
var bottomBull = close
var leftBear = bar_index
var rightBear = bar_index
var topBear = close
var bottomBear = close
//Bear Box Calc
if ph
leftBear := bar_index-leftLenH
rightBear := bar_index-(leftLenH-boxLength)
topBear := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? close[leftLenH] : open[leftLenH]) : high[leftLenL]
bottomBear := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? open[leftLenH] : close[leftLenH]) : close[leftLenL] > open[leftLenL] ? close[leftLenL] : open[leftLenL]
//Bull Box Calc
if pl
leftBull := bar_index-leftLenL
rightBull := bar_index-(leftLenL-boxLength)
topBull := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? close[leftLenL] : open[leftLenL]) : close[leftLenL] > open[leftLenL] ? open[leftLenL] : close[leftLenL]
bottomBull := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? open[leftLenL] : close[leftLenL]) : low[leftLenL]
plotshape(pl, offset=-25)
if pl
bull = box.new(left=leftBull, right=rightBull, top=topBull, bottom=bottomBull, bgcolor=color.new(bullBoxColor,80), border_color=bullBoxColor)
if ph
bear = box.new(left=leftBear, right=rightBear, top=topBear, bottom=bottomBear, bgcolor=color.new(bearBoxColor,80), border_color=bearBoxColor)