NexusFi: Find Your Edge


Home Menu

 





Profit Target as Percent Gain


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ascr with 2 posts (0 thanks)
    2. looks_two kronie with 1 posts (0 thanks)
    3. looks_3 Jeff65 with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 9,200 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Profit Target as Percent Gain

(login for full post details)
  #1 (permalink)
ascr
Toronto
 
Posts: 3 since Oct 2010
Thanks Given: 0
Thanks Received: 0

Help would be greatly appreciated.
I'm trying to exit a position at a 15% gain using easyLanguage.
Here's the relevant pieces of the code:

condition3 = Price > (EntryPrice * 1.15);
if condition3 then
Sell("LE 15% Gain") This Bar On Close;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
IQFeed MBO data experience
The Elite Circle
SPY ETF Question
Stocks and ETFs
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
Volume profile TradeStation
EasyLanguage Programming
ISO Equity Curve Indicator
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Supertradersams Thread Journal on NQ/MNQ
28 thanks
GFIs1 1 DAX trade per day journal
24 thanks
Tao te Trade: way of the WLD
13 thanks
Diary of a simple price action trader
13 thanks
Deaddogs Stock Trading
12 thanks

(login for full post details)
  #3 (permalink)
ascr
Toronto
 
Posts: 3 since Oct 2010
Thanks Given: 0
Thanks Received: 0


After poking around I found the solution. I'm rolling the account, so I'm using "initialcapital+netprofit" elsewhere in the code. Here's the relevent code:

variables: x(0);
x = initialcapital+netprofit;
setprofittarget (x * 0.15);

Reply With Quote
(login for full post details)
  #4 (permalink)
 
kronie's Avatar
 kronie 
NYC + NY / USA
 
Experience: Advanced
Platform: "I trade, therefore, I AM!"; Theme Song: "Atomic Dog!"
Trading: EMD, 6J, ZB
Posts: 796 since Oct 2009

excellent answer,

I have often wondered how to set a percentage as a target instead of a fixed interval as such

perhaps this can be shown with examples of how to implement it?

thanks

Reply With Quote
(login for full post details)
  #5 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97


kronie View Post
excellent answer,

I have often wondered how to set a percentage as a target instead of a fixed interval as such

perhaps this can be shown with examples of how to implement it?

thanks

I did not really test the following code, but it should put you in the right direction. The code example show two ways of determining a dynamic profit target. The first is based off the current ATR while the second is a percentage gain of current net profit.

 
Code
Input:
    ATRfactor( 2 ),
    ATRLength( 13 ),
    PrcntGain( 15 );
    
Variables:
    ProfitTarget$(0),
    ATR(0),
    MP(0);

ATR = AvgTrueRange( ATRLength );
MP = MarketPosition;

// Enter new trade on golden cross

If ( average(Close, 50) crosses over Average( Close, 200 ) ) Then
    Buy ("Gold Cross") next bar at market
Else If ( average(Close, 50) crosses under Average( Close, 200 ) ) then
    Sell ("Death Cross") next bar at market;
    
If ( MP = 1 ) Then
Begin
    // Set profit based upon Average True Range
    ProfitTarget$ = ATRfactor * ATR * BigPointValue;
    SetProfitTarget( ProfitTarget$ );
End;


If ( MP = 1 ) And ( NetProfit > 0 ) Then
Begin
    // Set profit based upon percent profit
    ProfitTarget$ = ( NetProfit * PrcntGain / 100 );
    SetProfitTarget( ProfitTarget$ );
End;

Reply With Quote





Last Updated on November 17, 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