How can I anchor the first bar in a moving average to an intraday high or low?
up vote
0
down vote
favorite
I am trying to adapt a script published by Jayy on TradingView. The script anchors a moving average to an intraday bar if you specify the bar number as an input. What i would like to do is anchor the moving average to the high or low of an Intraday period, eg Highest(high,20). Part of Jayy's script is below. I would be grateful for any pointers or ideas.
startBar01=input(0,"1/ Starting Bar Number, for Midas VWAP",
integer,minval=-1)
up01=input(false, title="Show upper resistance only - top to trend down" )
mid01=input(true, title=" Show MIDAS line (midline)")
low01=input(false, title="Show lower support only - bottom to trend up" )
v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)
SupportCumPV01 = cum(low*v01)
ResistanceCumPV01 = cum(high*v01)
startV01 = valuewhen(startmidas01,cumV01,0)
StartPV01 = valuewhen(startmidas01,CumPV01,0)
SupportStartPV01 = valuewhen(startmidas01,SupportCumPV01,0)
ResistanceStartPV01 = valuewhen(startmidas01,ResistanceCumPV01,0)
Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)
SupportMidas01 = (SupportCumPV01-SupportStartPV01)/(cumV01-startV01)
ResistanceMidas01 = (ResistanceCumPV01-ResistanceStartPV01)/(cumV01-startV01)
middle01 = plot( mid01 and showmidas? Midas01:na, color=aqua,linewidth=3, title="Midas Resistance 1M")
lower01 = plot(low01 and showmidas? SupportMidas01:na, color=teal,linewidth=1, title="Midas Resistance 1S")
upper01 = plot(up01 and showmidas?ResistanceMidas01:na, color=RED,linewidth=1, title="Midas Resistance 1R")
fill(lower01,upper01,color=#1c86ee,transp=97)
moving-average tradingview-api pine-script
add a comment |
up vote
0
down vote
favorite
I am trying to adapt a script published by Jayy on TradingView. The script anchors a moving average to an intraday bar if you specify the bar number as an input. What i would like to do is anchor the moving average to the high or low of an Intraday period, eg Highest(high,20). Part of Jayy's script is below. I would be grateful for any pointers or ideas.
startBar01=input(0,"1/ Starting Bar Number, for Midas VWAP",
integer,minval=-1)
up01=input(false, title="Show upper resistance only - top to trend down" )
mid01=input(true, title=" Show MIDAS line (midline)")
low01=input(false, title="Show lower support only - bottom to trend up" )
v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)
SupportCumPV01 = cum(low*v01)
ResistanceCumPV01 = cum(high*v01)
startV01 = valuewhen(startmidas01,cumV01,0)
StartPV01 = valuewhen(startmidas01,CumPV01,0)
SupportStartPV01 = valuewhen(startmidas01,SupportCumPV01,0)
ResistanceStartPV01 = valuewhen(startmidas01,ResistanceCumPV01,0)
Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)
SupportMidas01 = (SupportCumPV01-SupportStartPV01)/(cumV01-startV01)
ResistanceMidas01 = (ResistanceCumPV01-ResistanceStartPV01)/(cumV01-startV01)
middle01 = plot( mid01 and showmidas? Midas01:na, color=aqua,linewidth=3, title="Midas Resistance 1M")
lower01 = plot(low01 and showmidas? SupportMidas01:na, color=teal,linewidth=1, title="Midas Resistance 1S")
upper01 = plot(up01 and showmidas?ResistanceMidas01:na, color=RED,linewidth=1, title="Midas Resistance 1R")
fill(lower01,upper01,color=#1c86ee,transp=97)
moving-average tradingview-api pine-script
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to adapt a script published by Jayy on TradingView. The script anchors a moving average to an intraday bar if you specify the bar number as an input. What i would like to do is anchor the moving average to the high or low of an Intraday period, eg Highest(high,20). Part of Jayy's script is below. I would be grateful for any pointers or ideas.
startBar01=input(0,"1/ Starting Bar Number, for Midas VWAP",
integer,minval=-1)
up01=input(false, title="Show upper resistance only - top to trend down" )
mid01=input(true, title=" Show MIDAS line (midline)")
low01=input(false, title="Show lower support only - bottom to trend up" )
v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)
SupportCumPV01 = cum(low*v01)
ResistanceCumPV01 = cum(high*v01)
startV01 = valuewhen(startmidas01,cumV01,0)
StartPV01 = valuewhen(startmidas01,CumPV01,0)
SupportStartPV01 = valuewhen(startmidas01,SupportCumPV01,0)
ResistanceStartPV01 = valuewhen(startmidas01,ResistanceCumPV01,0)
Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)
SupportMidas01 = (SupportCumPV01-SupportStartPV01)/(cumV01-startV01)
ResistanceMidas01 = (ResistanceCumPV01-ResistanceStartPV01)/(cumV01-startV01)
middle01 = plot( mid01 and showmidas? Midas01:na, color=aqua,linewidth=3, title="Midas Resistance 1M")
lower01 = plot(low01 and showmidas? SupportMidas01:na, color=teal,linewidth=1, title="Midas Resistance 1S")
upper01 = plot(up01 and showmidas?ResistanceMidas01:na, color=RED,linewidth=1, title="Midas Resistance 1R")
fill(lower01,upper01,color=#1c86ee,transp=97)
moving-average tradingview-api pine-script
I am trying to adapt a script published by Jayy on TradingView. The script anchors a moving average to an intraday bar if you specify the bar number as an input. What i would like to do is anchor the moving average to the high or low of an Intraday period, eg Highest(high,20). Part of Jayy's script is below. I would be grateful for any pointers or ideas.
startBar01=input(0,"1/ Starting Bar Number, for Midas VWAP",
integer,minval=-1)
up01=input(false, title="Show upper resistance only - top to trend down" )
mid01=input(true, title=" Show MIDAS line (midline)")
low01=input(false, title="Show lower support only - bottom to trend up" )
v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)
SupportCumPV01 = cum(low*v01)
ResistanceCumPV01 = cum(high*v01)
startV01 = valuewhen(startmidas01,cumV01,0)
StartPV01 = valuewhen(startmidas01,CumPV01,0)
SupportStartPV01 = valuewhen(startmidas01,SupportCumPV01,0)
ResistanceStartPV01 = valuewhen(startmidas01,ResistanceCumPV01,0)
Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)
SupportMidas01 = (SupportCumPV01-SupportStartPV01)/(cumV01-startV01)
ResistanceMidas01 = (ResistanceCumPV01-ResistanceStartPV01)/(cumV01-startV01)
middle01 = plot( mid01 and showmidas? Midas01:na, color=aqua,linewidth=3, title="Midas Resistance 1M")
lower01 = plot(low01 and showmidas? SupportMidas01:na, color=teal,linewidth=1, title="Midas Resistance 1S")
upper01 = plot(up01 and showmidas?ResistanceMidas01:na, color=RED,linewidth=1, title="Midas Resistance 1R")
fill(lower01,upper01,color=#1c86ee,transp=97)
moving-average tradingview-api pine-script
moving-average tradingview-api pine-script
asked Nov 12 at 5:19
Daryth
12
12
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256312%2fhow-can-i-anchor-the-first-bar-in-a-moving-average-to-an-intraday-high-or-low%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256312%2fhow-can-i-anchor-the-first-bar-in-a-moving-average-to-an-intraday-high-or-low%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown