Hi,
I had a working strategy with a fixed percent exit ("percloss") based on the entry price. I wanted to replace that with an exit based on the following two conditions:
Exit at market if:
1. The closing price falls below: entry price - ATR * ATRxEntry, where ATR is the aver. true range and ATRxEntry is the parameter to be specified in the program, e.g. 1.
OR
2. The closing price falls below: highest price over a 50 day period - ATR * ATRxTrail, where ATRxTrail is the parameter to be specified in the program, e.g. 1.
The code as shown below, is incorrect: it exits the next day after a position is established. One obvious error, which I am unsure how to fix is due to the function Highest.Series( High, 50 )[bar], which on entry looks back 50 days. In reality it should gradually build up to 50 starting from 0.
Here's the trading loop of the program:
CODE:
Please log in to see this code.
Questions:
Can you suggest a function instead of Highest.Series( High, 50 )[bar] to fix the problem?
What debugging tools can be used in WL-Pro? something like write/print would help.
Thanks.