Account Equity Stop or Avoid the Risk of Ruin

Questions about MultiCharts and user contributed studies.
al68
Posts: 16
Joined: 25 Mar 2016

Account Equity Stop or Avoid the Risk of Ruin

Postby al68 » 05 Apr 2024

Hi,
I'm trying to use an old Function in order to create an AccountEquity StopLoss, but when I use it in my Signals, the function gives me an error: "GetBDAccountEquity function is not implemented".
Can anyone help me?
I enclose the Function AccountEqutyStop_X that I use

Code: Select all

// AccountEquityStop_X Input: EquityStopAlert(numeric), // Set Stop Loss Alert EquityProfitAlert(numeric), // Set Profit Target Alert AcctNum(string), // Pass Account ID: "12345.." oNetProfitToday(numericref); //input-output: in the strategy code you have to declare it as a variable, not as an input Vars: BDAcctEquity(0), // Beginning Day Equity CurAcctEquity(0), // Current Equity AcctNetProfit(0); // Acount Net Profit If Category{stock or futures or option...}=0 or Category=12 then begin BDAcctEquity = GetBDAccountEquity(AcctNum); {Get Beginning of Day Account Equity} CurAcctEquity= GetRTAccountEquity(AcctNum); {Get Real Time Account Equity} End Else If Category =2 then begin BDAcctEquity = GetBDAccountNetWorth(AcctNum); {Get Beginning of Day Account NetWorth} CurAcctEquity= GetRTAccountNetWorth(AcctNum); {Get Real Time Account NetWorth} End; AcctNetProfit = CurAcctEquity - BDAcctEquity; oNetProfitToday = AcctNetProfit; If oNetProfitToday>= EquityStopAlert and oNetProfitToday<= EquityProfitAlert then AccountEquityStop_X=True Else AccountEquityStop_X=false;

al68
Posts: 16
Joined: 25 Mar 2016

Re: Account Equity Stop or Avoid the Risk of Ruin

Postby al68 » 05 Apr 2024

Hi,
I've probably just solved the problem , but I wanna share the solution with you all and ask what you think:

Code: Select all

// AccountEquityStop_Y Input: EquityStopAlert(numeric), // Set Stop Loss Alert EquityProfitAlert(numeric), // Set Profit Target Alert AcctNum(string), // Pass Account ID: "12345.." don't forget the quotes " " oNetProfitToday(numericref); //input-output: in the strategy code you have to declare it as a variable, not as an input Vars: BDAcctEquity(0), // Beginning Day Equity CurAcctEquity(0), // Current Equity AcctNetProfit(0); // Acount Net Profit If Category{stock or futures or option...}=0 or Category=12 then begin If SessionLastBar[1] then BDAcctEquity = GetRTAccountEquity(AcctNum); {Get Beginning of Day Account Equity} CurAcctEquity= GetRTAccountEquity(AcctNum); {Get Real Time Account Equity} End Else If Category =2 then begin If SessionLastBar[1] then BDAcctEquity = GetRTAccountNetWorth(AcctNum); {Get Beginning of Day Account NetWorth} CurAcctEquity= GetRTAccountNetWorth(AcctNum); {Get Real Time Account NetWorth} End; AcctNetProfit = CurAcctEquity - BDAcctEquity; oNetProfitToday = AcctNetProfit; If oNetProfitToday>= EquityStopAlert and oNetProfitToday<= EquityProfitAlert then AccountEquityStop_Y=True Else AccountEquityStop_Y=false;


Return to “MultiCharts”