Hi Watanabix,
Your #1,2,3 questions are just about the Backtest report only showing at the intervals of your chart’s Timeframe. In Live (Demo too) you will see that this all works fine.
With Backtest, internally it also works fine. I mean, the profit and such are from the real “tick” crossings.
Regarding #4 I can only say that your Set Target as well as the Set StopLoss are subject to an If condition, which is not allowed. In practice (Live/Demo) this will fail just the same (as in Backtest). Just set both at the beginning or end of your program and it will work.
Keep in mind that it is not this black and white as I or formal rules tell you;
You *can* have either under a condition, but that condition should determine the price (and then be very careful what you imply with that – e.g. a changing TP each bar). You, in this case, have the TP and SL determined only once, when you buy. This is caused by the If around it.
The general rule is that such “pending” orders need to be repeated each bar (thus, each call of your code). Do notice, however, that the rules depend on the broker and that it may happen that for example, the StopLoss just needs to be given once (thus that under your condition it *would* work). But because for the real normal Pending Orders (Limit and Stop) this rule of needing to repeat for 100% sure works like that everywhere, it is best to treat the TP and SL the very same.
Notice that this is harmless, because the originating party – PRT in this case – will intelligently send a new order or not. This means : when you give such a pending order the same price as in the previous bar, nothing will be resent to the broker if only the broker will let the order stay. This is how “intelligently” comes into play, because if the broker desires to explicitly repeat the order or else it will be cancelled, then PRT will know about that, and thus repeats the order (with the same price).
All is no worry for you if yo only always repeat the orders. This means : no conditions for them.
But change the price underway (like your LO and pt) and PRT will automatically send a new order with the new price, and the old pending order will be cancelled at the broker.
Literally there is another dimension, because the order may be maintained by the Broker or by the Exchange. This, with the notice that IG is both, and IB is separate (like IBKR for broker and CME for e.g. Nasdaq Futures). This relates to the rules you can’t see. The pending order for the one instrument is maintained by the Broker, while the other is maintained by the Exchange. You, working through the same broker (like IBKR) won’t know this, unless you sorted it out. This is why you should be on the safe side, and cause Backtest to behave the same as Live later (Backtest knows nothing of brokers).
Does this help ?
Peter