Reply

‘What If’ Max simultaneous open trades

9 replies

huangwh88

Customer, bbp_participant, community, 113 replies.

Visit profile

4 years ago #250795

Hi,

Does anyone have a snippet for ‘what if’ that allows me to limit the max number of simultaneous open trades in a portfolio?

0

hankeys

Customer, bbp_participant, community, sq-ultimate, 487 replies.

Visit profile

4 years ago #250796

what for? because you will not be albe to trade that way without some tool

You want to be a profitable algotrader? We started using StrateQuant software in early 2014. For now we have a very big knowhow for building EAs for every possible types of markets. We share this knowhow, apps, tools and also all final strategies with real traders. If you want to join us, fill in the FORM.

0

huangwh88

Customer, bbp_participant, community, 113 replies.

Visit profile

4 years ago #254666

what for? because you will not be albe to trade that way without some tool

easy to code into your EA.

0

hankeys

Customer, bbp_participant, community, sq-ultimate, 487 replies.

Visit profile

4 years ago #254671

to a single strategy yes, for the whole portfolio could be done as another separate EA

but your trading will be different from the backtest, what to do with the pending orders? many other questions…

You want to be a profitable algotrader? We started using StrateQuant software in early 2014. For now we have a very big knowhow for building EAs for every possible types of markets. We share this knowhow, apps, tools and also all final strategies with real traders. If you want to join us, fill in the FORM.

0

peter

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

Visit profile

3 years ago #259614

Did anyone get a solution to this?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

3 years ago #259651

Hello,

this actually does not make too much sense to limit max open positions in portfolio considering you manage risk properly per strategy. You need as many trades as possible to make $ right. Meaning I would avoid doing this any way possible. From historical backtest you can see quite clearly the maximum number of open positions that happened in time and you can build on that information .

0

peter

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

Visit profile

3 years ago #259668

forgive me if i am wrong but i would disagree on the bases that is you have a simple brake out strategy that runs on multiple pairs.

and lets say that value of the usd drops this EA will then potentially put you in to a position to express USD weakness in multiple markets. so you would effectively have the same trade just on different markets and you would be increasing your exposure to the same idea ‘USD weekness’

where i would like to limit it so it only expresses USD weakness in the first market to brake out.

0

stearno

Customer, bbp_participant, community, 379 replies.

Visit profile

2 years ago #270585

And if you have a MM rule that says you your account balance cannot be lower than x%.  To regulate that, you could do it through max number of open trades.  To which is easy to code into the EA, but cannot be backtested.  That is why it would be nice to have the snippet to be able to backtest these conditions.

0

stearno

Customer, bbp_participant, community, 379 replies.

Visit profile

2 years ago #270586

I just saw there is a Correlation type in the Quant Editotor for number of open trades.  I don’t know if you can modify it to fit a What-If Analysis

 

package com.strategyquant.extend.CorrelationOf;

import com.strategyquant.lib.correlation.CorrelationType;
import com.strategyquant.lib.language.L;
import com.strategyquant.lib.results.SQOrder;
import com.strategyquant.lib.results.SQOrderList;
import com.strategyquant.lib.time.TimePeriod;
import com.strategyquant.lib.time.TimePeriods;

public class NumberOfOpenTrades extends CorrelationType {

public NumberOfOpenTrades() {
name = L.t(“Number of open trades”);
dataType = DATA_TYPE_TRADES;
}

@Override
public void computePeriods(SQOrderList orders, TimePeriods timePeriods, int period) throws Exception {

for(SQOrder order : orders) {
if(order.isCanceledOrder() || !order.isMarketOrder()) {
continue;
}

for(TimePeriod timePeriod : timePeriods) {
if(timePeriod.from<order.CloseTime && timePeriod.to >= order.OpenTime) {
// trades overlap
timePeriod.value++;
}
}
}
}
}

0

stearno

Customer, bbp_participant, community, 379 replies.

Visit profile

2 years ago #270966

I posted the snippet code at this forum post for limited max number of trades open at one time:

https://strategyquant.com/forum/topic/snipped-for-whatif-allow-max-simultainios-trades-per-instrument/

 

Happy trading.

0

Viewing 9 replies - 1 through 9 (of 9 total)