NexusFi: Find Your Edge


Home Menu

 





Stop strategy after a set $ amount lost from CumProfit


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one vast with 11 posts (2 thanks)
    2. looks_two Big Mike with 8 posts (7 thanks)
    3. looks_3 MXASJ with 1 posts (1 thanks)
    4. looks_4 BigDog with 1 posts (0 thanks)
    1. trending_up 9,732 views
    2. thumb_up 10 thanks given
    3. group 4 followers
    1. forum 21 posts
    2. attach_file 0 attachments




 
Search this Thread

Stop strategy after a set $ amount lost from CumProfit

  #21 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

If your broker supports it and if you run more than 1 strategy, you might consider a stand-alone strategy that uses the GetAccountValue() method. You would need to manually enter your account value at the start of session as that method only works in OnBarDate.

You could then code a daily loss limit for that account, and a "trailing stop" on your equity curve that could trigger an alert or the FlattenEverything() command.

Just be careful if you invoke FlattenEverything() at the same time you are closing positions with other trade logic as you could get inflight issues. A way around it is to apply this stratgey to a different time series than the one you are trading on (say 3 minute bars, COBC=true, for example).

Happy coding!

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #22 (permalink)
 
vast's Avatar
 vast 
Australia
 
Experience: Intermediate
Platform: Ninja
Posts: 167 since Jun 2009
Thanks Given: 154
Thanks Received: 62

Hi Jon

Well I did play with the idea for a bit, but gave up after I realised that I could never get a strategy to do what I wanted.
the money management side was ok, but I couldn't get an strategy that I was happy with. So I gave up, and went back to trading manually. This was the main part of the code.
I am a very basic programmer, and tend to use code from other users, then change it a bit.
Regards

 
Code
                            
Prevents further trading if the current session's realized profit exceeds $myMaxProfit or if realized losses exceed $myMaxLoss.
            not working:(Also prevent trading if 10 trades have already been made in this session.) */
            if (//Performance.AllTrades.TradesPerformance.Currency.CumProfit - priorTradesCumProfit >= myMaxProfit
                (Math.Round(Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit)+ 
                                        Math.Round(Position.GetProfitLoss(Close[0], PerformanceUnit.Currency))) - priorTradesCumProfit >= myMaxProfit
                || Performance.AllTrades.TradesPerformance.Currency.CumProfit - priorTradesCumProfit <= myMaxLoss  
                || maxConsecLoser >= myMaxConsecLoss
                || cumProfit <= maxCumProfit - maxRiskProfit
                ) 

Started this thread Reply With Quote
Thanked by:




Last Updated on November 15, 2010


© 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