Need code help

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
brodnicki steven
Posts:407
Joined:01 Jan 2008
Been thanked: 3 times
Need code help

Postby brodnicki steven » 17 Nov 2009

I'm trying to find some code to prevent 2 plots at the same time when using an oscillator and updating tick by tick. - I should be getting only one plot at a given time increment but sometimes I get 2 . See attached .
Any suggestions ? (I'm not a programmer, so simple solutions or code, if possible)
Attachments
Plot-2 points at once error.jpg
(14.86KiB)Downloaded 1255 times

User avatar
TJ
Posts:7354
Joined:29 Aug 2006
Location:Global Citizen
Has thanked: 993 times
Been thanked: 2100 times

Postby TJ » 17 Nov 2009

can you post a snippet?

can't tell you much without more information

brodnicki steven
Posts:407
Joined:01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 17 Nov 2009

TJ:
The Osc is the output from a neural net that I'm experimenting with- but the principal should be the same as any other oscillator.

Code: Select all

{ Now firing the network }
FireNet_Err = TSFireNet();
if (PutInput_Err <> 0) then print("Neural network firing error is", FireNet_Err:4:0);

{ Extract the predicted value from the DLL }
Nextday_Close = TSGetOutput(1); {neural net output}


if nextday_close > .500 then plot1(NextDay_Close, "ND_Close up");
if nextday_close < .500 then plot2(NextDay_Close, "ND_Close dn");
if nextday_close = .500 then plot3(NextDay_Close, "ND_Close =");
plot4(.500,"xvr");
end;
***I think using the noplot command, I could clear out any extra plots but I'm not sure how to code it.

User avatar
TJ
Posts:7354
Joined:29 Aug 2006
Location:Global Citizen
Has thanked: 993 times
Been thanked: 2100 times

Postby TJ » 17 Nov 2009

you don't need 3 plots.
probably you are using it for assigning different colors.

you can try this:
var:
upcolor(cyan),
dncolor(red),
neucolor(green);

plot1(NextDay_Close, "ND_Close");

if nextday_close > .500 then setplotcolor(1, upcolor)
else
if nextday_close < .500 then setplotcolor(1, dncolor)
else
setplotcolor(1, neucolor);

plot4(.500,"xvr");
Last edited by TJ on 18 Nov 2009, edited 2 times in total.

User avatar
TJ
Posts:7354
Joined:29 Aug 2006
Location:Global Citizen
Has thanked: 993 times
Been thanked: 2100 times

Postby TJ » 17 Nov 2009

alternatively you can use the noplot:


if nextday_close > .500 then plot1(NextDay_Close, "ND_Close up") else noplot(1);
if nextday_close < .500 then plot2(NextDay_Close, "ND_Close dn") else noplot(2);
if nextday_close = .500 then plot3(NextDay_Close, "ND_Close =") else noplot(3);

brodnicki steven
Posts:407
Joined:01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 17 Nov 2009

TJ: you're reading my mind, I tried that too, the picture that I posted was after trying that. (I forgot to mention it.)

It needs to know to only plot one at a time, in sequence. If I hit "status off" then "status on" it refreshes and erases the bad dot and looks correct for a little while.
If there was a way to detect the 2nd dot and if it was detected, to order a refresh, that might work. I just don't know how to code something like that.

User avatar
TJ
Posts:7354
Joined:29 Aug 2006
Location:Global Citizen
Has thanked: 993 times
Been thanked: 2100 times

Postby TJ » 17 Nov 2009

... can't tell you more,
unless you post more charts, with notes,
illustrating different scenario...
and different coding logics.
and in each chart scenario... point out why it was "wrong",
and how it should be "right".

brodnicki steven
Posts:407
Joined:01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 17 Nov 2009

Thanks TJ, I understand. I can't do anything else, until I have fast rt quotes coming in(day session). I may set up a print log tomorrow and track the values and try to figure it out that way.
Another thing I might try is to say (if osc > .5 AND osc < .5 then noplot). That way it shouldn't allow 2 at the same time I hope.

User avatar
TJ
Posts:7354
Joined:29 Aug 2006
Location:Global Citizen
Has thanked: 993 times
Been thanked: 2100 times

Postby TJ » 17 Nov 2009

TJ: you're reading my mind, I tried that too, the picture that I posted was after trying that. (I forgot to mention it.) ...
not sure which code you tried?
The first code? (with setplotcolor)
or the second code? (with noplot)

Thanks TJ, I understand. I can't do anything else, until I have fast rt quotes coming in(day session). I may set up a print log tomorrow and track the values and try to figure it out that way.
Another thing I might try is to say (if osc > .5 AND osc < .5 then noplot). That way it shouldn't allow 2 at the same time I hope.

the first code I posted (post#4) with the setplotcolor,
all you needed is only ONE plot.
Therefore there should not be another plot to give you false readings.

brodnicki steven
Posts:407
Joined:01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 17 Nov 2009

Thanks TJ, I tried the second one with noplot, I'll try the setplotcolor one tomorrow- great idea ! That's a nice clean fix.
Steve

brodnicki steven
Posts:407
Joined:01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 18 Nov 2009

TJ: just a quick update- I ran it all day today on 4 charts and never had 2 plots at the same time- Your fix worked !!!
Thanks, Steve

User avatar
TJ
Posts:7354
Joined:29 Aug 2006
Location:Global Citizen
Has thanked: 993 times
Been thanked: 2100 times

Postby TJ » 18 Nov 2009

You are welcome...

brodnicki steven
Posts:407
Joined:01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 19 Nov 2009

It's funny, I was aware of the "setplotcolor" function, I just didn't know that it could be applied multiple times, to a single plot.

User avatar
TJ
Posts:7354
Joined:29 Aug 2006
Location:Global Citizen
Has thanked: 993 times
Been thanked: 2100 times

Postby TJ » 19 Nov 2009

I also learn something new everyday...

;-)


Return to “User Contributed Studies and Indicator Library”