NexusFi: Find Your Edge


Home Menu

 





Intraday Profit Loss


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,690 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 =  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?
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Hormuz Normalization Collapses to 19.5% -- Iran Regime F …
Prediction Markets & Event Contracts
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
$4.5M Floods Russia Nuclear Contract in 24 Hours -- Krem …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 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