Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
MACD Crossover 0 not firing when it crosses
Collapse
X
-
brojas,
It looks like you may be missing a bracket } near the end. To verify :
Please follow the instructions below to see where the errors are coming from after compiling the indicator. This will allow you to debug the indicator/strategy or remove it from your PC. If you are wondering why you receive an error when compiling only one indicator, it is because NinjaTrader compiles all indicators and strategies- not just one.
Open NinjaTrader- From the Control Center select the Tools menu--> select the Edit NinjaScript menu item--> select Indicator
- Select an indicator and double click on it.
- A new window will appear and you will need to right click in the window and select Compile to compile the indicators.
- At the bottom of the window a new section will appear where you can find the error locations.
- Please send me a screenshot of the error with the name and description fields clearly readable.
To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and post here as an attachment.Last edited by NinjaTrader_AdamP; 01-18-2012, 11:18 AM.Adam P.NinjaTrader Customer Service
Comment
-
Thank you. That got rid of the error.
However, this being my first modified code didn't fire.
What should I do? I originally started with the strategy wizard.
Then I added the 2nd parameter - Tick so it would fire in real-time.
So although it compiles, it doesn't buy/sell when the MACD crosses 0.
What should I change?
Thank you.
Comment
-
Brojas,
For one this :
if (CrossBelow(MACD(12, 26, 9), 0, 1))
{
ExitShort("", "");
}
Won't work with the EnterLong portion.
If you can post your strategy I can test on my end. It is located in My Documents / NinjaTrader 7 / bin / custom / strategy / Macdcrosses0.cs
Please let me know if I may assist further.Adam P.NinjaTrader Customer Service
Comment
-
-
Hi brojas47,
Depending on what you're trading, your entry condition may be too restrictive. You are entering long when MACD crosses above 1. Apply MACD indicator to your chart to see the types of values you're getting and a quick check to see if the condition is ever true.
Then as Adam notes, your exit condition won't ever trigger since you have no short positions. You will likely want to change this to ExitLong();Ryan M.NinjaTrader Customer Service
Comment
-
Okay, that was a stupid error. I merged 2 strategies together.
Here's my new stripped-down strategy.
I just want to test out buying in real-time if the MACD diff is > 0 buy
diff < 0 sell.
I don't care about the timeframe as long as it fires as soon as the line crosses, which is why I chose 1 tick.
Here's the strategy attached.
Thanks again.Attached Files
Comment
-
brojas,
Please note that :
if (MACD(12, 26, 9).Diff[1] > 0)
{
EnterLong(DefaultQuantity, "");
}
May enter many long positions. This condition will be true for periods of time. I would suggest continuing to use "CrossAbove".
Please let me know if I may assist further.Adam P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
647 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
367 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
571 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment