One trade per Algo

Posted By: Fiber

One trade per Algo - 07/28/17 17:27

Hi,
How can I limit only one trade/open position per Algo?
I tried
Code:
string CurrentAlgo = Algo;
for(open_trades)
if(strstr(Algo,CurrentAlgo) && !TradeIsOpen)


also
Code:
if(Algo == "TRND" &&  && NumOpenTotal == 0)


but without success.
Posted By: Dalla

Re: One trade per Algo - 07/28/17 18:42

You are making it a bit more difficult than it is I think.
NumOpenTotal is per asset/algo, so you don't need to check what algo is currently in use.

From the manual

Code:
Limit the number of open positions
// max. 3 open long positions per asset/algo
if(my_long_condition == true) {
  exitShort(); // no hedging - close all short positions
  if(NumOpenLong < 3) enterlong();
}



Or just use reverseLong/reverseShort so e.g. instead of enterLong()
use reverseLong(x) where x is the maximum number if open positions allowed.
Posted By: Fiber

Re: One trade per Algo - 07/28/17 19:55

Thank you for idea, Dalla!
I use manual almost every day and still many good ideas not discovered there for me:)
Also it seems that NumOpenLong and NumOpenShort works well to limit number of trades, but NumOpenTotal doesn't and that's why I went wrong way..
© 2024 lite-C Forums