I have been attempting to write an easy function that closes a basket of trades at a variable percentage of gain of the overall account balance.
My "CloseAll()" function works perfectly, but integrating it with the criteria that triggers that function is where my problem lies.
Here's what I have:
//--------------------------
extern double BalanceMultiple = 0.02;
//--------------------------
void StopPercent()
{
if (AccountProfit() >= (AccountBalance()*BalanceMultiple))
{
CloseAll();
}
Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit());
return (0);
}
//-------------------------
The close all, and comments work perfectly. But I notice the "AccountProfit" number never changes in the comment section when running the tester.
Since that never changes once it shows the negative from the spread, I'm assuming that the same is happening with the use if AccountProfit in my if statement, so no value will ever be compared top the account balance.
I am obviously missing something simple here, but I've searched endlessly for examples, and have no clue why it's not working as I wrote it.
Any ideas from the smart guys? 'cuz I apparently be a dummy
My "CloseAll()" function works perfectly, but integrating it with the criteria that triggers that function is where my problem lies.
Here's what I have:
//--------------------------
extern double BalanceMultiple = 0.02;
//--------------------------
void StopPercent()
{
if (AccountProfit() >= (AccountBalance()*BalanceMultiple))
{
CloseAll();
}
Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit());
return (0);
}
//-------------------------
The close all, and comments work perfectly. But I notice the "AccountProfit" number never changes in the comment section when running the tester.
Since that never changes once it shows the negative from the spread, I'm assuming that the same is happening with the use if AccountProfit in my if statement, so no value will ever be compared top the account balance.
I am obviously missing something simple here, but I've searched endlessly for examples, and have no clue why it's not working as I wrote it.
Any ideas from the smart guys? 'cuz I apparently be a dummy
No way I'll wreck this... It's a beer truck!