Mark.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SamplePriceModification
Collapse
X
-
SamplePriceModification
Hello, how do I add short position in the strategy attached, thank you.
Mark.Tags: None
-
Hello snakepatob,
Thank you for your post.
In general, a short position can be added with the reverse conditions as the long. In this strategy there would need to be a few changes. Below is and example of using the reverse of what is used for the long and considering the position before taking a new position.
Code:// Resets the stop loss to the original value when all positions are closed if (Position.MarketPosition == MarketPosition.Flat) { SetStopLoss(CalculationMode.Ticks, stoplossticks); // Entry Condition: Increasing price along with RSI oversold condition if (Close[0] > Close[1] && RSI(14, 3)[0] <= 30) { EnterLong(); } // Opposite of long condition if (Close[0] < Close[1] && RSI(14, 3)[0] >= 30) { EnterShort(); } } // If a short or long position is open, allow for stop loss modification to breakeven else if (Position.MarketPosition == MarketPosition.Long) { // Once the price is greater than entry price+50 ticks, set stop loss to breakeven if (Close[0] > Position.AvgPrice + 50 * TickSize) { SetStopLoss(CalculationMode.Price, Position.AvgPrice); } } else if (Position.MarketPosition == MarketPosition.Short) { // Once the price is greater than entry price-50 ticks, set stop loss to breakeven if (Close[0] < Position.AvgPrice - 50 * TickSize) { SetStopLoss(CalculationMode.Price, Position.AvgPrice); } }
-
Patrik,
thanks for listening, I could include the code and compile.
Without your help I would not have succeeded.
Mark.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
5 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
8 responses
61 views
0 likes
|
Last Post Yesterday, 10:45 AM | ||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
4 responses
3,289 views
1 like
|
Last Post
by jgualdronc
Today, 10:02 AM
|
||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 09:55 AM | ||
Started by halgo_boulder, 04-20-2024, 08:44 AM
|
2 responses
24 views
0 likes
|
Last Post Today, 09:41 AM |
Comment