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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
81 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
42 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
64 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
66 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
54 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment