I built a simple code with 5 minutes data for day trading,
if SMA 7 cross 21, then buy in
The position stops at 3% loss or gets out at the end of the day.
The buy part is ok, it will have the alert and stage the order
to the order tool, and then place the order and I see the order get filled.
The sell part works on the backtesting, but in the real time, when the condition met,
it does not generate the alert and no order staged. Neither 3% stop loss or at closing time.
Can anyone help look at the script and help me solve the problem? thanks.
Here is the code:
CODE:
Please log in to see this code.