by December 20, 2019 in Python
onIndent four spaces after an if statement.
if x ==1:
++++4x = 2
Let’s break down the above code: Always test the current bar’s high or low against the signal trigger price. If the extreme of the bar exceeds the level then you know you were filled. In TradingSimula18 you are sitting on the close of current day and can look back and see what happened during the day. Is this future-leak? It is, but it’s ok as long as you know it and don’t cheat. The beauty of TS-18 is that it does exactly what you tell it today. The trade election is not determined by the computer – it is decided by the user. Once you determine if a signal has been triggered it us up to you to tell the computer what price you were filled at. If you are testing a stop order then you must check the open price to make sure the open didn’t gap through your price. If it did, then its up to you to assign the price the open of the day. Then all you do is assign a name to the trade and the numShares to be executed. The rest is just minutiae you can ignore.
Are you ready to sit down in front of your computer and start creating?