| Author |
Messages |
|
maninjapan Posts:12
 |
| 02-21-2007 8:01 AM |
Alert
|
| what would be the correct code for putting in a stop loss in a dollar amount or number of tics? say for 5,000 dollars or 10 tics. And would it differ between commodities and stocks? |
|
|
|
|
maninjapan Posts:12
 |
| 02-23-2007 5:11 AM |
Alert
|
Just to further my question on stop losses. I tried the following code testing on S&P daily sample data
If tradestoday()=0 Then Buy("buyRange",1,Lo,Limit,Day) EndIf
Exitdollarstop(1000,"","",1)
ExitEOD("","",1)
All the trades exit at end of day, however the biggest loss is 17,000 dollars.
|
|
|
|
|
rdencpa Posts:10
 |
| 03-10-2007 4:58 PM |
Alert
|
| Sub testDollarStop()
If tradestoday()=0 Then
Buy("buyRange",1,LowD,Limit,Day)
EndIf
ExitDollarStop(1000,"DollarStop","buyRange",1)
ExitEOD("EOD","buyRange",1)
End sub
The code above (note modifications) works and does stop out at $1000 when tested on the 5 minute bar data.
When creating the session be sure to set the data compression to 5 minute. It is easy to miss this step as the default is daily and then the code doesn't work as expeceted. |
|
|
|
|
|