Page 1 of 1

Need code help

Posted: 17 Nov 2009
by brodnicki steven
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)

Posted: 17 Nov 2009
by TJ
can you post a snippet?

can't tell you much without more information

Posted: 17 Nov 2009
by brodnicki steven
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.

Posted: 17 Nov 2009
by TJ
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");

Posted: 17 Nov 2009
by TJ
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);

Posted: 17 Nov 2009
by brodnicki steven
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.

Posted: 17 Nov 2009
by TJ
... 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".

Posted: 17 Nov 2009
by brodnicki steven
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.

Posted: 17 Nov 2009
by TJ
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.

Posted: 17 Nov 2009
by brodnicki steven
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

Posted: 18 Nov 2009
by brodnicki steven
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

Posted: 18 Nov 2009
by TJ
You are welcome...

Posted: 19 Nov 2009
by brodnicki steven
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.

Posted: 19 Nov 2009
by TJ
I also learn something new everyday...

;-)