READ-ONLY

The forum is now a read-only archive.

For bug reports & platform questions → [email protected]

Our community lives on Discord and YouTube — come join us!

Databank column always shows zero value

1 replies

Julian Gonzalez

Subscriber, bbp_participant, sq-ultimate, customer, community, 8 replies.

Visit profile

10 months ago #291831

I have created a Databank column and a template code is auto-generated calculating netProfit. I compile it and restart SQX UI. When I open the DataBank from Builder and add the column, it always shows zero value. The same happens if I download snippets from the community.

If I create a new one with just getNumericValue() and getValue() it works perfectly. So it seems that the compute() function it does nothing, why?

I already tried with 136, 142 and 143 versions. Help!

This is the template:

package SQ.Columns.Databanks;
import com.strategyquant.lib.*;
import com.strategyquant.datalib.*;
import com.strategyquant.tradinglib.*;
public class Prueba2 extends DatabankColumn {
  public Prueba2() {
    super(“Prueba2”,
          DatabankColumn.Decimal2, // value display format
          ValueTypes.Maximize, // whether value should be maximized / minimized / approximated to a value
          0, // target value if approximation was chosen
          0, // average minimum of this value
          100); // average maximum of this value
    setWidth(80); // defaultcolumn width in pixels
    setTooltip(“Your tooltip here”);
    /* If this new column is dependent on some other columns that have to vbe computed first, put them here.
       Make sure you don’t creat circular dependency, such as A depends on B and B depends on A.
       Columns (=stats values) are identified by the name of class)
    */
    //setDependencies(“DrawdownPct”, “NumberOfTrades”);
  }
  //————————————————————————
  /**
   * This method should return computed value of this new column. You should typically compute it from the list of orders
   * or from some already computed statistical values (other databank columns).
   */
  @Override
  public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception {
    /* an example – this is how you can get other values that this new value is dependent on */
    //int numberOfTrades = stats.getInt(“NumberOfTrades”);
    //double drawdownPct = stats.getDouble(“DrawdownPct”);
    /* an example – calculating net profit from the list of trades */
    double netProfit = 0;
    for(int i = 0; i<ordersList.size(); i++) {
      Order order = ordersList.get(i);
      if(order.isBalanceOrder()) {
        // don’t count balance orders (deposits, withdrawals) in
        continue;
      }
      /* method getPLByStatsType automatically returns PL depending on given stats type – in money, % or pips */
      double PL = getPLByStatsType(order, combination);
      netProfit += PL;
    }
    /* round and return the value. It will be saved into stats under the key “Prueba2” */
    return round2(netProfit);
  }
}

0

Julian Gonzalez

Subscriber, bbp_participant, sq-ultimate, customer, community, 8 replies.

Visit profile

10 months ago #291832

Solved!

It seems the compute() function only updates when you force the strategy to be backtested again (retesting it or generating a new strategy). Instead, getNumericValue() and getValue() functions does not need it.

🙂

1

Viewing 1 replies (of 1 total)