ATR stop loss not working correctly
Posted: May 05 2021
Trying to use the synchronizers to manually trade with automatic exits as here: https://www.multicharts.com/trading-sof ... _at_a_Time
Yesterday I kept receiving warnings about tick to strategy calculation start lag warnings that ended up escalating to about 45 seconds until it finally automatically disabled auto trading. Today I haven't received any so who knows. Only had one workspace and three charts open while testing in only one of them. Broker was "Paper Trader." Datafeed is Rithmic.
Stop loss doesn't seem to work correctly either. Code below. Even though I can set it to 2X ATR, it stops out at only half-point loss. If ATR is about 6, then the stop should be 12 points, correct? The only three signals loaded are this, and the two synchronizers. Btw, this signal is a modified version of the "Stops & Targets" signal. I just commented out lines I didn't want to use. Thanks.
Yesterday I kept receiving warnings about tick to strategy calculation start lag warnings that ended up escalating to about 45 seconds until it finally automatically disabled auto trading. Today I haven't received any so who knows. Only had one workspace and three charts open while testing in only one of them. Broker was "Paper Trader." Datafeed is Rithmic.
Stop loss doesn't seem to work correctly either. Code below. Even though I can set it to 2X ATR, it stops out at only half-point loss. If ATR is about 6, then the stop should be 12 points, correct? The only three signals loaded are this, and the two synchronizers. Btw, this signal is a modified version of the "Stops & Targets" signal. I just commented out lines I didn't want to use. Thanks.
Code: Select all
[IntrabarOrderGeneration = true]
inputs:
ShareOrPosition( 1 ),
{ProfitTargetAmt( 5 ),}
ATRLength(14),
StopLossPct( 1 ),
{BreakevenFloorAmt( 0 ),
DollarTrailingAmt( 0 ),}
PctTrailingFloorPct( 0 ),
PctTrailingPct( 0 ),
ExitOnClose( false ) ;
variables:
StopLossAmt( 0 ),
ATR( 0 ),
PctTrailingFloorAmt( 0 );
ATR = AvgTrueRange(ATRLength);
StopLossAmt = ATR * StopLossPct;
PctTrailingFloorAmt = ATR * PctTrailingFloorPct;
if ShareOrPosition = 1 then
SetStopShare
else
SetStopPosition ;
{if ProfitTargetAmt > 0 then
SetProfitTarget( ProfitTargetAmt ) ;}
if StopLossAmt > 0 then
SetStopLoss( StopLossAmt ) ;
{if BreakevenFloorAmt > 0 then
SetBreakeven( BreakevenFloorAmt ) ;
if DollarTrailingAmt > 0 then
SetDollarTrailing( DollarTrailingAmt ) ;}
condition1 = PctTrailingFloorPct > 0 and PctTrailingPct > 0 ;
if condition1 then
SetPercentTrailing( PctTrailingFloorAmt, PctTrailingPct ) ;
if ExitOnClose = true then
SetExitOnClose ;