I don’t think my coding idea can work with STOP orders and Renko bricks. With Renko brick sizes you would simply always be placing a STOP order at the closest level for the smallest brick.
Hi all,
I have read this thread with great interest, but unfortunately, I can’t find exactly what I’m looking for. I have three strategies, A, B, and C, which are quite similar. I want up to two of the strategies to be able to take a position but not all three at the same time (as it would result in too big exposure). Does anyone know how this can be solved?
Hi. Try this
Mods edit: link edited out
DEFPARAM CUMULATEORDERS = true
once trade=0
IF YourTradeIdeaA and trade<=2 THEN
BUY PositionSize CONTRACT AT MARKET
trade=1
ENDIF
IF YourTradeIdeaB and trade<=2 THEN
BUY PositionSize CONTRACT AT MARKET
trade=1
ENDIF
IF YourTradeIdeaC and trade<=2 THEN
BUY PositionSize CONTRACT AT MARKET
trade=1
ENDIF
JSParticipant
Senior
Hi,
To count the number of transactions use:
Trade=Trade+1
Thank you so much, ProfitAlgos. This solved the entire challenge!👍🎯
Moderation point: please don’t add link to a marketplace product in a proorder topic when it’s irrelevant to the topic, keep such links to relevant store dedicated topic in the “general trading discussions”, thanks. Link has been edited out.
Glad, it worked out for you 😊
Hmmm… that was probably a bit of a hasty judgment on my part. I also tried to include Trade=Trade+1 to count the number of transactions, as JS suggests, but then it doesn’t take a position. Should Trade=Trade+1 replace Trade=1, or how should the script look?
JSParticipant
Senior
Swap “Trade=1” for “Trade=Trade+1″…
Like this
DEFPARAM CUMULATEORDERS = true
once trade=0
IF YourTradeIdeaA and trade<=2 THEN
BUY PositionSize CONTRACT AT MARKET
trade=trade+1
ENDIF
IF YourTradeIdeaB and trade<=2 THEN
BUY PositionSize CONTRACT AT MARKET
trade=trade+1
ENDIF
IF YourTradeIdeaC and trade<=2 THEN
BUY PositionSize CONTRACT AT MARKET
trade=trade+1
ENDIF
Thanks to those who have provided comments and scripts on how to combine multiple strategies into one. It works well and is very useful!
An even better solution might be if each strategy could be started separately (as standalone strategies instead of all being combined into one), otherwise, you would have to stop all of them if you want to make a change to one of the strategies. Does anyone know if it’s possible to add to each strategy’s script that it should go long if the number of long contracts on my account is a maximum of x, and otherwise not?
No, we can’t do that, each strategy has to operate in isolation and cannot receive information from outside the strategy code etc.