Say if the current bar's open and low ($1), close and high ($1.50) and the value of SMA (14) is $1.25. Is it possible to set my return value (ie: exit price) to the value of SMA (14)(ie: $1.25)? If so, how?Thanks in advance.
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
Changing the return value
Collapse
X
-
Changing the return value
Hi,
Say if the current bar's open and low ($1), close and high ($1.50) and the value of SMA (14) is $1.25. Is it possible to set my return value (ie: exit price) to the value of SMA (14)(ie: $1.25)? If so, how?Thanks in advance.Tags: None
-
Hello JT1230,
Yes, you can supply an indicator value (which is a double) anywhere a double is accepted.
For example:
if (SMA(14)[0] > GetCurrentBid())
{
ExitLongLimit(SMA(14)[0]);
}
This would check that the sma is a valid price for a sell limit order and then places the sell limit order at the price of the sma.Chelsea B.NinjaTrader Customer Service
-
Hi Chelsea,
Thanks for your reply. I've altered my exit long limit condition to:
if (DonchianChannel(5).Lower[1] > Low [0] && DonchianChannel(5).Lower[1] < High [0])
{
ExitLongLimit(DonchianChannel(5).Lower[1]);
}
But it doesn't seem to work when I backtested it (shown in the graph). The long exit should be where the black arrow is. Please advise.
Comment
-
Hello JT1230,
Any observed behavior in your strategy's logic that is not matching up with what you are expecting to see would need to be debugged with Print() statements to fully understand how the logic is firing, the variables used to control the logic, and to identify a specific issue that needs rectifying.
Please keep in mind, Limit orders submitted with the Managed Approach will cancel after the close of the next bar unless an overload with isLiveUntilCanceled is used.
ExitLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)
I've included some links to publicly available information on debugging and the order methods used for the managed approach.
Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418
TraceOrders: http://ninjatrader.com/support/forum...ead.php?t=3627
Live Until Cancelled Orders - https://ninjatrader.com/support/help...ancelledOrders
If you have any questions regarding the information received in the output window, please don't hesitate to write back with the resulting prints.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Aviram Y, Today, 05:29 AM
|
0 responses
2 views
0 likes
|
Last Post
by Aviram Y
Today, 05:29 AM
|
||
Started by quantismo, 04-17-2024, 05:13 PM
|
3 responses
25 views
0 likes
|
Last Post Today, 05:23 AM | ||
Started by ScottWalsh, 04-16-2024, 04:29 PM
|
7 responses
34 views
0 likes
|
Last Post Today, 05:15 AM | ||
Started by cls71, Today, 04:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by cls71
Today, 04:45 AM
|
||
Started by mjairg, 07-20-2023, 11:57 PM
|
3 responses
217 views
1 like
|
Last Post
by PaulMohn
Today, 04:22 AM
|
Comment