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 charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
65 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
149 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
162 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
99 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
286 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment