I have an initial stop for longs go below the most current swing low - 35 ticks. Then its supposed to go under the rest of the swing points - 5 ticks. In the replay it is exiting at an undesired price. Tracelog and details below. Please help.
Stop losses are initially set to the prior swing low minus 35 ticks.
Then they are set to the next swing low minus 5 ticks.
The screenshot shows the order being exited at the open of the next candle. It clearly should still be in a trade as the stop should now be below the most current swing low minus 5 ticks.
First the traceorder show the initial stop of 1.1363 (35 ticks below the swing low, correct)
Then it moves to 1.1378 (5 ticks below the swing low, correct)
Finally instead of moving the stop to the most recent swing low print, it attempts to move the stop above price to 1.3925 (incorrectly exits trade early).
The order is exited at the open of the next candle.
Trace Order:
4/4/2016 6:55:04 AM Entered internal PlaceOrder() method at 4/4/2016 6:55:04 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='L1' FromEntrySignal=''
4/4/2016 6:55:04 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='L1' Mode=Price Value=1.1363 Currency=0 Simulated=False
4/4/2016 7:00:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='L1' Mode=Price Value=1.1378 Currency=0 Simulated=False
4/4/2016 7:00:00 AM Amended stop order: Order='bda4d9d50725419b89f71dca4601bfcf/Replay101' Name='Stop loss' State=Accepted Instrument='6E 06-16' Action=Sell Limit price=0 Stop price=1.1378 Quantity=1 Strategy='FTRVSA2' Type=Stop Tif=Gtc Oco='9d7b9e8bba224047ab9b4334357329b5-7326' Filled=0 Fill price=0 Token='bda4d9d50725419b89f71dca4601bfcf' Gtd='12/1/2099 12:00:00 AM'
4/4/2016 7:00:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='L1' Mode=Price Value=1.13925 Currency=0 Simulated=False
4/4/2016 7:00:00 AM Amended stop order: Order='bda4d9d50725419b89f71dca4601bfcf/Replay101' Name='Stop loss' State=Accepted Instrument='6E 06-16' Action=Sell Limit price=0 Stop price=1.13925 Quantity=1 Strategy='FTRVSA2' Type=Stop Tif=Gtc Oco='9d7b9e8bba224047ab9b4334357329b5-7326' Filled=0 Fill price=0 Token='bda4d9d50725419b89f71dca4601bfcf' Gtd='12/1/2099 12:00:00 AM'
My setup is as follows:
The script contains a 30 minute higher time frame also. I did not find any details pertaining to barsarray or indexing for the swing indicator. Everything else however has the proper modifications for the dataseries index.
private int swingStrength = 2; //default swing strength
private int initialSwingPeriod = 1; //initial swing period
private int swingPeriod = 2; //subsequent swing period
private int spacer = 1; //space in ticks above or below swing
private int initialSpacer = 35; //ticks above or below initial swing
CalculateOnBarClose = true;
if (long entry conditions met == true)
{
EnterLong(DefaultQuantity,"L1");
double initialStop = Swing(swingStrength).SwingLow[initialSwingPeriod]-initialSpacer*TickSize;
SetStopLoss("L1",CalculationMode.Price,initialStop , false);
}
//subsequent stop modification
if (Position.MarketPosition == MarketPosition.Long)
{
double swingLow = Swing(swingStrength).SwingLow[swingPeriod]-spacer*TickSize;
SetStopLoss("L1",CalculationMode.Price,swingLow, false);
}
Comment