NexusFi: Find Your Edge


Home Menu

 





Intraday Profit Loss


Discussion in EasyLanguage Programming

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




 
Search this Thread

Intraday Profit Loss

  #1 (permalink)
no erocla
turin italy
 
Posts: 96 since May 2013
Thanks Given: 43
Thanks Received: 4

Hi guys,

im trying to write a code that simply stop trading if intraday profitloss > x or < y, for backtested and real trading (flag "test").

Code:

 
Code
                            
//// Storing Morning Balance
if Time 0900 AND Test 0 then begin
PL 
0;
balance GetRTAccountEquity(Account);
END;
if 
Time 0900 AND Test 1 then begin
PL 
0;
balance InitialCapital i_ClosedEquity;
end
now variable "balance" is equal to account balance at 9:00 AM

 
Code
                            
//// Calculating P&L
if test 0 then
PL 
BALANCE GetRTAccountEquity(Account);
if 
test 1 then
PL 
BALANCE - (InitialCapital i_ClosedEquity);

//// EXIT
Condition99 PL >   Max_Daily_Porfit OR PL  < - Max_Daily_Loss 
now, PL is equal to variable "Balance" - actual Account Balance


 
Code
                            
if (marketposition =  and condition99 then 
sell 
("sell p&l"1 contract next bar at market;

if (
marketposition = -and condition99 )then 
buytocover 
("cover p&l"1 contract next bar at market
But unfortunatly it doesn t work, any help ?

Thank you for any response

Regards
No Erocla

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Request for MACD with option to use different MAs for fa …
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
52 thanks
NexusFi site changelog and issues/problem reporting
48 thanks
GFIs1 1 DAX trade per day journal
31 thanks
What percentage per day is possible? [Poll]
31 thanks

  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


no erocla,

you should print the values of your variables to the output bar to check them and see what values they contain.
This line "PL = BALANCE - GetRTAccountEquity(Account);" actually becomes negative when your equity grows and positive when you lose money.
Depending on your input values for Max_Daily_Porfit and Max_Daily_Loss I'd guess that your condition99 can never become true.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
  #4 (permalink)
no erocla
turin italy
 
Posts: 96 since May 2013
Thanks Given: 43
Thanks Received: 4

Thank you like always for the help

 
Code
                            
//// Storing Morning Balance

if Time 0900 then begin
PL 
0;
balance = (InitialCapital i_OpenEquity);
END;
            
//// Calculating P&L
if Time 0900 then
PL 
=(InitialCapital i_OpenEquity) -  BALANCE 
it works now.

No Erocla

Reply With Quote
The following user says Thank You to no erocla for this post:
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

You are welcome. I am glad that it works for you.

Regards,
ABCTG

Follow me on Twitter Reply With Quote





Last Updated on November 12, 2014


© 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