Seems it would be simple, but I'm a newbie to coding.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Breakeven Stop
Collapse
X
-
Breakeven Stop
Is there a way in Ninjascript to place a breakeven stop, once a certain level of ticks above entry price has been reached?
Seems it would be simple, but I'm a newbie to coding.Tags: None
-
-
Breakeven Stop
I am getting an error message saying "the name "stoplossticks" does not exist in the current context".
Comment
-
Breakeven Stop
I copied it from the sample strategy.
Here's my code:
protectedoverridevoid Initialize()
{
CalculateOnBarClose = false;
// SetProfitTarget(CalculationMode.Ticks, 20);
SetStopLoss(CalculationMode.Ticks, stoplossticks);
// ExitOnClose = true;
}
Comment
-
If you go back to look at the SamplePriceModification reference sample please take note of the "Variables" and "Properties" sections of the code. In the "Variables" section you will see where stoplossticks was defined. Here is the code snippet from there.
In the "Properties" section of the code you will see how I made that a user definable input with this code segment.Code:private int stoplossticks = 20;
Because I defined stoplossticks in the "Variables" section I can use that variable in the Initialize() method. You will need to do the same if you wish to use a variable. Alternatively, you can just input an integer in place of stoplossticks so for example:Code:/// <summary> /// </summary> [Description("Numbers of ticks away from entry price for the Stop Loss order")] [Category("Parameters")] public int StopLossTicks { get { return stoplossticks; } set { stoplossticks = Math.Max(0, value); } }
http://www.ninjatrader-support.com/H...tStopLoss.htmlCode:[FONT=Courier New][SIZE=2]SetStopLoss(CalculationMode.Ticks, 4);[/SIZE][/FONT]
Josh P.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment