Thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Wait x bars after signal to trade
Collapse
X
-
Wait x bars after signal to trade
Apologies for this simple and probably redundant question. How can I wait x bars after a signal to go long or short, such as from a moving average crossover.
ThanksTags: None
-
first :
learn C# and NinjaScript
next :
create a strategie
next :
put this after your strategie setup
//your signal ...
if ( ....... == ......)
{
signalbar = CurrentBar;
signal = 1; // long
}
if ( ....... == ......)
{
signalbar = CurrentBar;
signal = 2; // short
}
int x = 3; // or 4 or 5 or what ever you want
// trade your signal
if (signalbar + x == CurrentBar)
{
if (signal == 1 && .....)
{
orderlong = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Limit, quantity, longlimit, 0, "", "long");
signal = 0;
}
if (signal == 2 && .....)
{
ordershort = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, quantity, shortlimit, 0, "", "short");
signal = 0;
}
}
enjoyLast edited by jr123; 12-21-2017, 04:14 AM.
-
Hello rgreenberg,
Thanks for your post.
I see you have posted a duplicate in the more appropriate Strategy forum. I will provide a response there. https://ninjatrader.com/support/foru...528#post528528
For future reference please avoid duplicate posts as we do not always see the duplicates. If you have posted in the wrong forum, just let us know and we can move your thread to the correct forum.Paul H.NinjaTrader Customer Service
Comment
-
jr123
Thank you very much for your detailed response! I am very appreciative of you taking the time to respond. I will incorporate your suggestions into my work.
rg
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
10 responses
1,769 views
0 likes
|
Last Post
by Leafcutter
Today, 03:01 AM
|
||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, 04-23-2024, 07:51 PM
|
2 responses
30 views
0 likes
|
Last Post
by Max238
Today, 02:25 AM
|
||
Started by Shansen, 08-30-2019, 10:18 PM
|
24 responses
943 views
0 likes
|
Last Post
by spwizard
Today, 01:29 AM
|
||
Started by Max238, Today, 01:28 AM
|
0 responses
10 views
0 likes
|
Last Post
by Max238
Today, 01:28 AM
|
||
Started by rocketman7, Today, 01:00 AM
|
0 responses
7 views
0 likes
|
Last Post
by rocketman7
Today, 01:00 AM
|
Comment