Hi Everyone,
I'm trying to add Risk and R-Multiples to the TradeList. I've looked
at the example using MaxLossPercent to add r-multiples and that is
pretty straight forward. However, my risk per trade is based on some
multiple of the ATR. So I put the risk points per trade in an array,
then I tried using the addtocomposite and Foreign functions to get
this array to the backtester section, but it seems that all the data
is zero when it gets to the backtester. Is there any other way to
make this array holding the risks per trade available to the
backtester to output this for each trade?
Here's some of the code:-
Risk = 2.5 * ATR(14);
i = 0;
MSL = 0;
for( bar=1; bar < BarCount; bar++)
{
if (Buy[bar] == 1 OR Short[bar] == 1)
{
MSL[i] = Risk[bar];
// _TRACE("MSL = " + MSL[i]); //this outputs correct values
i++;
}
}
AddToComposite( MSL,"~MSL","V", atcFlagDeleteValues |
atcFlagEnableInBacktest); // if i plot this it looks fine
...
if(AAAction == actionPortfolio)
{
MSL = Foreign("~MSL", "X",0);
_TRACE("MSL=" + MSL[0]); // this output 0 for every index in the
array
...
}
Nick