NexusFi: Find Your Edge


Home Menu

 





Intraday Profit Loss


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #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 =  1 and condition99 ) then 
sell 
("sell p&l") 1 contract next bar at market;

if (
marketposition = -1 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?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
Datafeed for Atas
Platforms and Indicators
EA
Platforms and Indicators
Trump Media to sell instant access to market-moving soci …
Traders Hideout
No book, only a stair: journaling fills where price move …
Cryptocurrency
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
Johnnys Journal
2 thanks
TopStep Trader disappointment
2 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643


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 X Reply With Quote
Thanked by:
  #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
Thanked by:
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

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

Regards,
ABCTG


Follow me on X Reply With Quote




Last Updated on November 12, 2014


© 2026 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 - Downloads - Top
no new posts