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)
Hi
I am trying to write a Ninja Script code for a very simple strategy but it is taking me forever to figure it out and I think I need some help Basically the strategy is time dependant
1st part
When the time is between 9:30 – 10:30
If the low of the 1min candles is always above the 10 EMA, then condition 1 = True
Else if the high of the 1min candles is always below the 10 EMA, then codition 2 = Ture
2nd part
When the time is greater than 11:30
If condition 1 was true and now the low <= the 10 ema, then buy
If condition 2 was true and now the high >= the 10 ema, then sell
If have coded it in NT, but obviously I am doing something wrong,
Here is my code, any help would be greatly appreciated… I think I am off somewhere regarding my initial condions…
if (ToTime(Time[0]) > ToTime(9,30,00) && ToTime(Time[0]) < ToTime(10,30,00))
{
if (Low[60] > EMA(14)[0])
{
condition1 = true;
}
else if (High[60] < EMA(14)[0])
{
condition3 = true;
}
will it mater if condition 1 is a bool variable.. i thought I could just write "true" ,,,I thought the problem was that I didnt not get the coding right for the
if the low of the last 60 mins was above the 14 period EMA (as in the lows of the 1min candles never touched the EMA line in the past hour) - in ninja trader is written as
if (ToTime(Time[0]) > ToTime(9,30,00) && ToTime(Time[0]) < ToTime(10,30,00))
{
if (Low[60] > EMA(14)[0])
Low[60] is not the low of the last sixty minutes. Also, unless you've included something like
Then using Low[60] is going to throw an error anyway for an out of bounds index. You need to be reviewing the Log tab of the control center for errors, if this strategy has compiled successfully but is not working as expected.
If you are using a 1-minute bar, low[60] is the low of the bar 60 minutes ago.
You need to use MIN(Low, 60)[0] to find out what the low is over the last 60 bars.
Also, you need to either post the exact error message you are receiving upon compiling (bottom of the screen), or you need to post the .cs file itself. I (we) can not really help otherwise because we don't know what the error is.
I am not getting any errors in the log tab, but as you suggested I am getting errors in the execution of the strategy.
I am trying to write a script for:
If the low of all the 1-min candles > the moving average (the value of the MA corresponding to that time the low was made) then xxx = true
visually, it would look like a trending market. If the market was always trading above (or below) the moving average over a certain time period then xx = true
any ideas on how to code this
the MIN(Low, 60)[0] function would almost work except i wouldnt know what to compare it against,
PS any ideas where I can learn all the C# little stuff like the int_lowbar ... do you know if it is on the ninja site somewhere? I find stuff a little disorganized on Help function sometimes
int just means integer, and _lowbar is a variable name. it could be "int _iamsleepy" etc.
I suggest any C# "for dummies" book to cover basic principles, most of which apply to NinjaTrader directly, and then from there to learn NinjaScript specific commands, either read the help site cover-to-cover or just dissect all the code you can find and go line by line to understand it.