I am trying to figure out how to create multiple Long orders in one script.
For example, I put together one script that has 3 buy / sell conditions, and I would like each to have it's own entry / exit parameters. Figuring out how to order multiple Long entries in one script is my current obstacle.
There is currently a "Main", a "Fast" and a "Vol" strategy.
No matter what I try, each of these work by themselves but when run together whichever one is fastest essentially runs everything. Maybe one out of 100 times a lower one will slip through, and then sometimes a different strat will Sell / go long on that trade instead of letting the strat that bought it determine when to sell it.
Things I've tried includes nested loops and also strategy.oca groups. I've been reviewing documentation but none of them demonstrate my scenario--the scenarios I found were multiple entries with one big exit. I want each strat to enter and exit on it's own. I have pyramiding on at 3. I've tried using Strategy.position_size == 0 entries as well as trying to add a variable to stop a conditional from ordering if it already has an order but nothing I've tried works.
If it matters, I will not be using any margin.
if OrderLong and not OrderShort
strategy.cancel(id="Sell")
strategy.entry(id="Buy", long=true, comment="Buy") //strategy.entry(id="Buy", long=true, stop=high, comment="Buy", limit=(OrderLimit))
if OrderShort and not OrderLong and not OrderShortFast
strategy.cancel(id="Buy")
strategy.exit("Sell", "Buy", stop=low, limit=(OrderLimit),comment="Sell")
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if OrderLongFast and not OrderShortFast
strategy.cancel(id="SellFast")
strategy.entry(id="BuyFast", long=true, comment="Buy Fast") //strategy.entry("BuyFast", long=true, stop=high, comment="Buy Fast", limit=(OrderLimit))
if OrderShortFast and not OrderShort
strategy.cancel(id="BuyFast")
strategy.exit("SellFast", "BuyFast", stop=low, limit=(OrderLimit),comment="Sell Fast")
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if OrderLongVol
strategy.cancel(id="SellVol")
strategy.entry(id="BuyVol", long=true, comment="Buy Vol") //strategy.entry("BuyFast", long=true, stop=high, comment="Buy Fast", limit=(OrderLimit))
if OrderShortVol
strategy.cancel(id="BuyVol")
strategy.exit("SellVol", "BuyVol", stop=low, limit=(OrderLimit),comment="Sell Vol")