Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Can anyone provide guidance as how to encode a "hold" signal for "x" number of bars in ninjascript? What I am seeking would resemble the following which was obtained from another language:
SYNTAX hold( EXPRESSION, periods )
FUNCTION Holds a "true" result of EXPRESSION for the specified number of periods.
This true result is held true over the number of periods specified even if a "false" result is generated.
EXAMPLE hold( cross(rsi(14),70),5 )
Thank you in advance for any help you can provide.
With kind regards,
Fred
Can you help answer these questions from other members on NexusFi?
I would define a BoolSeries object, which will hold the value "true" or "false" for each bar. You can then use an integer index, set it to 5 periods, count it down to zero and set the value to "true" if the index still is greater than 0.
However, it is not clear what you actually try to achieve.
Thanks, Fat Tails. Much appreciated. What I am trying to do is:
1. Define an entry setup that I believe should be valid for "x" bars even if all conditions defining that setup don't hold true for all "x" bars. For example, a Long entry setup could be a very oversold situation, eg, RSI(2) < 3.
2. Use price movement beyond the extreme of the last bar in the desired trade direction to confirm and trigger a Long trade entry. For example, using the above oversold case: H[0] > H[1] could be the Long entry trigger.
I hope that makes sense.
I have some limited programming experience with Amibroker but none really with Ninjascript, so I am currently using the Strategy Wizard to cobble together a strategy. If you wouldn't mind, would you be so kind as to provide a simple example of the code you proposed. I'm very new at this and would regard it as an excellent learning opportunity.
The easiest think would be, if you just edit a sample strategy. You could for example edit the SampleMACrossOver and save it under a new name.
You can then change the conditions within this strategy. If you have coded indicators or strategies with AmiBroker that should not be much of a problem. For example, you can use the RSI instead of the SMA. Note that the RSI has two parameters, the period of the RSI and the smoothing period, so the syntax will be RSI(period,smooth), as opposed to the SMA(period).
Now let us assume that you have a setup signal
1st condition: RSI(2) < 30
and that you want to hold this signal for 5 bars, and that you have an entry condition
2nd condition High[0] > High[1]
This means that you would have to check, whether the second condition is true and whether the first condition was true for the current or one of the prior four bars
A simple solution:
Admittedly not very elegant, but should work nevertheless. Alternatively you could code
Dear Fat Tails,
With your kind assistance I was able to successfully deploy your second suggestion. Thank you very much for your generous efforts. FWIW, I've ordered a book on C# programming!