NexusFi: Find Your Edge


Home Menu

 





NetProfit


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,741 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

NetProfit

  #1 (permalink)
AhmedF
north bergen
 
Posts: 13 since Feb 2017
Thanks Given: 3
Thanks Received: 1

Does anyone know how to write a code in esaylanguage that stops a robot from trading after it has profited x amount of pips?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


AhmedF,

there are several way to approach this, one would be to store the net profit in a variable at the beginning of a new period in which you want to stop the trading when a certain net profit is reached (for example daily or weekly, but others would be possible, too).

Now you compute the difference of the current net profit to the value that you stored within the variable. If the difference is greater than your profit limit, block your code from taking further entries and maybe even close all open positions.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
AhmedF
north bergen
 
Posts: 13 since Feb 2017
Thanks Given: 3
Thanks Received: 1

vNetProfit(0),
vDailyNetProfit(0),

If Date = CurrentDate and Date <> Date[1] then
begin
vNetProfit = NetProfit;
end
else
If Date = CurrentDate then
begin
{ Calculate Daily NetProfits }
vDailyNetProfit = NetProfit - vNetProfit;
end;

i found this online how do implement this with order execution so once the robot profits x amount ( E.g. 200$) stop trading. At the same time i want it to run between certain hours 8am-10:30am the way i want it to function is the following . if 200$ are made starting at 8am and 1030 has not come yet then stop trading else continue trading until 1030 then stop disregarding if it made 200 or not.

ABCTG View Post
AhmedF,

there are several way to approach this, one would be to store the net profit in a variable at the beginning of a new period in which you want to stop the trading when a certain net profit is reached (for example daily or weekly, but others would be possible, too).

Now you compute the difference of the current net profit to the value that you stored within the variable. If the difference is greater than your profit limit, block your code from taking further entries and maybe even close all open positions.

Regards,

ABCTG


Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

AhmedF,

I am afraid without knowing how your "order execution" part of the code looks like, it's hard to give you a clear direction on how to add the code snippet you posted.

The variable vDailyNetProfit holds the daily profit since midnight, if you only want it to hold the profit since 8am, you would have to modify the code to do the reset based on time and not on the date change.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #6 (permalink)
AhmedF
north bergen
 
Posts: 13 since Feb 2017
Thanks Given: 3
Thanks Received: 1

if (data2var2 > 0 )
then begin
vvsup = true;
VVSDN = False;
end;
if (data2var2 < 0 )
then begin
vvsup = False;
VVSDN = True;
end;

if VVSUP then begin
if ( var3 crosses above -0.88) and (trnd > 0) then buy next bar at market;

if VVSDN Then begin
if ( var3 crosses under 0.88) and (trnd < 0) then sellshort next bar at market;

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

AhmedF,

for that code you could for example set VVSUP and VVSDN to false when your profit goals are met. Additionally you can exclude this part from being executed when your goals are met:
 
Code
if profitGoalIsMet = false then
begin
if (data2var2 > 0 )
then begin
vvsup = true;
VVSDN = False;
end;
if (data2var2 < 0 )
then begin
vvsup = False;
VVSDN = True;
end;
end
else
begin
vvsup = False;
VVSDN = false;
end;
Something like the above should work, under the condition that profitGoalIsMet is a boolean variable that holds the result of your profit goal check.

Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on February 23, 2017


© 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