Integrating Screen Scaled and Price Scaled Inputs

Have a QScript to share, or need help with programming? Post your comment here.
Post Reply
DC1
Posts: 25
Joined: Tue Aug 11, 2015 6:39 pm
Contact:

Integrating Screen Scaled and Price Scaled Inputs

Post by DC1 » Thu Jul 27, 2017 6:20 pm

Perhaps someone here can help me with attempts to do some qscript work

Is it possible to put together a Qscript indicator which uses
both screen scaled and price scaled inputs

Something like a price channel and a fractal or any other for that matter

Second I use this to plot the 50% line between 1 ..2...3 days ago

YTp50=RoundESPrice(yh-((yh-tlow)*.50));
if(YTp50<YTp50[1]) {text(barnumber+12,YTp50 ,YTp50 ,16750848,tx_center,14); text(barnumber-5,YTp50 ,"YTp50 ",16750848,tx_center,14);}

however although the instructions are there to

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Integrating Screen Scaled and Price Scaled Inputs

Post by earik » Thu Jul 27, 2017 6:55 pm

Hi DC,

Not sure if your whole message came through or not, but you can't mix and match screen and price scales together. It's one or the other. If you need to plot both types, you have to break the code into two scripts, one that handles the screen scaling plots, and the other that handles the price scaling plots. I've actually thought about allowing different scales for different plots, which would allow this, but it hasn't made it to a production version yet...

Earik

DC1
Posts: 25
Joined: Tue Aug 11, 2015 6:39 pm
Contact:

Re: Integrating Screen Scaled and Price Scaled Inputs

Post by DC1 » Thu Jul 27, 2017 8:10 pm

Yes my mouse was busy doing some thing i was unaware of sending

I use this to plot the 50% line between 1 day ago and today

YTp50=RoundESPrice(yh-((yh-tlow)*.50));


I use this script to put text in which gives the value of YTp50 as it heads lower for the day

if(YTp50<YTp50[1]) {text(barnumber+12,YTp50 ,YTp50 ,16750848,tx_center,14); text(barnumber-5,YTp50 ,"YTp50 ",16750848,tx_center,14);}

Now I would like to take out the old value of the text position as it goes lower during the day to avoid all the clutter it makes

however I am unable to make it work "although the instructions are there to delete or reset


I tried the same thing using a line for the set-up and trying to delete the line

ref=trendline(barnumber,ytp50,barnumber+ bars_per_day,ytp50,16750848); set_tl_size(ref,1);
text(barnumber+2,Ytp50,Ytp50,16750848,tx_center,14); text(barnumber+42,Ytp50,"Ytp50",16750848,tx_center,14);

Don

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Integrating Screen Scaled and Price Scaled Inputs

Post by earik » Mon Jul 31, 2017 7:37 pm

Hi Don,

You have to save the reference to the text object, and then you use that to delete it. You are saving the reference for your trendline, but not for the text tool. So you had:
if(YTp50<YTp50[1]) {
text(barnumber+12,YTp50 ,YTp50 ,16750848,tx_center,14);
text(barnumber-5,YTp50 ,"YTp50 ",16750848,tx_center,14);
}
...but what you actually need is:

Code: Select all

if(YTp50<YTp50[1]) { 
   tx_ref1 = text(barnumber+12,YTp50 ,YTp50 ,16750848,tx_center,14); 
   tx_ref2 = text(barnumber-5,YTp50 ,"YTp50 ",16750848,tx_center,14);
}
The difference is that I'm saving the references in tx_ref1 and tx_ref2. Now if you want to delete those two text objects, you go:

Code: Select all

text_delete(tx_ref1);
text_delete(tx_ref2);
At this point, you can re-plot them if you want with new values. You can also call text_reset( ), if you just want to change their position or what they say, which would also work.

Earik

DC1
Posts: 25
Joined: Tue Aug 11, 2015 6:39 pm
Contact:

Re: Integrating Screen Scaled and Price Scaled Inputs

Post by DC1 » Tue Aug 01, 2017 4:04 pm

Well thank you for the information
First I would like to thank you for your efforts to help people to make things work.

You know first hand the size of the programs I have created to do various things! (most of which have been reduced to a computer manageable number of lines after your input)

But I guess because I don't really understand the underlying structure of this programming (fortran 4 and 5 was a long time ago)

Still get nothing but error messages "ref1 is never assigned a value"

Here is the current from what I understand you just told me

if(YTp50>YTp50[1]) {
tx_ref1 = text(barnumber+12,YTp50,YTp50 ,16750848,tx_center,14); text_delete(tx_ref1); text_reset(ref1, barnumber+12, YTp50,YTp50,16750848,tx_center,14);
tx_ref2 = text(barnumber-5,YTp50 ,"YTp50",16750848,tx_center,14); text_delete(tx_ref2); text_reset(ref2, barnumber-5, YTp50,"YTp50",16750848,tx_center,14);
}


Next attempt same error


if(YTp50>YTp50[1]) {
tx_ref1 = YTp50; text(barnumber+12,YTp50,YTp50 ,16750848,tx_center,14); text_delete(tx_ref1); text_reset(ref1, barnumber+12, YTp50,YTp50,16750848,tx_center,14);
tx_ref2 = YTp50; text(barnumber-5,YTp50 ,"YTp50",16750848,tx_center,14); text_delete(tx_ref2); text_reset(ref2, barnumber-5, YTp50,"YTp50",16750848,tx_center,14);
}

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Integrating Screen Scaled and Price Scaled Inputs

Post by earik » Tue Aug 01, 2017 4:33 pm

Hi Don,

One difference from Fortran is that there are objects now. Just think of an object as a little self-contained blob that manages itself. So you call for text or a trendline, but then they worry about how to draw themselves, etc. You just say draw from point A to point B, and the object handles itself. Each trendline or text that you put on the chart it it's own object. Each object has a reference (think of it as the object's name), which you can then use to tell it to do things in the future, like change colors or delete itself, etc.

Anyway, you have this partially correct, but you're mixing things up a little. If you call text_delete(), the trendline gets thrown in the garbage. You can't call any more functions on it after that point. So if you call text_delete(), you can't call text_reset(), and have to just do a completely brand new trendline with text( ) again. The alternative to text_delete( ) is to call text_reset( ), which doesn't delete anything, just tells the trendline to draw itself differently.

So you can do either this: (using text_delete)

Code: Select all

if(YTp50>YTp50[1]) { 
tx_ref1 = text(barnumber+12,YTp50,YTp50 ,16750848,tx_center,14);
text_delete(tx_ref1); 
tx_ref1 = text(barnumber+12, YTp50,YTp50,16750848,tx_center,14);
 
tx_ref2 = text(barnumber-5,YTp50 ,"YTp50",16750848,tx_center,14); 
text_delete(tx_ref2); 
tx_ref2 = text(barnumber-5, YTp50,"YTp50",16750848,tx_center,14); 
} 
Or you can do this: (using text_reset)

Code: Select all

if(YTp50>YTp50[1]) { 
tx_ref1 = text(barnumber+12,YTp50,YTp50 ,16750848,tx_center,14); 
text_reset(tx_ref1 , barnumber+12, YTp50,YTp50,16750848,tx_center,14); 
tx_ref2 = text(barnumber-5,YTp50 ,"YTp50",16750848,tx_center,14); 
text_reset(tx_ref2 , barnumber-5, YTp50,"YTp50",16750848,tx_center,14); 
} 
Hope that helps,

Earik

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests