Home | Trading Alchemy Manual | Alchemy Functions IndexAlchemyDailyAccumPLEx (Function)AlchemyDailyAccumPLEx is a multiple-output function that returns true when a specified maximum daily accumulated position profit or loss is reached. This function is used in the Alchemy Daily Accumulated Profit-Loss Exit Strategy (AlchemyDailyAccumProfitLossExit). boolean AlchemyDailyAccumPLEx ( numericsimple MaximumProfit, numericsimple MaximumLoss, numericseries SessionStartTme, numericseries SessionEndTme, numericsimple ExcludeDayOfWeek, numeric EntryBar, numeric ExitBar, numericref oAccumPL, numericref oClosedAccumPL, numericref oOpenPositionPL, numericref oMaxProfitTarget, numericref oMaxLossStop ) Parameters |
Parameter Name | Parameter Type | Parameter Description |
MaximumProfit |
numericsimple |
Specifies the maximum daily accumulated position profit dollar amount at which the function returns true. A setting of 0 disables the maximum daily accumulated position profit functionality. |
MaximumLoss |
numericsimple | Specifies the maximum daily accumulated position loss dollar amount at which the function returns true. A setting of 0 disables the maximum daily accumulated position loss functionality. |
SessionStartTme |
numericseries |
Specifies the session start time for detecting the beginning of a new session and for the function to zero out the daily accumulated position profit/loss. The format of this input is in military charting time without the colon such as 1300 for 1:00pm or 13:00. With a negative setting such as -1, the function automatically uses the calendar date for the session start time. |
SessionEndTme | numericseries | Specifies the session end time for detecting the beginning of a new session and for the function to zero out the daily accumulated position profit/loss. The format of this input is in military charting time without the colon such as 1300 for 1:00pm or 13:00. With a negative setting such as -1, the function automatically uses the calendar date for the session end time. |
ExcludeDayOfWeek | numericsimple | Specifies the day of the week to exclude from a session for zeroing out the daily accumulated position profit/loss, whereas 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday and a negative setting disables this feature. |
EntryBar |
numeric | In order to correctly detect the entry bar of the strategies that are applied on the chart, this input should be set 0 when the strategies that are applied on the chart enter positions on the next bar such as with market, limit and stop entry orders. When the strategies that are applied on the chart enter positions on the close of the same bar by using this bar on close entry orders, this input should be set 1. |
ExitBar |
numeric |
In order to correctly detect the exit bar of the strategies that are applied on the chart, this input should be set 0 when the strategies that are applied on the chart exit positions on the next bar such as with market, limit and stop exit orders. When the strategies that are applied on the chart exit positions on the close of the same bar by using this bar on close exit orders, this input should be set 1. |
oAccumPL | numericref | This is an output variable that returns the daily accumulated position profit/loss. |
oClosedAccumPL | numericref | This is an output variable that returns the daily accumulated closed position profit/loss. |
oOpenPositionPL | numericref | This is an output variable that returns the open position profit/loss. |
oMaxProfitTarget | numericref | This is an output variable that returns the maximum profit target price for each position before the maximum profit threshold is reached. |
oMaxLossStop | numericref | This is an output variable that returns the maximum stop loss price for each position before the maximum loss threshold is reached. |
UsageWhen using the Alchemy Daily Accumulated Profit-Loss Exit Strategy, this function should be used in the corresponding entry strategy to prevent the entry strategy from re-entering a new position after the maximum daily accumulated profit or loss has been reached and here is an example on how to apply this function in your entry strategy code: // Declare the function variables as inputs inputs: MaximumProfit(0),MaximumLoss(0),SessionStartTme(-1),SessionEndTme(-1),ExcludeDayOfWeek(-1),EntryBar(0),ExitBar(0);
// Declare the output variables variables: oAccumPL(0),oClosedAccumPL(0),oOpenPositionPL(0),oMaxProfitTarget(0),oMaxLossStop(0);
// Define the function to test for the maximum daily accumulated position profit or loss to be reached condition1=AlchemyDailyAccumPLEx(MaximumProfit,MaximumLoss,SessionStartTme,SessionEndTme,ExcludeDayOfWeek,EntryBar,ExitBar,oAccumPL,oClosedAccumPL,oOpenPositionPL,oMaxProfitTarget,oMaxLossStop);
// If the maximum daily accumulated position profit or loss has not been reached, condition 1=false and the buy and sell short code can be placed if condition1=false then begin // place your buy and sell short code here end; |