NexusFi: Find Your Edge


Home Menu

 





Stop loss modification


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one rleplae with 3 posts (0 thanks)
    2. looks_two thegreattrader with 2 posts (0 thanks)
    3. looks_3 iqgod with 1 posts (0 thanks)
    4. looks_4 olres7 with 1 posts (0 thanks)
    1. trending_up 2,812 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Stop loss modification

  #1 (permalink)
 olres7 
Gatlinburg TN/USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 12 since Sep 2015
Thanks Given: 5
Thanks Received: 0

Attachment 195796Hi!

I want to write a strategy for a stop loss modification.
I wrote it however it doesn't work properly. It works but has different results.

You may look it on example:

Lets say my stop loss is 4 ticks
If I have:
+5 ticks profit modify stop loss to -3 ticks loss
+6 ticks profit modify stop loss to -2 ticks loss
+7 ticks profit modify stop loss to -1 tick loss
+8 ticks profit modify stop loss to 0 tick break-even
+9 ticks profit modify stop loss to +1 tick profit
+10 ticks profit modify stop loss to +2 tick profit
+11 ticks profit modify stop loss to +3 tick profit

if (Position.MarketPosition == MarketPosition.Short)
{
if(Low[0] <= Position.AvgPrice - (5 * TickSize))
SetStopLoss("Short1",CalculationMode.Price, Position.AvgPrice + (3*TickSize) ,false);
...
if(Low[0] == Position.AvgPrice - (11 * TickSize))
SetStopLoss("Short1",CalculationMode.Price, Position.AvgPrice - (3*TickSize),false);
}

It check only the last bar low[0] to last entry price.

If I leave only ONE stop loss modification it works great.

+8 ticks profit modify stop loss to 0 tick break-even
It does exactly what I want.
It finds THE LOWEST LOW from my ENTRY PRICE and compared to current price.

However when I use all of them it is a mess.

If anybody knows how to help me to modify stop losses to different parameters I will only appreciate

Thanks,
Serge

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


olres7 View Post
Attachment 195796Hi!

I want to write a strategy for a stop loss modification.
I wrote it however it doesn't work properly. It works but has different results.

You may look it on example:

Lets say my stop loss is 4 ticks
If I have:
+5 ticks profit modify stop loss to -3 ticks loss
+6 ticks profit modify stop loss to -2 ticks loss
+7 ticks profit modify stop loss to -1 tick loss
+8 ticks profit modify stop loss to 0 tick break-even
+9 ticks profit modify stop loss to +1 tick profit
+10 ticks profit modify stop loss to +2 tick profit
+11 ticks profit modify stop loss to +3 tick profit

if (Position.MarketPosition == MarketPosition.Short)
{
if(Low[0] <= Position.AvgPrice - (5 * TickSize))
SetStopLoss("Short1",CalculationMode.Price, Position.AvgPrice + (3*TickSize) ,false);
...
if(Low[0] == Position.AvgPrice - (11 * TickSize))
SetStopLoss("Short1",CalculationMode.Price, Position.AvgPrice - (3*TickSize),false);
}

It check only the last bar low[0] to last entry price.

If I leave only ONE stop loss modification it works great.

+8 ticks profit modify stop loss to 0 tick break-even
It does exactly what I want.
It finds THE LOWEST LOW from my ENTRY PRICE and compared to current price.

However when I use all of them it is a mess.

If anybody knows how to help me to modify stop losses to different parameters I will only appreciate

Thanks,
Serge

You might find helpfull the code in my BOT to update the stoploss.
It is a trailing stop, but you can easily update it to what you want to do
Be carefull if you update the stoploss, once i a while you will run into the problem of 'overfill'

Then NT throws an error and the strategy stops working..


Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
thegreattrader
London
 
Posts: 4 since Mar 2016
Thanks Given: 0
Thanks Received: 1


"Be carefull if you update the stoploss, once i a while you will run into the problem of 'overfill'

Then NT throws an error and the strategy stops working.."


- In what cases does updating a stoploss would result in an overfill. I am confused about this comment

Thanks

Reply With Quote
  #4 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


thegreattrader View Post
"Be carefull if you update the stoploss, once i a while you will run into the problem of 'overfill'

Then NT throws an error and the strategy stops working.."


- In what cases does updating a stoploss would result in an overfill. I am confused about this comment

Thanks

This happens when the order is modified (new order) and in the meantime it is executed
resulting in 2 times execution. The problem occurs if you change targets and stops, when
the price is close or at that level.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
 
iqgod's Avatar
 iqgod 
Mumbai, India
Legendary Market Wizard
 
Experience: Advanced
Platform: ChartNexus
Trading: Stocks, Commodities, Futures
Posts: 1,802 since Feb 2012
Thanks Given: 3,658
Thanks Received: 3,097

Agreed NinjaTrader 8 is still beta but I have encountered this issue when moving stop part of an OCO order manually on the ChartTrader - in case I move it too close to the ask / bid and in case the stop can't be set because price is already at that level then the stop gets deleted and you effectively are trading without the stop!


Thank My New Journal https://nexusfi.com/trading-journals/56579-just-being-trader-letting-go.html
Please visit and thank individual posts if you feel they are / will be serving some purpose for someone! Remember: Gratitude begets gratitude!
Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
thegreattrader
London
 
Posts: 4 since Mar 2016
Thanks Given: 0
Thanks Received: 1

thanks for taking time to reply rleplae.

1) Do you modify a trailing order due to this problem?
2) I am new to this forum. Futures.io is not letting me download the sample you have provided earlier. Is there a way I can get a copy of this without being an elite member? I am still new

thanks

Reply With Quote
  #7 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


thegreattrader View Post
thanks for taking time to reply rleplae.

1) Do you modify a trailing order due to this problem?
2) I am new to this forum. Futures.io is not letting me download the sample you have provided earlier. Is there a way I can get a copy of this without being an elite member? I am still new

thanks

1) over fill, there is not much you can do about it, you can try to avoid chaning target or stop
if the price is close to the price

2) i would strongly recommend considering to become an elite member, it is only 100$ and
probably the best 100$ spend in your trading career, not for my module but for all the other
premium discussions and indicators and material

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on April 12, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts