edit: Why is this topic created (moved?) to Bug Reports?
I don't think so that the platform is offering such feature. However with coding (automated strategy) you can achieve this.
You could run a strategy that does nothing but checking for orders without SL, and if it founds one, it sets the SL level based on % of the (initial) account balance.
Here is a code snippet from a strategy that does this:
private double accountStartBalance;
private double SLInCurrency; // SL in account currency
private static HashMap<Currency, Instrument> pairs = new HashMap<Currency, Instrument>();
@Configurable("Instrument")
public Instrument selectedInstrument = Instrument.EURUSD;
@Configurable("Stop Loss Percent")
public int stopLossPercent = 10;
private void initializeCurrencyPairs() {
pairs.put(Currency.getInstance("AUD"), Instrument.AUDUSD);
pairs.put(Currency.getInstance("CAD"), Instrument.USDCAD);
pairs.put(Currency.getInstance("CHF"), Instrument.USDCHF);
pairs.put(Currency.getInstance("DKK"), Instrument.USDDKK);
pairs.put(Currency.getInstance("EUR"), Instrument.EURUSD);
pairs.put(Currency.getInstance("GBP"), Instrument.GBPUSD);
pairs.put(Currency.getInstance("HKD"), Instrument.USDHKD);
pairs.put(Currency.getInstance("JPY"), Instrument.USDJPY);
pairs.put(Currency.getInstance("NOK"), Instrument.USDNOK);
pairs.put(Currency.getInstance("NZD"), Instrument.NZDUSD);
pairs.put(Currency.getInstance("SEK"), Instrument.USDSEK);
pairs.put(Currency.getInstance("SGD"), Instrument.USDSGD);
}
// This function is calculating the value (in currency) of pipCount pips, using the given amount (orderAmount) for the given instrument.
private double pipValueInCurrency(Instrument instrument, double pipCount, double orderAmount) throws JFException
{
double profit
, transitionalPrice
, buyPrice
, sellPrice
, payedAmount
, soldPrice
, soldAmount
, profitInInitialCurrncy;
Instrument transitionalInstrument;
// multiple up orderAmount
orderAmount *= 1000000;
buyPrice = history.getLastTick(instrument).getAsk();
sellPrice = history.getLastTick(instrument).getBid();
payedAmount = buyPrice * orderAmount;
soldPrice = (buyPrice + (selectedInstrument.getPipValue()*pipCount));
soldAmount = soldPrice * orderAmount;
profitInInitialCurrncy = soldAmount - payedAmount;
//If second currency in the instrument is account currency, then print amount difference
if (instrument.getSecondaryCurrency().equals(account.getCurrency()))
{
profit = soldAmount - payedAmount;
//If primary currency in the instrument is account currency, sold instrument secondary currency to buy primary(account) currency
}
else if (instrument.getPrimaryCurrency().equals(account.getCurrency()))
{
profit = (soldAmount - payedAmount) / sellPrice;
// Secondary instrument is USD, convert to account currency.
//If secondary currency is USD, get instrument from map by account key and buy account currency.
}
else if (instrument.getSecondaryCurrency().equals(USD))
{
transitionalInstrument = pairs.get(account.getCurrency());
transitionalPrice = history.getLastTick(transitionalInstrument).getBid();
profit = profitInInitialCurrncy * transitionalPrice ;
// Secondary instrument is not USD, must convert to USD, then to Account currency
//If secondary currency not equal to USD, and primary or secondary currency not equal to account currency. Then get transitional instrument from map, if USD is a primary currency in the instrument then divide profit to bid price, if USD is a secondary currency in the instrument, then multiple profit to bid price.
}
else
{
transitionalInstrument = pairs.get(instrument.getSecondaryCurrency());
Currency workInstrumentSecondaryCurrency = instrument.getSecondaryCurrency();
// USD is primary currency in transitional instrument
if (transitionalInstrument.getPrimaryCurrency().equals(USD))
{
// Sell Primary(USD) currency
transitionalPrice = history.getLastTick(pairs.get(workInstrumentSecondaryCurrency)).getBid();
profit = profitInInitialCurrncy / transitionalPrice;
}
// USD is secondary currency in transitional instrument
else
{
transitionalPrice = history.getLastTick(pairs.get(workInstrumentSecondaryCurrency)).getBid();
profit = profitInInitialCurrncy * transitionalPrice;
}
}
return profit;
}
public void onStart(final IContext context) throws JFException {
accountStartBalance = context.getAccount().getBalance();
SLInCurrency = accountStartBalance * (stopLossPercent*0.01);
initializeCurrencyPairs();
}
public void onMessage(IMessage message) throws JFException {
IOrder anOrder;
double price
, slPrice
, aPipValue
, stopLossInPips;
switch(message.getType()) {
case ORDER_FILL_OK:
anOrder = message.getOrder();
if (Double.compare(anOrder.getStopLossPrice(),0) == 0) {
price = anOrder.getOpenPrice();
aPipValue = pipValueInCurrency(selectedInstrument, 1, anOrder.getAmount());
stopLossInPips = SLInCurrency / aPipValue;
if (anOrder.isLong())
slPrice = price - stopLossInPips*tickSize;
else
slPrice = price + stopLossInPips*tickSize;
anOrder.setStopLossPrice(slPrice);
anOrder.waitForUpdate(2000);
}
break;
}
}