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
EnterLong above a specific value or price.
Collapse
X
-
EnterLong above a specific value or price.
I have written a strategy in C# where I want to submit a long order above a specific price, what function do I use? For example, current stock price is $100 and it is within a range from $102 and $97. I want to submit a long order if the price break above $102. How do I put this conditional order using C#? What function do I use?Tags: None
-
Hello Bhavin81,
For that type of condition you would check if the close price is greater equal to 102 or you can also use CrossAbove as the condition. A specific price can be entered as Misc -> Numeric value.
If you wanted the strategy to know about the102 price without typing it in you would need to determine what relevance 102 has so that can be calculated. However you are generating the range of prices would be what you need to look into further to understand if that can be made into a variable or calculated by the strategy.JesseNinjaTrader Customer Service
-
I am bit confused. I created a new custom strategy which is called "SubmitConditionalLongAbove". This strategy I guess will have to take Two input; TriggerPrice and Quantity. I already have a strategy called "MarketForecastStrategy", which determines when to go long above a given price. So, in this case, MarketForecastStrategy will call "SubmitConditionalLongAbove" strategy and pass TriggerPrice and Quantity. SubmitConditionalLongAbove will then call EnterLongLimit function in OnBarUpdate() method as below? Is that right understanding? if so, How do i make sure that this strategy/conditionalOrder only executes ones and may be in given timelimit?
protected override void OnBarUpdate()
{
//Add your custom strategy logic here.
if (CurrentBar <= BarsRequiredToTrade)
return;
if(Close[0] > EntryPrice)
{
EnterLongLimit(Quantity, EntryPrice, "MR Forecast Long" + CurrentBar);
}
}Last edited by Bhavin81; 02-11-2023, 04:16 PM.
Comment
-
Hello Bhavin81,
For this type of use case with a Limit order you would need to make sure your condition stays true for as long as the order is not filled. Limit orders expire after 1 bar if not filled unless you keep calling the entry method while it should be active.
You could add a simple position check here as part of the condition, if the position is flat and close is above entry price then allow the entry. Once the entry fills and the position is not flat it wont be called again.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
4 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
||
Started by rhyminkevin, Today, 04:58 PM
|
4 responses
52 views
0 likes
|
Last Post
by dp8282
Today, 06:13 PM
|
||
Started by iceman2018, Today, 05:07 PM
|
0 responses
5 views
0 likes
|
Last Post
by iceman2018
Today, 05:07 PM
|
||
Started by lightsun47, Today, 03:51 PM
|
0 responses
8 views
0 likes
|
Last Post
by lightsun47
Today, 03:51 PM
|
||
Started by 00nevest, Today, 02:27 PM
|
1 response
14 views
0 likes
|
Last Post
by 00nevest
Today, 03:48 PM
|
Comment