I'm trying to write a my first Qscript.
This should be easier then I making it out to be.
Tried to find a script I could alter, could not find.
I want multiple vertical trend lines
One at the beginning and one at the end on of two hot spots with equal divisions of vertical tend lines between the outside two.
inputs would be styles, # of divisions, color, thickness, etc.
This way I can alter the time by the hot spots, 30 min, 30 hours, or 30 years. this way time does not need to be put in Qscript to make it easier.
I really would like to do this myself but need some direction.
Mark
Qscript Vertical trendlines
Re: Qscript Vertical trendlines
Check out this sample code. Seems to work on a basic 10 minute chart. It should get you started. I did not add any arguments, or colors or styles, but that should be easy.
Also not sure about my syntax for the trendlines, as I rarely use them. But it looked good on my screen...
EDIT: I just re-read your request. I added the additional trendlines on the *outside* of the two initial hotspots. Looks like you wanted to perhaps subdivide instead? If you need help with that part, let me know and I can try another crack at it if the above sample code doesn't help you.
Also not sure about my syntax for the trendlines, as I rarely use them. But it looked good on my screen...
Code: Select all
# Grab the two hotspots
bar1 = hotspot_to_bar(1);
bar2 = hotspot_to_bar(2);
if (bar1 < bar2) {
leftbar = bar1;
rightbar = bar2;
} else {
leftbar = bar2;
rightbar = bar1;
}
# Calculate the difference
bardiff = abs(bar1-bar2);
# Draw the two hotspots on the chart
pad=(h-l)*0.5;
additionalTrendlines=3;
for (i=0 to additionalTrendlines by 1) {
tl1=trendline(leftbar-(bardiff*i), low-pad, leftbar-(bardiff*i), low-pad*2, silver);
tl_extend_left(tl1,true);
set_tl_style(tl1, ps_dot);
tl2=trendline(rightbar+(bardiff*i), low-pad, rightbar+(bardiff*i), low-pad*2, silver);
tl_extend_left(tl2,true);
set_tl_style(tl2, ps_dot);
}
Re: Qscript Vertical trendlines
Thank You
I will install and see how it works.
Mark
I will install and see how it works.
Mark
Re: Qscript Vertical trendlines
This does what you want. You can add extra subdivisions, etc. as variables.
Todd
Todd
Code: Select all
input: ratio1(0.5);
#get bar values and time difference
if (barnum==barsback)
{
bar1=hotspot_to_bar(1);
price1=hotspot_to_price(1);
bar2=hotspot_to_bar(2);
price2=hotspot_to_price(2);
#make sure bar1 happens before bar2
if (bar2 < bar1)
{
temp=bar1;
bar1=bar2;
bar2=temp;
temp=price1;
price1=price2;
price2=temp;
}
time_diff=bar2-bar1;
#draw vertical target at bar1
targetbar=bar1;
ref=trendline(targetbar,0,targetbar,999999,silver);
set_tl_style(ref,ps_dot);
#draw vertical target at bar2
targetbar=bar2;
ref=trendline(targetbar,0,targetbar,999999,silver);
set_tl_style(ref,ps_dot);
#draw vertical target at subdivision
targetbar=bar1+time_diff*ratio1;
ref=trendline(targetbar,0,targetbar,999999,fuchsia);
set_tl_style(ref,ps_dash);
}
# END
Re: Qscript Vertical trendlines
Thank You Todd works good.
Who is online
Users browsing this forum: No registered users and 89 guests