NexusFi: Find Your Edge


Home Menu

 





Intraday Profit Loss


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,099 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?
REcommedations for programming help
Sierra Chart
What broker to use for trading palladium futures
Commodities
Quantum physics & Trading dynamics
The Elite Circle
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


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
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,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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