Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Entry not triggering at the MACD Crossover
Collapse
X
-
Entry not triggering at the MACD Crossover
I'm trying to enter a trade as soon as the MACD Crossover occurs but the strategy is entering a bar later see attached screenshots. I have set MACD at bars 0 and crossover is happening between MACD and Avg. Is there a way to set it so I am able to enter the long position as soon as the crossover happens?Tags: None
-
Hello pyraxic,
Here you get a sample macd cross strategy, it will plot arrow up / down on your chart @ macd cross signal. For me I can't see the lag as you're getting, you can test this with your parameters & confirm. I've used standard parameters which you can change as per your need. Also attaching the snapshot for reference.
[ATTACH]n1127583[/ATTACH]
Comment
-
Hello pyraxic,
I attached it but it seems some issue, let me attach it again. Here you get it.
SampleMACDcross.zip
Comment
-
Hello pyraxic,
Just one thing I am suspecting is that after making the change to Calculate = Calculate.OnEachTick you must reset your strategy or you can remove it & add again on your charts. Any changes made to State.SetDefaults don't reflect by refresh (F5).Last edited by s.kinra; 11-15-2020, 04:55 AM.
Comment
-
Hello pyraxic,
s.kinra would be correct in that Calculate would need to be .OnEachTick.
Below is a link to a forum post that discusses this.
I would expect that in real-time data, orders would appear on the same bar the cross occurred on.
In your screenshot are these real-time orders or historical orders?
That said, in historical data, TickReplay (using historical tick data) would also be required for the historical orders to also be placed intra-bar.Chelsea B.NinjaTrader Customer Service
Comment
-
-
If I wrap it inside the IsFirstTickOfBar, it doesn't trigger buy orders every time it crosses. The strategy entered 4 trades in past 15 days.
Code:protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) return; if(IsFirstTickOfBar) { if (CrossAbove(MACD1.Default, MACD1.Avg, 1)) { EnterLong(Convert.ToInt32(DefaultQuantity), @"Long"); } } }
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by inanazsocial, Today, 01:15 AM
|
1 response
5 views
0 likes
|
Last Post Today, 02:18 AM | ||
Started by rocketman7, Today, 02:12 AM
|
0 responses
8 views
0 likes
|
Last Post
by rocketman7
Today, 02:12 AM
|
||
Started by dustydbayer, Today, 01:59 AM
|
0 responses
1 view
0 likes
|
Last Post
by dustydbayer
Today, 01:59 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
23 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
Comment