NexusFi: Find Your Edge


Home Menu

 





Easylanguage NetProfit Strategy with midnight issues


Discussion in MultiCharts

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




 
Search this Thread

Easylanguage NetProfit Strategy with midnight issues

  #1 (permalink)
bruiser
Burbank + California/ USA
 
Posts: 6 since Mar 2020
Thanks Given: 0
Thanks Received: 0

Hello,

Looking for some help on an easylanguage coding spot where I am stuck.

Im using a daily profit target / daily profit loss method whereby it will stop trading once either threshold has been hit.

I have seen some other code posted along these lines and to some degree, for the most part they work. However, the problem that I am running into is the fact that "NetProfit" resets at midnight.

So, trading the e-mini S&P beginning at 1700 CT and running till 1515 CT the next day for example, at midnight which is in the middle of the trading session the NetProfit resets and essentially takes all the math calculating the daily profit and daily profit / loss targets back to zero and doesn't do what it is intended to do.

In other words, if the goal has been hit for the next day before midnight (starting at 1700 and say target has been hit by 2100) it will stop trading as it is supposed to.

But, at midnight it will think its ok to trade again since everything reset and the intention is that it would not start trading again until 1700 the next day.

If someone could provide the missing pieces I would greatly appreciate it.

Here is the portion of the code that I am having the issue with:

Variables:
DailyProfit (0),
DailyLoss (0),
YesterdayNet (0),
TodayNet (0),
DayPL (False);


If date <> date[1] then begin
YesterdayNet = NetProfit ;
End;

If MP = 0 Then Begin
TodayNet = NetProfit - YesterdayNet;
End;

If -DailyLoss < TodayNet And TodayNet < DailyProfit Then
DayPL = True
Else DayPL = False;

I have also tried the following and still issues:

If (date = date[1] and time > 1659)
then begin
YesterdayNet = NetProfit ;
End;

If MP = 0 Then Begin
TodayNet = NetProfit - YesterdayNet ;
End;

if date = date[1] and time = 2359
then begin
PrevNetProfit = TodayNet ;
End;

if date <> date[1] and time = 0000
Then begin
TodayNet = PrevNetProfit - netprofit;
End;

If TodayNet < DailyProfit Then
DayPL = True
Else DayPL = False;


Thank you in advance for your assistance.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
11 thanks
GFIs1 1 DAX trade per day journal
11 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

Hi bruiser,

welcome to futures.io. You could simply move the resetting of the net profit value to the time of your choice, for example after 5 PM.
You can accomplish this for example by using below code snippet:
 
Code
Variables:
bool resetAllowed ( false );

//allow the reset again for the new day
if Date <> Date[1] then
   resetAllowed = true ;

//check for the time based reset
if Time > 1700 and resetAllowed then
begin 
   resetAllowed = false ;
   //update your variable here - for example YesterdayNet = NetProfit ;
end ;
Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
bruiser
Burbank + California/ USA
 
Posts: 6 since Mar 2020
Thanks Given: 0
Thanks Received: 0


Thank you very much!

Greatly appreciate the help!

Reply With Quote
  #4 (permalink)
bruiser
Burbank + California/ USA
 
Posts: 6 since Mar 2020
Thanks Given: 0
Thanks Received: 0

One other question along a similar line:

This works with regards to what it is supposed to do. Resets profits to zero at specified time and with P&L / Loss parameters set it would stop trading once target is met.

However, it works for the specific code on the market that it is activated on.

If I am trading 3 different markets for example, it would run the parameters individually on each market and stop trading accordingly for that particular market.

Trying to figure out what I would need to implement in the code to have it look at the combined P&L / Loss for the account for the day / markets traded for the day.

For example: If we set the day P&L target to $500 in the code it would keep taking new trades until that market either hit the $500 profit target or the daily loss amount was triggered.

But, if were trading 5 markets for example, I want to be able to have each individual market look at the profit / loss overall for the day before taking a new trade. So, if $500 has already been hit for the profits it would not enter new trades in any of the other markets since the daily goal has been hit. Regardless of the fact that each particular market may not have had a trade.

I hope that all makes sense, and I am pretty sure it is something rather simple I am missing.

Really appreciate the assistance.

Thank you

Reply With Quote




Last Updated on March 21, 2020


© 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