NexusFi: Find Your Edge


Home Menu

 





I have a function used on TS several years, but now it can't work correctly on MC


Discussion in EasyLanguage Programming

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




 
Search this Thread

I have a function used on TS several years, but now it can't work correctly on MC

  #1 (permalink)
slicent
Taipei City
 
Posts: 15 since Jul 2020
Thanks Given: 10
Thanks Received: 0

The function is as the end of the post.
It is a filter function
That is:
After attain profit target, calculate the loss of closed position(after attain the target) and open position profit.
Then use the average value per contract as the filter.
The code can run correctly on TS, but it can't on MC, and I try several days but it still can't work...
Does any one knows how to correct it on MC?

I have tried for Closedpositionprofit[0]-Closedpositionprofit[1]
1.Closedpositionprofit[0]-Closedpositionprofit[1]
it always implies ProfitTargetAttain = true
2.positionprofit[0] - openpositionprofit[0] - ( positionprofit[1] - openpositionprofit[1] ),
it always implies ProfitTargetAttain = false
3.positionprofit - openpositionprofit
It seems ProfitTargetAttain = true will lag for several bars...
all can't work and I am extremely confused...

 
Code
inputs:
	Per_PL_Min_TARG( numericsimple );
variables:
	Closedpositionprofit( 0 ),//only consider when currentcontracts != 0
	Closedbarloss( 0 ),//only consider when currentcontracts != 0
	Closedpositiongrossloss_AfterTARG( 0 ),//only consider when currentcontracts != 0
	value_currentcontracts( 0 ),
	Closedbarlosscontracts( 0 ),
	Closedpositionlosscontracts_AfterTARG( 0 ),//only consider when currentcontracts != 0
	ProfitTargetAttain( false );
	
value_currentcontracts = Currentcontracts;
Closedpositionprofit = Positionprofit - Openpositionprofit;

If Closedpositionprofit[ 0 ] - Closedpositionprofit[ 1 ] > 0.1
Then ProfitTargetAttain = True;

If currentcontracts = 0
Then Begin
	ProfitTargetAttain = False;
	Closedpositiongrossloss_AfterTARG = 0;
	Closedpositionlosscontracts_AfterTARG = 0;
end;

If Closedpositionprofit[ 0 ] - Closedpositionprofit[ 1 ] < -0.1
Then Begin
	Closedbarloss = Closedpositionprofit[ 0 ] - Closedpositionprofit[ 1 ];
	Closedbarlosscontracts = value_currentcontracts[ 1 ] - value_currentcontracts[ 0 ]; //This is true if profit rarget is greater than stop loss and # of max. contracts hold is 3.
End
Else Begin
	Closedbarloss = 0;
	Closedbarlosscontracts = 0; 
End;

If ProfitTargetAttain = True
Then Begin	
	Closedpositiongrossloss_AfterTARG = Closedpositiongrossloss_AfterTARG + Closedbarloss;
	Closedpositionlosscontracts_AfterTARG = Closedpositionlosscontracts_AfterTARG + Closedbarlosscontracts;
	_Filter_Per_PL_TARG = IFFLogic( ( Closedpositiongrossloss_AfterTARG + Openpositionprofit ) / ( Closedpositionlosscontracts_AfterTARG + Currentcontracts ) > Per_PL_Min_TARG, True, False );
End
Else _Filter_Per_PL_TARG = True;

Reply With Quote




Last Updated on June 11, 2023


© 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