- ago
I am having the Sell after N Bars Block issuing sell orders after 1 bar instead of waiting until 3 bars to issue the market sell order when I run the strategy in the strategy monitor. It runs fine in backtesting, but every time I run the strategy it is issues market sells for every order that was placed this morning, it doesn't seem to be looking up the original entry bar from my existing positions.

This is with Ameritrade as the broker, it doesn't appear to be giving the entry bar as today?

0
283
9 Replies

Reply

Bookmark

Sort
- ago
#1
Can you post the code or a screenshot of the Blocks?
0
- ago
#2


CODE:
   }          condition0 = false;          {             condition0 = true;          }          if (condition0)          {             foreach (Position foundPosition0 in OpenPositions)             {                if (idx - foundPosition0.EntryBar + 1 >= Parameters[8].AsInt)                {                   ClosePosition(foundPosition0, OrderType.Market, 0, "Sell after # bars");


There are the screenshots of the code and the block that backtest (the screenshot above was the strategy input for parameter 8 of 3 bars), but issue next day market orders on a daily scale in Ameritrade.
0
- ago
#3
There seem to be at least 9 parameters. Are you sure there's no overlooked Sell At Market block, for example?
0
- ago
#4
No, the two other sell blocks are profit target (limit) and trailing stop block (limit), The Backtest position results all hold for the 3 day (bar) timeframe unless the profit or stop limits are reached, so I'd expect the strategy to run live the same way, but I can't get the market sell order to wait 3 bars to sell in this past 1-2 weeks with TD Ameritrade. I utilized these same sell codes from the blocks two weeks ago successfully live trading, so I'm not sure if something changed in one of the recent updates that affected this?
0
Glitch8
 ( 12.10% )
- ago
#5
It sounds like the backtest hypothetical trades are not synchronized with your actual live positions. Just look at the Backtest Positions list to double check.
0
- ago
#6
CODE:
{ if (idx - foundPosition0.EntryBar + 1 >= Parameters[8].AsInt) { ClosePosition(foundPosition0, OrderType.Market, 0, "Sell after # bars");

Being that this code results in "foundPosition0.EntryBar + 1".
Would this cause peeking and be the reason it does implement correctly in live trading?
0
- ago
#7
No. What is the data loading range?
0
- ago
#8
For the strategy monitor is 500 bars, for backtesting it's 10 years
0
- ago
#9
I will email the strategy over when I get home tonight to see if you guys can see what I may have done wrong.
0

Reply

Bookmark

Sort