Hi,
I have been trying to create the simplest of a number of planned temporal (bar-to-bar) filters that operate on a sequence of price-related binary pulses with a ‘1’ or 'ON' duration of D bars where D >= 1. These pulses are separated by at least one bar of binary ‘0’ or 'OFF'. A filter of this type accepts a binary stream in and produces a binary stream out. By cascading these filters end to end, a final filtered waveform is produced and this is the required output of the code. In any one call attached to a bar (in a SHOWPLOT, for example), the filter must remember and use variables set up in the previous bar before they are later recomputed for the next bar. Changes in dynamics mean that I must be able to, on occasion, assert variables at more than one place in the sequence of the lines of code.
The bare minimum functionality is to be able to modulate measured input pulses to introduce delays-to-ON and delays-to-OFF. This has the effect of being able to filter out specific noisy pulses in the input stream. This is elementary digital filtration I could do easily in every other language I am familiar with. But no matter what I do I cannot implement the filter using Optuma script for 1 fundamental reason:
The scripting language insists that variable declaration and assertion must happen on the same line and the variable cannot be referenced until that line is executed.
Before discussions ensue, some notes:
- I have tried huge numbers of combinations of SWITCH or COUNTSINCESIGNAL or TIMESINCESIGNAL and IF().
- I am conversant with the pascal [n] backwards array referencing. It does not solve the problem.
- I have tried many different ways of using duplicate scripts early in the script. Bat-to-bar timing means it does not work because no matter what you do, in Bar N, you need to first examine a variable by name that was asserted at the end of the previous bar's (N-1) processing, and before the variable is reassigned later in (N) ... a reassignment that is dependent on the original reference early in bar N. Of particular note is the need to examine the state of a counter (COUNTSINCESIGNAL ) variable assigned at the end of the previous bar's processing.
- I can't use NOREPEAT() because there's no examples in the knowledge base of how to embed NOREPEAT() into the above functions at the moment of their call. Without knowing what NOREPEAT actually does it's function is mysterious.
Either
a) I have not found the right way to use the Optuma scripting language
Or
b) The basic scripting language is fundamentally ill-suited to this problem.
I am, as usual, starting with the premise I have missed something. I assume you can help me see how to do it. I am looking for ways ahead.
Q. How do you use NOREPEAT as per 4. above? (it probably doesn't matter ... it was only a guess it might be able to be coerced into doing what I want.)
Q. Have I missed something? Is there some function that does what I want?
Q. Does the Pascal programming environment relieve the programmer of the scripting limitation?
I look forward to your comments. I have placed below a basic test functionality which I claim is impossible to do in Optuma basic script.
Regards
Colin
Test functionality (I have tried many dozens of times to do this)
=====================
INPUT:
I work only in daily bars. Two price related binary pulse streams A and B (1 bar wide pulses) that never coincide. A is always followed by a B and a B is always followed by an A. (Think of a A = 'crossing up' and B = 'crossing down' to create it).
PROCESSING
Measure the gap (in bars) between A and B.
If the gap exceeds N bars, then wait for B and then inhibit any and all A that occur for M bars after B.
else do nothing (pass through the next B without doing anything).
OUTPUT
A) output stream is the same is the input EXCEPT the inhibited A pulses are missing
B) output stream is the same is the input B stream.
The problem? The 'inhibit' signal' that deletes the A pulses, is a product of the previous bar, must be examined early, before later being recomputed based on the previous processing.
========================