OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader Professional Forum
Trade Plans In Strategies
Intraday Stops
Last Activity 1/17/2022 3:59 AM
27 replies, 17231 viewings

Jump to page : 1 2
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : Intraday Stops
Posted : 1/25/2009 6:23 PM
Post #11285

I am currently working on a trade plan and would like to use a Stop Market order to exit a trade that is based on the LLV of x number of days for longs and HHV for x number of days for shorts.
For example, if I'm in a long trade, I would like to be stopped out if the intraday price goes below yesterday's Lowest Low value of say the last 3 days.
If this is possible, I'm hoping someone has cracked the code here.
Thanks in advance.
Greg

[Edited by Greg Winch on 1/25/2009 9:26 PM]

^ Top
Drew

Legend
500
Posts: 509

Joined: 6/13/2008

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/25/2009 6:43 PM
Post #11286 - In reply to #11285

would trying something like this work?

If C < LLV(L,3) Then
Signal = ExitSignal
End If
^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/25/2009 9:09 PM
Post #11287 - In reply to #11285

Thanks Drew - but I don't think that would work.
The stop level needs to be some type of virtual level that I'm not sure how to program into an OT trade plan.
The Close only indicates that the stop level was hit sometime during the trading day.
Same thing for L < LLV(L,3), I think.

[Edited by Greg Winch on 1/25/2009 9:11 PM]

^ Top
Matthew Greenslet

Idol
2000252525
Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/26/2009 12:08 PM
Post #11294 - In reply to #11285

If you want to exit when the last price has violated the prior bars 3 period lowest low value you can use C < LLV(3)[1]. This will look back 3 bars so depending on what your timeframe is set to will determine how much data is used to calculate the lowest low.

If you wanted to calculate the prior 3 daily lows on a lower periodicity timeframe then you will need to dynamically change the number of bars used in the LLV(offset) call. Since exits only start calculating after a signal has been fired it might be easier to return the desired exit level from an Indicator. This way you will not have to dynamically calculate LLV(offset)[Lookback] where lookback is equal to the number of bars in the current session + 1. We might have a function that returns the number of bars in the current session but I can not check on that at this time (running some other tests) in which case it can all be done within a stop instead of an Indicator + Stop.

If you are on a intra-day chart you need to calculate how many X minute bars (X=SymbolData.Compression) make up 1 whole trading day. This will depend on the exchange you are trading.

If you are on a daily chart you would simply use C < LLV(3)[1]

For an example of how to tell what periodicity you are on (minute, Daily, Weekly) take a look at the floor pivot indicator under the OT09 Base Indicator sticky thread.
^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/26/2009 5:32 PM
Post #11300 - In reply to #11294

Hi Matthew:

I think what he was asking (or, at least, what I'd like to know) is:
How to code an exit that executes DURING the day, WHEN the intraday price hits the LLV(n prior days).

It would not be related to the Close of the daily bar, nor directly related to the Low - rather, it would fire sometime during aday in which the daily L was less than the LLV.
The exit would not be AT the low, but at the LLV value.

It prob is necessary for user to have intraday data to do this (your response implied that). However it should not be necessary, since it's a simple stop market or stop limit type of order.
I guess I still don't understand how to "program into" TP's.

I hope I'm wrong, and that there is a neat easy way to do this very common task, usinf EOD data.

Thanks as always!
^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/26/2009 8:14 PM
Post #11302 - In reply to #11300

Thanks Jim. You just hit the nail on the head.
For backtesting, forward testing or real trading using end-of-day data, there should be a method of determining a Stop Market order to execute during the following trading day.
I'm still not sure if Matthew has answered this for me/us.

For trade plans to work for end-of-day users, one should be able to set a stop that would trigger during the course of the day.

I know this can be accomplished in Trade Plans using the Stop Market Order with the price being a percent or points or ATR above or below the high of the previous day, low of the previous day, etc. but not for HHV or LLV of x number of days in the past.

I'm being redundant, but I think this is essential to the trading success of those us us with day jobs outside the world of the Markets.
^ Top
Buffalo

Elite
500100
Posts: 603

Joined: 7/11/2007
Location: Braintree, MA

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/26/2009 8:21 PM
Post #11303 - In reply to #11302

I agree with both of y'all - I am stuck using a pre-set stop level each day (set before the market opens based on yesterdays C, H, L whatever) OR using a cumbersome, unelegant, over-simplified trailing stop via the broker (which doesn't accomplish what I want).

What you describe would be VERY good, and help me grab more profit/stem losses (mostly giving back profits), while I toil away at my day job.
^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/26/2009 8:51 PM
Post #11304 - In reply to #11303

I also believe Jim Dean's post #11301 is relevant to this discussion:

"The *only* tricky thing to using daily bars for intrday entries/exits in backtesting is related to whether the H or L occurs first.
There is a neat solution to this that at least two other BT engines use, and OT could use - so that it would better simulate real-life trading.
I posted the explanation for this earlier today in another thread. Nutshell: use relative distance of O to H and L to determine which comes first.
By doing this, an intraday entry on that bar (per discussion above) can be logically coordinated with a stop that is immediately placed on the same bar.
Depending on whether the H or L comes first, either the stop fires or it doesn't (presuming extreme of day violates the stop.)"

In the case of LLV or HHV stops the above may not matter unless both a profit stop and a loss stop could be hit on the same bar. But for backtesting purposes, I think something of this nature is important.

OT is a great program with great goals for its users. My feeling is one could have any number of Trading Systems that pinpoint excellent opportunities to enter a trade but without Trade Plans that are customizable like mentioned above, are not really usable in real "end-of-day" trading.

^ Top
Matthew Greenslet

Idol
2000252525
Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/27/2009 11:23 AM
Post #11315 - In reply to #11285

You have to think of the root construction of a stops as two properties. One that contains a floating point number which is our calculated exit level and one that is a boolean (true/false) that tells us if need to fire the exit.

In OmniLanguage you set your ExitLevel property like this...

ExitLevel = nSomeSingleValue

Your boolean FireExit property is set by setting the current signal to an exit like this...

Signal = ExitSignal

When you write your stop code it is your responsibility to set these two properties and keep them in sync. However there is one rule in particular that you have to follow and that is, you can not change the value of your Exit Level intra-bar. Only on the next bar will the last change made to your ExitLevel property take affect.

One other behavioral note. The vote line handles stop level slightly differently than trade plans. With a Trade Plan your exit is checked everytime new data is received whether it be new ticks in RT or On-Demand downloading in EOD. This way exits are fired as soon as they are met giving us the ability for intra-bar virtual stops (that is the broker is unaware of the exit level since it is not a broker stop).

From a vote line perspective we have two paths. One where the exit has a known exit level (use of ExitLevel = nSomeSingleValue is not required) and one that doesn't. We can not do any exit calculation except on the one bar where our FireExit property is set (you have set Signal=ExitSignal). On that bar if our ExitLevel property has not been set then we then we assume the close of the bar. Since that order can not be sent until the close of the bar (to ensure our signal does not disappear) our exit fires at the first tick (open) of the next bar.

If we have set an exit level we first check it against the open. If the exit level was violated at the open we use the open price for the simulated exit price. If the ExitLevel is outside the range of the bar it treats it the same as if there was not exit level. If the exit level is within the range of the bar it always uses the exit level as the simulated exit price.

One think you need to know before understanding how the trade plan is processes is that each tick (or data update) the current bars close price is updated. This continues until we receive the first tick of the next bar.

A trade plan is not tied to the analysis in any way. Therefore it does not require analysis to be ran in order for it to update. A trade plan is analyzed each tick (or data update). Nothing is transmitted to the broker until the FireExit property = true. At the moment the FireExit property = true it will fire off the chosen order type to the broker. There is one exception to this rule which is level based orders tied to a virtual level but we can cover that later.

That said, from a trade plan perspective you can use either the C < LLV(3)[1] Or you can use L < LLV(3)[1]. Either one will return true as soon as the price ticks below your level (at least in real time). In EOD it would be possiable to update data and the low tick below your exit level but the close is still above it. If you used the close price in your conditional to set your FireExit property, in this case the Trade Plan would not fire the order to your broker since the FireExit boolean is still set to false. If you wanted to fire intra-bar stops and you want to avoid this, use the low since this will return true as soon as data is received that violates your your.
^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/27/2009 8:08 PM
Post #11326 - In reply to #11315

Matthew,
I have read your post 3 times. I really appreciate you taking the time to put together your response. Put me in the corner with a dunce cap on my head if you'd like, but I still don't know if you have answered the question (at least to my understanding).
I know very little programming. The answer may be in the Boolean or floating point numbers, etc., but in plain English, can we now or will we be able to someday set Stop Market orders to exit trades the following day at a specific level?
I am not asking to change the Exit level intra-bar...only to be able to set a stop at night (or in a backtest) at a cetain level that would get me out of trade at that specific level (price) the following day.
I apologize in advance if the answer is in your post and I'm just not getting it.
Greg

^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/28/2009 7:25 AM
Post #11329 - In reply to #11326

Excellent explanation, Matthew! Thank you!

I'm very interested to hear the rest of the story re "virtual" stops, which are mysteries in the manual (and to me). The explanation you gave below SHOULD be a part of the manual. Kudos.

I'm hoping that somehow the "virtual" stops provide a way to programmatically set the exit levels used by the Limit and/or Stop and order types. If so, then Greg's needs will be perfectly met ... OT can eval his thresholds the night before, and immediately send a (non-pre-market) Limit or Stop-Limit or Stop-Market order to the broker before the next day's open, to be applied after/at the open (depending on order type), without going through any manual EOD rigamarole described in boring detail below. MANY OF US WANT TO DO THIS!

------

To answer Greg's question ... yes, you can "set a stop at night (or in a backtest) at a cetain level that would get me out of trade at that specific level (price) the following day." BUT, barring some cool use of "virtual" stop levels that I mentioned earlier, it requires things to be done in a specific way during the next trading day, so that your backtest method matches your execution method.

Here is my understanding of Matthew's explanation, put in a bit more explicit terms for you. I trust that Matthew will correct me if I've made any errors.

For backtesting, you write a formula similar to the ones that Matthew mentioned, using the [1] syntax. That suffix tells the engine to compare the current-day's L or C to the LLV-period that ended on the PRIOR day (ie the night before).

During the backtest simulation, if you use C in the formula, the order would not fire unless the full-day's bar's Close (ie the "real" close) was below the threshold. In that case, you don't need to set an exit level, since the program will assume the Close to be the exit level. Just use the boolean C < LLV(3)[1] forumula for the signal logic ("boolean" means a true-false formula).
However, if you use L in the boolean exit-signal formula for backtesting, L < LLV(3)[1], the order will fire if the Low for the day is below the LLV(3) that was determined the night before (as you requested). In this case, however, you need to set the exit LEVEL to be equal to a scalar (single precision, numeric) value of LLV(3)[1] in addtion to boolean formula above. This will assure that the backtest simulation gets you out at the LLV price level, rather than at the Close.

-----

For actual trading, this works differently, depending on if you have a true RT feed, vs if you have an EOD feed that you manually update once a day (about 15 min before the close), vs if you have an EOD feed that you update manually many times a day (to simulate an RT feed, with built in 20-min delay plus whatever manual delay you exercise).

Caution - I am admittedly less confident of my understanding here. I don't currently have an RT feed attached to OT, and I'm not currently using OT to fire orders to my broker, and the issues with the voteline are ones that I'm not very confident about.

If you have a true continuous RT feed, then you can use EITHER boolean formula L < LLV(3)[1] or C < LLV(3)[1] to fire the signal ... probably for purity's sake the "L" formula is better. RT causes the "daily" bar to be "reconstructed" with every new tick(update) ... so, during the course of the day, there is always a full set of OHLC values present ... but since the day is not yet complete, the H, L, and C values are subject to change ... especially the C value. In this environment, it's useful to think of the intermediate C value as "R"(recent), and the intermediate H & L values as "X"(max) and "N"(min) ... I've found that if I write out logic and trading rules this way, it helps me avoid making mistakes. Anyways ... as the day progresses with the RT feed, and as the XNR values continually are updated, then the boolean formulae also continually are checked. As soon as the boolean formula's value is TRUE, then the exit signal fires, and the broker presumably uses the "close" as the exit point (presuming a Market order) ... but it's really not the real Close ... it's the "R" value I mentioned earlier.

OK, now let's presume that you don't have RT, but you do in fact manually update EOD many times each day (say, once every half hour). Keep in mind that the EOD feed is 20-min delayed, so an update at 10:00 really represents the values at about 9:40 (this is not a precise thing, btw). So, think of this as a "really slow RT feed". With that in mind, the same logic I described for the RT feed above applies here ... the XNR values "look" like HLC values every time you do an update. In this case, if your use the boolean formula L < LLV(3)[1], you will to capture the price "wiggles" that occured between your manual updates. If you want to IGNORE the intermediate "wiggles", use C < LLV(3)[1]. If you want a clever way to ignore TRANSIENT wiggles, then try something like (L+C)/2 < LLV(3)[1] ... I particularly like that last approach, btw :~)
In this case, you don't need to set the exitlevel, since if the boolean is violated, it will just use the R (most recent close) price.

Finally, if you just do ONE manual update each day, prob about 15-30 min before the close, then for all intents and purposes you ARE doing an "on Close" exit. So, for the boolean exitsignal test, you can use either C < LLV(3)[1] if you want "precise" logic (see the Aristotle quote in my sig about this), or maybe opt for something like (L+C*2)/3 < LLV(3)[1] instead. Either way, if the formula eval's to TRUE, the broker's market order will execute approximately at the R value (which presumably is similar to the final Close if the market is not moving too fast).

----------

Tolja it would be long and boring! I hope it helps. And if I'm incorrect in any particulars, I'm looking forward to Matthew's clarifications. This kind of info is INCREDIBLY important for us all to understand in a crystal-clear fashion.

=================

The big missing link here IMO is that we can't (to my knowledge) set the Limit or Stop values in the trade plan programmatically (ie dynamically based on prior-day's data). Maybe the "virtual" thing that Matthew has yet to explain does make this possible. If/when it IS possible, then the NIGHT BEFORE, OT can automatically determine the thresholds for the stops (based upon LLV(3) or whatever fancy formula the user wants), and UPDATE the Limit / Stop thresholds which would then be sent off to the broker before the next day begins. I don't think this is currently possible in OT, but it should be a priority, since THAT'S THE WAY THAT MANY TRADERS ACTUALLY OPERATE.

Thanks for your patience, Greg, and your able help, Matthew!

[Edited by Jim Dean on 1/28/2009 7:32 AM]

^ Top
Matthew Greenslet

Idol
2000252525
Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/28/2009 11:09 AM
Post #11333 - In reply to #11285

You have the right idea Jim. There were a couple very minor inaccuracies not important enough to mention. The one inaccuracy only by way of omission I will point out is in the order submission with the TP since it ties in with the broker virtual level. Allow me to go into too much detail =).

Before I get started we need to keep in mind there is a difference between a Virtual Stop and a Broker Stop tied to a virtual level (I will refer to this as a Virtual Broker Order)

The Trade plan is broken up in to two sections. Virtual Stops (bottom left pane) and the Broker Orders (bottom Right). You can set your trade plan up to use only a virtual stop with no broker order, you can use a broker order without a virtual stop, or you can can use both.

Normally using only a virtual stop without an order is simply used to move the trade plan to another step. Once the virtual stop is fired you can have it move you to a new step that uses different exits. All stop and/or broker orders in the original step will be canceled and all the stops and/or broker orders in the new step take effect.

If you select an Broker Order without a Virtual Stop it becomes a pure broker order. That order type and level (if it is a level based order) is immediately sent to the broker as soon as the step becomes active.

If you use both a Virtual Stop and a Broker Order the Trade Plan waits for our Virtual Stop FireExit boolean to return true. Again with the exception of a level base order typed to a virtual level (I will cover this in a minute) nothing happens until our boolean FireExit returns true. At the moment it returns true it them submits whatever order type you have selected to the right. For the most part you will generally use Market Orders as you want to get out as soon as your condition is met, but you are not restricted to this. You could have a Virtual Fixed Profit Stop fire and have the trade plan submit a Stop Market level 1 ATR away from the trigger price. This setup is uncommon but it can be done.

Each of the Virtual Stops COULD return a calculated exit level. VBA stops set this level by setting ExitLevel = SomeValue and/or ProfitLevel = SomeValue. It is important to note that not all Virtual Stops have a calculated exit level I.E. Trade Session Boundary stop. This stop just fires an exit at a specified time. As such VBA stop do not require you to set your exit/profit level. If you have a exit/profit level it is always best to set the exit/profit levels in the stop so they can be used elsewhere. If a Virtual Stop returns a level you can have a broker order tied to this level.

For simplicity sake lets setup a Virtual Broker Order tied to a Fixed Loss Stop.

Create a new trade plan by clicking Edit | Trade Plans | and click the New button. After you can created a new trade plan select Step 2. Right click on the Step 2 header and choose Add Condition. We now have a condition that we can choose a Virtual Stop and/or a Broker Order. In the Virtual Stop pane select a Fixed Loss Stop.

Now what I want to do is use this stops calculated level and submit it as a protective broker stop. Assuming I am in a long position I know that if I want a protective stop I need a Stop Market order. So select the Stop Market broker order.

Now that we have a stop level based Broker Order chosen you will notice the Stop Units is enabled. Before we continue drop down this box and look at your options. You have Actual Value, ATRs, Percent, Points, and Virtual Level (yes the Virtual Level option is the key we are looking for).

If you select Actual Value you will only be required to enter a Stop Quantity. Actual Value is used to select a specific price so the price you want to use is entered into the Stop Quantity field. Since you are using a specific price there is no need to choose a stop offset.

If you choose ATR then you should put your ATR multiplier in the Stop Quantity field. Also only when a Unit is set to ATR does the option for ATR Periods (below the level properties) come it to play. this will allow you to set the periodicity used to calculate an ATR value. Because you are calculating a stop offset you need to pick a base level and a direction to apply the offset.

The Points unit works much like the ATR (except the ATR Periods option is no longer used) You enter your point value in the Stop Quantity and choose a stop offset.

As mentioned at the start of this post, if you are using any of the above 4 options nothing is sent to the broker or calculated for the broker order until the Virtual Stop fires.

Now for the bread and butter. Go ahead and set your Stop Market order to use Virtual Level. With a Virtual Stop selected, a level based broker order selected, and its units are set to Virtual Level, we create a Virtual Broker Order. As soon as the trade plan step becomes active containing a Virtual Broker Order the selected broker order is transmitted using the level calculated by the stop.

If you were to submit a trade with this trade plan you would see a broker order submitted at your broker for the same price as your Fixed Loss chevron. As you drag the FL chevron around you it will update your level at the broker as well.

Now that we have the basics of Virtual Broker Orders lets explore the power of this option a little more. One of the benefits of using this option is that it allows you to use any stop you available to you in OmniTrader with your broker regardless if your broker supports it or not. We are essentially simulating the stop at the broker. As your Virtual Stop exit level changes we update the level at the broker as well.

So lets say for example we chose to use OTs Trailing Profit Stop tied to Stop Market order as a Virtual Broker Stop. In this case as soon as the stop becomes active (assuming you are using a threshold) a Stop Market order is sent to the broker using the exit level calculated by the Trailing Stop. Every time the trailing stop level changes our prior Stop Market order is canceled and and new one is submitted with the new level (or the order level is just updated if the broker supports it).

If you have all loss stops or profit stop (you can not do both within the same step) are set to Virtual Level OT will pick the stop that is closest to price and submit that level to the broker. So lets say we have more than one ratcheting stops. A Trailing Profit and a Eights stop for example. On our initial entry the eights stop is tighter than the Trailing Profit (or the TP uses a threshold and is not active yet) OT will submit the order for the eights stop. As the trade progresses the trailing stop supersedes the eights stop. At this point the order will be canceled (or updated) to reflect the level of the trailing stop until another stop supersedes it. Keep in mind this functionality only works if ALL loss (or profit) stops in the step are set to a Virtual Broker Order.
^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/28/2009 11:12 AM
Post #11334 - In reply to #11329

Thank you Jim.

Your expanation clarifies things a bit.
First point: I am an EOD user, so your explanation for EOD is what I am focused on for now. I do not wish to peek at the OHLC during the course of the day, I wish to use only EOD data (for backtesting purposes).
Secondly, I have attempted to program this exit level into my Trade Plan using "virtual levels".
Unless I'm doing things terribly wrong, I can't seem to make it work.
Like you indicated, if virtual levels are programmable into Stop Market orders, perhaps someone could enlighten us all with a step by step instruction.

Thanks for hanging in there with me Jim!
Greg
^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/28/2009 7:53 PM
Post #11352 - In reply to #11333

Matthew,

Thank you for your patience with my learning curve.
I've read through your post #11333, printed it out and atempted to program the LLV Stop as a virtual stop.

I am still having no success with setting a stop (i.e. LLV(3) for use on the next bar.
I am copying the code I wrote for the stop level I am looking for:
-----------------------------------------------------------------
#Stop

#Param "PctCush",0.005
#Param "LB_Periods",3

Dim MyStop as single

If Signal=LongSignal Then
MyStop=LLV(L,LB_Periods)[1]-(LLV(L,LB_Periods)[1]*PctCush)

Elseif Signal=ShortSignal Then
MyStop=HHV(H,LB_Periods)[1]+(HHV(H,LB_Periods)[1]*PctCush)

End If
----------------------------------------------------------------------
Can you let me know if I'm on the right path here and if so, exactly how I can get this stop level to fire as a Stop Market order during a daily bar?

My problem I think is combining the above "MyStop" with your instruction in the post.

Greg
^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/28/2009 8:10 PM
Post #11354 - In reply to #11329

And the hits just keep on comin' - thanks again, Matthew, for the lucid explanation.

Tho you did not mention it, the list of virtual stops avail does include OLang stops, afaik.
Vereee good.

The only confusion (or heartburn) I have with this is related to the statement you made: if you have all loss stops or profit stop (you can not do both within the same step).

I really, really need to be able to have both a loss and a profit stop active at the same time - in fact, I prefer two of each.
Typically one of each is a partial exit, and the other of each is a full exit.

Profit stops (I call them "profit grabs") are set up to capture short-term statistical outliers (ie highs beyond 3 SD's), while trailing stops are there to prevent riding a position, once profitable, into loss.

They both must be active at the same time.

The broker can do this - isn't there a way for TP's to?

If not, can - hope to presume that it's in the works??

Thanks again!
^ Top
Matthew Greenslet

Idol
2000252525
Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/29/2009 10:43 AM
Post #11361 - In reply to #11354

You can do this in a trade plan just not with two broker orders. One side or the other has to be true Virtual Stops tied to most presumably a Market Order.

It just makes sense that if you had only one level you can send to the broker you would put it on the loss side. In fact it is very important to ALWAYS have a broker order on the loss side so that you are protected if you loose power for instance and you can not open your trading platform.

So to set this up you can have as many loss stops in Step 2 that are Virtual Broker Orders that you like. You can also have as many profit stops in Step 2 that you like as well, however they all must be true Virtual Stops. That is to say a Virtual Stop tied to a Market Order. Really it could be any order type as long as it is not tied to a Virtual Level. However at least 90% of the time it will be tied to a Market Order.

Each condition you add to a trade plan step can be set to only take broker action with a percent of the open position. By default when creating a new condition it is set to 100%. Each condition can also be set so that after that conditions broker action has completed you can jump into any Step after the one you are in (you can not go backwards).

The list of Virtual Stops does indeed also include any stop you have written in OmniLanguage. If you are using a custom OL stop as a Virtual Broker Order ensure your ExitLevel property is being set.

Now that you know about Virtual Stops and Virtual Broker Orders I want to mention one other special stop in the Virtual Stops list called OmniScript.

The OmniScript stop gives you an alternative to the process of creating a OmniLanguage stop if you just have a simple condition. Lets say for instance I had a long trade plan and I just wanted to exit when the last price is greater than the highest high of the past 5 bars. Instead of writing several lines of code to create this as a stop I can just use the formula C > HHV(5) in an OmniScript stop.

Keep in mind this is OmniScript, not OmniLanguage. You cannot create and assign variables, you cannot create any logic other than a boolean statement. The formula syntax for the OmniScript stop is the same you would use in OmniScan, Color Charts, and Strategy Filter Blocks. Because of this the stop CANNOT return any calculated level (there is no calculations, just a True/False...Fire Exit or Dont) so it can not be tied to a Virtual Broker Order, it will not plot anything on the chart when Plot Stops is enabled, and it will not have a chevron when the Trade Plan step is active. If you have a live trade plan using a OmniScan stop you will see a small gray box at the bottom on the price pane that says OS.
^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/29/2009 12:18 PM
Post #11364 - In reply to #11361

I think I understand it now, Matthew. The power that TP offers is complex enough that it really benefits from the explanations you've provided. Please include these explanations in the new manuals you've been working over - they are incredibly helpful.

Icing on the cake would be a complete example that has one loss-side broker order plus several virtual stops, all in the same step, two on the "grab extreme profit opportunities" side (use SD's as convenient thresholds - if 2 SD's beyond yesterday's (avg + 1 ATR) then exit 1/3 of position; if 3 SD's beyond, exit 2/3 of position), and two on the "protect from loss or disaster" side - your examples of an ATR-based trailing stop and an eighths stop are good ones - maybe include a formula-based MA crossover or something for illustrative purposes.

The one bottom-line limitation that this presents to the EOD user that does NOT plan on any intraday updates is that ONLY the broker-order actually will do him any good ... the virtual logic won't take effect because the PC is shut down, &/or because the data is unchanging in OT during the day. So, a zillion virtual stops would make no difference, without frequent manual updates, or without continuous RT feed.

The original question I believe was related to a stop that compared the price of the current day to the LLV(3)[1] ... ie the lowest of the lows that had occured in the prior three days. As I understand it, the user has two choices in which the backtest will reasonably approximate EOD real-life:

1. Enter C < LLV(3)[1] in an "omniscript" mode, tied to a Stop MOC broker order for the backtest. If the exit occurs in backtest, it will be based on only the C of the current day, since that's what the formula specifies. In real life, the fact that the order is Stop MOC (not just Stop Market), with a broker threshold value of LLV(3)[1], will prevent the broker from exiting the trade earlier, even if the day's L is below the threshold. Thus, the backtest will match real life (not counting slippage). The trader's machine can be turned off during the day. Is this correct?

2. Create an OmniLanguage Stop that specifies BOTH a boolean ExitSignal of: L < LLV(3)[1] ... and also, a scalar ExitLevel = LLV(3)[1]. The backtest will fire on the day's bar if the low got below the threshold, but the ExitLevel value will force the calculated exit price to be at the LLV(3)[1] threshold. Only exception would be if entire day (ie the High for the day) was below the threshold ... in that case, the backtest will exit at the Open ... not a perfect solution, but how can a computer simulate PANIC, anyways?? In real-life, the trader would create a typical Stop Market order based on LLV(3)[1], which the broker would execute at the equivalent intraday point that the backtest would have chosen (disregarding slippage). Is this correct?


I think that these two paragraphs are a complete answer to the original question - Gregg, if we've missed anything, please chime in.

Thanks for your help, Matthew!


[Edited by Jim Dean on 1/29/2009 12:22 PM]

^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/29/2009 12:41 PM
Post #11365 - In reply to #11364

Actually, I just realized that there is a third option, which allows the EOD trader to go beyond the only-one-broker-order-at-a-time-and-no-intraday-manual-updates-so-no-virtual-orders limitation.

If we presume that all of the actual real-life broker orders are placed by the trader external to OT (ie not using the OT brokerage module), but rather thru TWS or phone or whatever, then we CAN simulate (some) multiple virtual order logic situations in backtest, even if one is profit-side and one is loss-side, AND carry them out in real life.

Without going thru a full example ... the proposed virtual combo of several profit grab and stop loss levels with differing exit percentages, etc could all be modelled in an EOD based backtest, as long as the rules in my #1 and #2 are followed.

#1V case: if the OmniScript ExitSignal is of the form "C < formula", then the broker order MUST be Stop Market On Close with "formula" as the stop level. It is of course possible that several different formula alternatives could be set virtually based on things that happened ... but in every case, the SMOC would exit at or close to the Closing price for the day, if any of them fired. So, this approach has marginal usefulness.

#2V case: if the OmniLanguage Stop's ExitSignal is of the form "L < formulaA" or "H > formulaB", AND if an ExitLevel is set in the stop's code, then multiple virtual stops &/or grabs could be implemented to simulate intraday action that a broker would take if the broker was given several Stop Market orders. The eval of each formula would be done in real life the night before, and the trader would have to manually enter the group of orders, rather than asking OmniBrokerage to do it.

This (2V) approach raises an interesting question. You mentioned earlier that if two virtual stoploss orders were active, the closer one to the Open would be used in the backtest eval. BUT, what if that was only a PARTIAL exit, leaving a nonzero position size behind after execution? If the price continued to go against the position, after the closest order fired, and it finally passed the more distant stop level during that same day, would the backtest engine (EOD, mind you) then execute the second stoploss order, applied against the remaining shares?

If the day was really volatile and the ExitLevels were pretty tight, and if all were Partial Exits that summed <=100%, then TWO on the profit side and TWO on the loss side (all at different ExitLevels) could ALL fire in one day, IN REAL LIFE, as the broker executed them in real time.

I'm guessing that until you get the OHLC vs OLHC logic installed, we are stuck with either JUST the loss-side pair firing, or JUST the profit-side pair firing, or JUST the first one firing. That is, the current backtest code in EOD mode treats all of those four virtual stops as OCA (One Cancels All) orders. Ungood, if partial exits are the desire. Please clarify what happens in this scenario, for the program as-is.

Finally - when (hopefully not "if") you get the OHLC vs OLHC logic in place, PLEASE ALSO ADD ORDER DISTINCTIONS FOR OCA.

I look forward to whatever corrections you might share. This has been an interesting and worthwhile discussion (for me at least). Thanks again!

[Edited by Jim Dean on 1/29/2009 12:44 PM]

^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 1/29/2009 12:46 PM
Post #11366 - In reply to #11364

Matthew / Jim,
I'm sorry guys but I'm still lost.
What would help me immensely would be the complete example Jim is asking for in his last post.
The stop level I think I programmed in Post 11352 is what I am looking for (with or without the cushion).
I know you both are trying hard to help me here. I appreciate your patience.
Greg
^ Top
tradermike

 
Subject : RE: Intraday Stops
Posted : 2/2/2009 4:22 PM
Post #11398 - In reply to #11366

Hi Greg,

First my disclaimer: I have been away from the forums (and OT) for quite a while. As such I am probably rusty and my input should be taken with a grain of salt :)

Alright, well unless I’m missing something(?)…what you’re looking for seems pretty straight forward to me. I think the main point of potential confusion is that if you want to use OT to cause exits to happen during the day, then you MUST use a real-time data feed – regardless of whether you are a RT or EOD user!

As Matthew pointed out, Stops are processed differently & separately from the focus list. Furthermore, stops are evaluated only when (and every time) new data comes in. So if you only have a EOD feed, then stops can only be updated and evaluated at the end of day. But with a RT data feed then stops are evaluated continuously. The other hybrid option discussed here is that of manually updating your EOD feed one or more times during the day. If you do that, then each update will result in your stop conditions be evaluated.

But the bottom line is, for a stop to be triggered…new data must come into OT.

----------------------------------------
Regarding your code above (post 11352)

The logic is partially correct. But I’m guessing you want this to behave like a trailing stop(?). If so, then you need additional logic to only move the stop in the direction of your trade (otherwise it could move backwards). And then of course there is the extra logic to trigger the stop itself. Oh, and if you assign “ExitLevel” to your “mystop” value, then it can be plotted on a chart.


================================
BTW: I published some work on a similar Stop and Trade Plan a while back. I’m reasonably confident that this will do what you’re looking for…(as I've used it with live trading)

For the community: Refinements to the XBarStop:
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1411

In particular, take a look at the stpXBarLiveSafetyNet stop and set the parameters:
Periods = 3
myOffset = 0

There’s also a sample Trade Plan there for you to review.

And yes, these stops and Trade Plan were created with RT trading in mind, but the “safetynet” version should work just fine for EOD.

Oh one caveat...
Looking at my code now with hindsight, I see that there might be a minor logic bug? That is, I might need to reference the previous bar on my LLV calc(?). Anyway, take a look and if you’re interested, let me know and I’ll double-check my code logic.

Regards,
--tradermike

[Edited by tradermike on 2/2/2009 4:31 PM]

^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 2/2/2009 7:45 PM
Post #11399 - In reply to #11398

Mike,
Thanks for your post regarding this particular type of stop.
I have read it and your post(s) from 2007 with great enthusiasm.

I realize as an EOD trader that I will need RT data to have my stop levels executed when I take my strategies live, but for backtesting purposes, don't you think OT could assume that if the high for a day was 25 and the low for a day was 23 that the price of 24 was traded sometime during the trading day?

I think the theory I'm referring to is already possible with OT, in fact I think I'm using it to an extent.
In a trade plan I am currently working on, I can enter a trade in the middle of the bar (or "intraday") by selecting the following in the Order block of the trade plan:
For long trades, select Stop Market order, select Stop Units as Percent, select any number for Stop Quantity (I used 0.5), select Above High as Stop Offset and I select "good for day only". This gets me into trades when backtesting at precisely 0.5% above the high of the previous bar (day in my case).
The key here is "Above High". It appears to only work on the previous previous bar's data. What I am looking for is above "High of previous 3 bars or HHV(3) in lieu of "Above High".
I will further study your posts from 2007 for clues that I may implement to get my Trade Plan to work properly.
By the way, thanks for the tips on coding my stop to plot, etc.
I would appreciate any thoughts you or other Forum Users may have on this subject.
Greg

^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 2/2/2009 7:58 PM
Post #11400 - In reply to #11399

Another thought:
While setting up trade plans, if one would like a Profit Stop of say 3% above the entry price for long trades, we can make this happen in the Virtual Conditions block by selecting the appropriate items. This again gets me out of trades "intraday".
OT is an awesome program for allowing us to do things like this to help Back and forward testing.
Greg
^ Top
tradermike

 
Subject : RE: Intraday Stops
Posted : 2/3/2009 12:02 AM
Post #11405 - In reply to #11285

Hi Greg,

When it comes to live trading vs simulated trading results with OT, you really need to exercise caution. I have learned some very (emotionally & technically) painful lessons in this area. In fact, there has been more than one instance where I have created the holy grail trading system, analyzed it upside down and sideways to “prove” that everything was correct, only to eventually learn that there were significant differences with OT’s behavior.

He’s one example of such a problem:
multiple timeframe indicators
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1550

One step that I learned to take was to scrutinize trades from the back test period. For example, if you run a Portfolio Simulation, save off a copy of the Trades pdf file somewhere. Then go through each trade and analyze BOTH the entry and exit times AND prices. Compare this with the chart(s) and the Vote Line, looking for confirmation or inconsistencies. This will give you a much better idea of how OT is handling your Strategy (and Trade Plan).

Then, after you have a good understanding of OT simulated behavior, you must then compare that to actual live trading results – trade by trade. I know this is a painful and tedious process, but I believe it is very important. Think about it this way, either you will uncover a problem…or gain confidence that things are working correctly. Both of these are good things!

Perhaps the main point here is that while OT is a powerful tool, it does have it’s limitations. Understanding how OT works, it’s strengths AND it’s limitations are crucial to getting it to do what you want.

And while you can say things like “well shouldn’t OT do this” or “behave that way” are certainly valid statements, what truly matters is how OT actually behaves right now. Then you must learn how to operate within and/or around it’s limitations. (Submitting feature requests is fine, just don’t expect anything soon.)

==============================

As for coding help, my pleasure. There are actually quite a few good programmers on the Pro forum. Not only that, but most of them are very friendly and happy to help others. So if you ever have questions or problems, just post and there’s a good chance someone will reply.

By the way, if you look at one of my stops (referenced in that post), you will see the answers to the things I pointed out. (i.e. how to make your’s a trailing stop, how to make it plot’able, etc.)

And if you’re the kind of coder that benefits from looking at sample code created by others, then there’s a few other stops that I have published that may (or may not) be of reference benefit. Just do a search on my username…or I can provide links if you prefer.

==============================
In case you’re interested, here’s a few other related posts that touch on some items related to this thread.

Can new trade entries be aborted?
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1662

Help with Mult-Step Trade Plan
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1542

TradePlan Problems
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1488
Mentions some observations on Broker Stop requirements / limitations in Trade Plans

Who manages the Trade Plan - OT / OP ???
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1319&posts=8

Also, Jeff Drake published a really good (28min) seminar - Getting Started With Integrated Brokerage.
http://www.omnitrader.com/intbrokergettingstarted/
This may or may not be helpful to you as well.

==============================
And if you’re really interested in reading, here’s rather lengthy post covering all sorts of topics related to Trade Plans and OT behavior in general.

Lessons on Automated Trading using OT Pro
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1442

==============================
Alright, well I apologize if I’m flooding you with too much info, or if I’m somehow deviating from your desired topic. But I’m just trying to help out a little.

Regards,
--tradermike

^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Intraday Stops
Posted : 2/3/2009 6:28 AM
Post #11407 - In reply to #11405

Hi, Greg:

TM's comments and handly list of info is really good stuff. Copy & save it (I did).

However, I really think that we got to a solution earlier, but there are just some terms or concepts that we are no "clicking" on.

I've p-mailed you my phone# - give me a call and I'll try to break the logjam for ya, if I can.


^ Top
Greg Winch

Regular
2525
Posts: 71

Joined: 1/21/2007
Location: Phoenix

User Profile
 
Subject : RE: Intraday Stops
Posted : 2/3/2009 8:15 PM
Post #11426 - In reply to #11407

Jim, Mike & Matthew,

You have all been very helpful to me.
I appreciate the patience you have shown, especially Jim.
I think I now have the tools to go on.
You all gave me a lot of info to study, and believe me, I will.
If I make discoveries I feel worthwhile to you, I will share them here.

Greg
Jump to page : 1 2
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.