Can Automated limit and stop orders be set for moves less than 1%?
Author: topcat77
Creation Date: 9/12/2008 4:22 PM
profile picture

topcat77

#1
I installed the bracketed exit routine ( OCO limit and stop orders) that Eugene helped me with but wheraeas all my entry orders autoplaced none of the bracketed orders showed up. For info, my system trades 1 min bar signals and looks to exit before 1% moves in either direction ( so I need to place limits/stops at 0.5%/0.7%, for example) I combed through all the literature and could not find any requirement that limit or stop orders need to be set above 1% or in whole numbers. Could this be the source of the problem?
profile picture

Cone

#2
Of course not. If the orders don't show up it's probably because those statements aren't being executed.
profile picture

topcat77

#3
Ok, that's good to know
here is my script; would be grateful if you could diagnose which statements are not being executed and point me in a direction to correct them

The limit/stop parameters for the securities that this script points to are:
Profit target : 0.50%
Stop: 0.70%
Trigger for trailing stop: 0.35%
at which, move stop to (close minus 100% of profit) - that is, move stop to entry price:

CODE:
Please log in to see this code.



profile picture

Eugene

#4
But wait, you got the entry signal commented out.
profile picture

topcat77

#5
Thanks, but I've compared the script you posted on 9/9 (1:52pm) line-by-line, comma-by-comma, bracket-by-bracket and (save for the final line BuyAtMarket..
which appears on two lines in yr script) I cannot find where/how I've got the entry signal commented out. (you can tell I'm new at this, but eager to learn) Please point me to the line that needs correcting.(Incidentally, all my entry orders have autoplaced correctly with this script)
profile picture

Eugene

#6
CODE:
Please log in to see this code.

This is where the entry is commented.
profile picture

topcat77

#7

so moving the ..BuyAtmarket...part of the line down will solve the problem?

like this in your script?

CODE:
Please log in to see this code.




or do I remove the two forward slashes from the beginning of the line altogether?

Also, for my understanding, why did this allow the entry orders to autoplace but not the stop and limit orders ?
profile picture

Eugene

#8
QUOTE:
or do I remove the two forward slashes from the beginning of the line altogether?


This will be two different scenarios. Leaving the condition commented will not allow for historical signals to appear on the strategy's chart because alert is generated on the last bar only.

QUOTE:
Also, for my understanding, why did this allow the entry orders to autoplace but not the stop and limit orders ?


This code should not let entries autoplace, so the reason is elsewhere.
profile picture

topcat77

#9
so am I back to square one ?
profile picture

topcat77

#10

ok after your last comment I went through and checked the strategy codes for all the autoplace strategies I used last week and found (red-faced ) that two were "commented" the others were not.That explains why I have twenty-odd autoplaced trades but I'm back to my original dilemma
profile picture

topcat77

#11
Eugene, what can I do as a next step to get my exits to work ?

Could it be my settings ?

This is what I do:
1)I organize three data-sets, each containing securities of a different volatitility class
2) I activate two strategies toward each data-set - one long, one short; except for their direction, each set is identical
3) each set of two strategies differs from the other sets only: for the parameters used to assess the entry signal ( minimum rsi difference etc, contained in the "if" statements at the end of the script) and for the parameters contained in the exit rules, also numerical
4) my strategies are named by series eg, Coastal5, Coastal5.1, Coastal5.2 etc
5) whenever I make changes I always de-activate and reactivate the strategy
6) I have ticked off all the subsets in the Advanced Options section of the Preferences list to do with Strategy

I am test-driving WL to see how it handles a suite of pattern-recognition programs for the fund I run. So far I'm impressed. During this period I am trading in only seven securities for the 1-minute-bar program and during the past two weeks or so I have seen about 10 trades a day autoplaced; for each, I enter exits manually. This is still risky b/c the exits can happen within minutes.I expect that when my security list is fully populated it could (should) see upwards of 50 trades a day (each seeking a small, finite return)in a manner that resembles high-frequency algorithmic trading. This is why I have an urgeny to complete the development of this program.

(The larger, daily-bar program the Cone helped me with, scans about 2000 securities, is in month-four of trading and could also benefit with programmed exit rules,only for analytical insight, but these can wait b/c holding periods are days not minutes)

Am I right in assuming that one way to tell if the exit routine is working is that a back-test will perform correctly?
This is not currently the case

I have gone through my scripts minutely (with my untrained eye). If this helps, there is a a little red error-squiggle under the end of each of the
perecent inputs for profit-limit/stop/trailing-stop trigger etc going onto the adjacent bracket( eg (1-.041/100.0d) ) which says "semicolon expected"

All your help is and has been much appreciated


profile picture

Eugene

#12
QUOTE:
5) whenever I make changes I always de-activate and reactivate the strategy

Make changes to what, the strategy code? As far as I remember, de-activating a strategy shouldn't affect the Strategy Monitor as it always works with its own stored copy of the strategy.
QUOTE:
If this helps, there is a a little red error-squiggle under the end of each of the
perecent inputs for profit-limit/stop/trailing-stop trigger etc going onto the adjacent bracket( eg (1-.041/100.0d) ) which says "semicolon expected"

This squiggle is all right, ignore it.
QUOTE:
Am I right in assuming that one way to tell if the exit routine is working is that a back-test will perform correctly?
This is not currently the case

Depends on the definition of the word "correctly". In programming, there's a chance for logic errors - look what Wikipedia has to say about it:

QUOTE:
In computer programming, a logic error (sometimes called a semantic error) is a bug in a program that causes it to operate incorrectly, but not to terminate abnormally (or crash). A logic error produces unintended or undesired output or other behavior, although it may not immediately be recognized as such. (...) Unlike a program with a syntax error, a program with a logic error is a valid program in the language, though it does not behave as intended.
profile picture

topcat77

#13

Comparing the code above to the pre-made code in Entries and Exits for "Long Exit
at Profit Target with Fixed stop and Trailing Stop" again, I noticed that the line
that says : Plot stops ()

CODE:
Please log in to see this code.


does not appear . Could this be why bracketed orders are not executing in my program?
Is so, where does that line belong within the code above?

profile picture

Eugene

#14
PlotStops() is there for visualizing purposes - just hit F1 with the text cursor pointing at the method to pop up the QuickRef.
profile picture

topcat77

#15
Thank you
then I'm still looking for the reason why the exits in this script will not execute
when all the initial entries autoplace perfectly. Any ideas will be v welcome
profile picture

Eugene

#16
1. If you're running the same strategy in Strategy Monitor, keep in mind that edits do not affect the activated strategies until the tool is closed and re-opened.
2. No indication of what you did to the entry line. As said above, commenting and leaving the condition will result in two different outcomes. You need to realize it, taking the line from a strategy that supposedly looks like a Scan (Screen), and combining it with other conditions within a regular trading Strategy.
profile picture

topcat77

#17

1. In response, I turned the Strategy monitor off and on; deactivated all strategies and
reactivated them;and for good measures sake uninstalled and reinstalled WL 5.1
2 Entry line:
CODE:
Please log in to see this code.


same result - all entries autoplace, the exits don't show up.

When the entries autoplace they all say "Group1 |" like in the script.
If I run this strategy through a backtest, both "trades" (and therefore "performance") show as zeros
I assume that this is b/c there is no exit with which to compute performance measurement; i.e if there was
an entry-only strategy the backtest would not mark the open long positions to market and
count this this as "performance" - is this correct?

I am willing to re-write the script from scratch if you think this will help. Or try anything else.




I'm willing to start from scratch ( rewrite the script) if you think this could help

profile picture

Eugene

#18
QUOTE:
If I run this strategy through a backtest, both "trades" (and therefore "performance") show as zeros
I assume that this is b/c there is no exit with which to compute performance measurement; i.e if there was
an entry-only strategy the backtest would not mark the open long positions to market and
count this this as "performance" - is this correct?

This "if" condition in your code instructs Wealth-Lab to create an entry on the last bar (only). There will be zero trades in the history. If you remove the condition, the strategy becomes backtestable.
profile picture

topcat77

#19
Bingo !
I commented the if statement and put BuyAtMarket..... on the next line and
that cleared up all the issues;
it has allowed the EXITS to execute and the backtests to work
Thanks v m for staying with this
For my understanding, though, why would the earlier format (above) block the Exits from executing?