reverseLong/Short side effects

Posted By: Sphin

reverseLong/Short side effects - 07/02/17 17:41

Examining some strange behaviour of a script I read following in the remarks of the enterLong-etc-page in the manual:

Quote:
reverseLong/Short are helper functions ... If Stop, TakeProfit, or ExitTime is used, open trades in the same direction are updated with the new stop loss and take profit values ...

Unlike enterLong/Short Stop and TakeProfit seem to influence also open trades. If I have:

Code:
int TMF() {
  // modify Stop/Takeprofit if some conditions are met
}

function run() {
  ...
  Stop = 250 * PIP;
  TakeProfit = 550 * PIP;

  ...
  reverseLong(1, TMF);
  ...
  reverseShort(1, TMF);

}


Will Stop and TakeProfit be (re)set to the values from the run function (250/550 * PIP) each run if not modified by the TMF?
Posted By: jcl

Re: reverseLong/Short side effects - 07/03/17 09:44

Yes, in fact those side effects are the main reason for the reverse functions. When a trade signal is triggered, but no new trade is opened since the maximum of trades is already reached, you normally want to update their stop and profit targets to the current price level. So they behave as if just opened.

If this is not desired, then simply use something like if(NumOpenLong < MyLimit) enterLong(); instead of the reverse functions.
© 2024 lite-C Forums