Activate Stops Immediately

Hi,

I see the check box in the Back Tester under the "Stops" tab, "Activate Stops Immediately..."

Can this option be controlled from within the code so that I can have a StopLoss triggered immediately (same bar) after entering on the Open but allow a Profit Target to be executed next bar?

Thank you,

Mike

ApplyStop(Type=0,Mode=1,Amount=StopLoss,ReentryDelay=2);
ApplyStop(Type=1,Mode=1,Amount=Target);

See SetOption function:

SetOption("ActivateStopsImmediately", True);

BTW, your ApplyStop code is incorrect. ReentryDelay is at 6th position.

ReentryDelay=2;
ApplyStop(stopTypeLoss, stopModePercent, StopLoss, 1, False, ReentryDelay);

Thanks for the correction on the ReentryDelay positioning.

If I set the Option as you suggest, both the Stop Loss and Profit Target are executed immediately. Can the Option be conditioned to be True for a Stop Loss and False for a Profit Target?

Thanks,

Mike

Have you tried ValidFrom setting of ApplyStop?
I have posted link to ApplyStop manual in upper message.

AFL Function Reference - APPLYSTOP

ValidFrom -
defines first bar since entry when stop can generate an exit. 0 means from the very beginning

fxshrat...Thank you!..Worked perfectly!!...Mike

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.