I was able to add StrategyInfo.ClosedEquity to my strategy and have it close out when the net profit reaches a certain amount. However, now I would like to try setting it up so once profit reaches a certain amount, it then focuses on loses, and when/if the loses reach a certain point, it closes out. Much like a trailstop, but according to the prog guide, trailstops are specific to an order and not to overall profit.
Let's say my equity cap is at $1500 for my automated strategy. Now, if it hits $1500, and then over time profit drops below $1200, I want it to close out. I can not picture how to write it using simple if statements, is there something in MC that can help?
Is there any way to write it?
For reference (not super relevant), below is how I am using ClosedEquity:
Code: Select all
if(!money())
{
if(StrategyInfo.MarketPosition > 0)
{
exitLong.Send("Close for profit cap");
}
if(StrategyInfo.MarketPosition < 0)
{
exitShort.Send("Close for profit cap");
}
return;
}
private bool money()
{
if(StrategyInfo.ClosedEquity >= Amount)
return false;
else
return true;
}