I am trying to place a stop loss on the low and high of the previous bar. When entering the market long, I want to put the stop loss at the low of the previous candle. When entering short, I want to place the stop loss at the previous candle's high. However, I am unable to do it. I have tried different techniques but failed. Attached is the script. Can anyone tell me what I may be doing wrong?
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
Placing StopLoss According to Previous Candle
Collapse
X
-
Placing StopLoss According to Previous Candle
Hello:
I am trying to place a stop loss on the low and high of the previous bar. When entering the market long, I want to put the stop loss at the low of the previous candle. When entering short, I want to place the stop loss at the previous candle's high. However, I am unable to do it. I have tried different techniques but failed. Attached is the script. Can anyone tell me what I may be doing wrong?Tags: None
-
Hello cranky,
Unfortunately, you cannot use dynamic price information with the Stop Loss (or Profit Target) in the Strategy Buider.
Below is a link to forum posts that discuss.
Hello support team, I have 2 dataseries, a 1minute to detect the ATR value. Now I would like to set the stoploss and profit target based on the actual ATR Value Example: Stoploss 2xATR Profittarget 3xATR value 1. How can this be done with builder, I have no coding experience 2. Later I would like to have the possibility to
Use Exit orders in the Conditions and Actions instead.
You will also want to ensure that the price of the low of the previous bar is a valid price (and below the current bid).Chelsea B.NinjaTrader Customer Service
-
Can you provide a simple example code of how would I do that on the "Conditions and Actions" screen of the builder? I have attached a script that I am using. Note that this strategy is for only long positions.
Basically, I am asking how would you tell the system to put a stop loss. I have tried, it doesn't seem to work.Attached FilesLast edited by cranky; 08-16-2023, 02:15 AM.
Comment
-
Hello cranky,
I have provided an example in post # 2. May I confirm you have followed the links to the forum post with the TrailBuilderExample and IndicatorAsOrderPriceBuilderExample.
Have you imported and opened these scripts in the Strategy Builder to learn how to submit an order using a dynamic price?
You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
"Basically, I am asking how would you tell the system to put a stop loss. I have tried, it doesn't seem to work."
As stated in post # 2, you cannot use a dynamic price for a stop loss in the Strategy Builder. Either use an exit order as I have directed you, or unlock the script and code by hand.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello cranky,
In the TrailBuilderExample, in set 2, the price for the stop is set (CurrentStopPrice) to the Close with an offset of the TrailStopDistance.
In set 4 the order is submitted.
Using the same technique, assign the stop price to Price -> Low (instead of the Close with an offset)
Calculate.OnEachTick would update the script each time a tick is received, allowing the logic to be evaluated before the bar closes in real-time.
For historical as well, the script would need to be unlocked and 1-tick intra-bar granularity implemented and TickReplay enabled.
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by SnailHorn, Today, 10:49 PM
|
0 responses
4 views
0 likes
|
Last Post
by SnailHorn
Today, 10:49 PM
|
||
Started by naanku, Today, 07:25 PM
|
0 responses
8 views
0 likes
|
Last Post
by naanku
Today, 07:25 PM
|
||
Started by milfocs, Today, 07:23 PM
|
0 responses
6 views
0 likes
|
Last Post
by milfocs
Today, 07:23 PM
|
||
Started by PaulMohn, Today, 06:59 PM
|
0 responses
8 views
0 likes
|
Last Post
by PaulMohn
Today, 06:59 PM
|
||
Started by bortz, 11-06-2023, 08:04 AM
|
48 responses
1,756 views
0 likes
|
Last Post
by carnitron
Today, 06:57 PM
|
Comment