logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Scaleo  
#1 Posted : Wednesday, April 21, 2010 7:16:35 AM(UTC)
Scaleo

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/29/2009(UTC)
Posts: 13
Location: Germany

Hi @ all, does anybody know how to set a customized expiration for orders in the EST? I do have only two options if I want to place a stop order: Good for day, or Good till canceled. The problem is that I want to set stop buy or stop sell orders which are only valid for e.g. the next five bars. The reason why I want to have this is logical. If a signal occurs I want to set the stop and I only want to enter if the stop is reached by the next view bars. Because otherwise the signal is not approved, but the stop entry order is still there and is executed maybe 100 bars later, which is certainly wrong and falsifies the whole system test. So the question is, how to set an expiration (in bars) for entry orders in the EST? Thanks for your help Scaleo
vienna  
#2 Posted : Wednesday, April 21, 2010 9:39:31 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

Hi
I think you have to implement the whole stop logic into your (buy)signal by your own.
This means you have to set your buy signal to 0 until your own stopsignal is reached and the stop signal is <=5 days.

The expiration can be realized with
- the barssince - function (see http://www.meta-formula....-barssince-function.html) or
- with cum(1) and valuewhen() function in combination or
- with PREV+1 and if() in combination


Scaleo  
#3 Posted : Wednesday, April 21, 2010 12:15:12 PM(UTC)
Scaleo

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/29/2009(UTC)
Posts: 13
Location: Germany

Hi Vienna, first thank you for your fast reply.
vienna wrote:
Hi
I think you have to implement the whole stop logic into your (buy)signal by your own.
This means you have to set your buy signal to 0 until your own stopsignal is reached and the stop signal is <=5 days.
I agree absolutly with you but the your solution seems not working in my case. It is not like I have not tried a lot. The major problem is that I have to use a stop entry order. First I have the major entrycondition coded in the formula window. Below of this I define the stop conditions. The point is that if the major entry condition is true, the stop condition is only calculated once (only at the current bar where the major entry formula is true). After the calculation of the stop condition the stop entry order is placed and not touched again. That means that calculations in the Stop conditions which are depending on "barssince", "value when", "prev" or simulation.age will not work because they are only once calculated as the major entry condition is true (at the bar befor entry) and the result at e.g. barssince will be 0. Would it not be 0, the major formula would not be true and the stop condition would eighter not be calculated... I am talking about backtests in intradaycharts and for that reason a solution would be essential, because test in which stop orders are like "ghots" for long time in the test and will be executed hundrets of bars later does not only make me wonder where this trades are coming from, they do also destroy every result... I can ask the question a bit different: How to implement an expiration for the next day only, for a stop entry order? This also works only with market orders... If I am wrong, please give me a short example which works so that I can reconstuct it. best regards Scaleo
vienna  
#4 Posted : Thursday, April 22, 2010 3:41:42 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

Hi Scaleo,

unfortunatly my english isn't as well as it should be and so I'm not really sure if I have understood your problem correctly.

I think you will need to define all your signals in all simulation windows (e.g. Buy Order, Sell Order, Sell Short Order, etc.) and react in every window in an other way to these signals.

I have tried to do a simple (signal) example where we can discuss more practically about.
I have two signals: signal1 and signal2.
I calculate the days which have been passed since signal2 has given me a signal. But if the days are more than 5 I reset the count to 0.
Then I can use signal1 in combination with the countdays. So I get only a signal if signal1 is 1 and signal2 has been fired in the time range of the last 5 days.


signal1:=Mov(CLOSE,15,S)<Mov(CLOSE,5,S);
signal2:=Mov(CLOSE,50,S)<CLOSE;

countdays:=If(signal2=1,1,If(PREV<5 AND PREV>0,PREV+1,0));

signal1;
signal2;
(countdays>0);

{example to use the signal}
If(countdays>0 AND signal1=1,1,0)

best
vienna
Scaleo  
#5 Posted : Thursday, April 22, 2010 7:46:46 AM(UTC)
Scaleo

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/29/2009(UTC)
Posts: 13
Location: Germany

I know that this is an englisch spoken forum, but because in this moment only two natively german talking people are corresponding I will translate this post to german at the bottom too. So please do not be irritated. --- I think we are talking duplex. Your code shows one option, I preferred another which was provided by wabbit in the forum long time ago x:= my condition H>valuewhen(1,x,H) and barssince(x)<=5 BUT: In this special case the main thing is that I do not want to open a position as a market order at the open of the next bar. I want to open for example a long position after a given signal with a stop entry order over the high of the signal. (That means: Signal occurs -> stop entry order is placed over the high of the signal, -> alternative 1: the high is in less 5 days taking and the stop entry order is triggered over the high of the signal, alternative 2: the signals high is not taking within 5 days so the stop order is canceled) If the signals high is not taking within the next 5 bars, the order should be deleted (because the signal is in this case not approved)! If I try to solve this with a market order, I can on the one hand place an expiration for this order (e.g. 5 bars) but if the high of the signal is taking, I will entry on the other hand market at the open of the bar after the signal high was taking (this is to late and the wrong price as wanted) By my knowledge it is only possible to get other value for entry/exit positions in backtests such as O/H/L/C if I am dealing with stop, limit, stop/limit orders. But the essential problem with an once placed stop entry order is that this order is definitely in the market and will stay as long as it is triggered (not depending on how many bars are gone since the signal occured) or the test is over and the order well be deleted at the end of the test. I did not find a time depending limitation for stop orders, yet. But that is what I am searching for. It should be of course possible to set an expiration for stop orders! @ all market- / coding-wizards: Help is desperately wanted! Scaleo --- --- Ich denke das wir aneinander vorbeireden. Der Code von Dir spiegelt eine möglichkeit wieder. Eine andere welche ich ausprobeirt habe war x:= my condition H>valuewhen(1,x,H) and barssince(x)<=5 ABER: Es geht dadrum das ich nicht mit einer Market Order zum Open des nächsten Bars meine Position eröfnen möchte. Vielmehr ist gewünscht, dass nach Signalgebung mit einer Stop Order z.B. über das Hoch des Signals long gegangen werden soll. (Das heißt: Ein Signal entsteht, -> eine stop buy Order wird über das Signalhoch gelegt, -> Möglichkeit 1: Das Signalhoch wird innerhalb von 5 Tag berührt und die Stop Buy order ausgelöst, Möglichkeit 2: Das Signalhoch wird innerhalb 5 Tagen nicht berührt und die Order verfällt) Wird das Signalhoch nicht innerhalb der nächsten 5 Bars überschritten soll diese Stop Order verfallen (weil das Signal dann nicht bestätigt wurde). Realisiert man das ganze mit einer Market Order kann man zwar die Anzahl der Bars beschränken an welchen die Order gültig ist, aber es wird zuerst das Signalhoch genommen und anschließend zum Open des nächsten Bars die Position Market erföffnet (zu spät und zum falschen Kurs). Meines Wissens kann man nur mit Stop,Limit, StopLimit Orders andere Werte zum Eröffnen/Schließen von Positionen als O/H/L/C in Backtests bekommen. Nur das essentielle Problem mit einer einmal gesetzten Stop Order ist, dass siefix im Markt verbleibt bis sie ausgelöst wird (egal wie viele Bars später) oder der Test zuende ist und die Order mit Testende verfällt. Zumindest habe ich noch keine Zeitliche Begrenzung für Stop Orders gefunden, auf der Suche nach der Lösung bin ich ja hier. Es muss doch möglich sein Zeitlich limitierte Stop Orders in den Markt zu legen!!! Vielen Dank für Deine Hilfe, ich bin mittlerweile nahe am verzweifen... Scaleo
vienna  
#6 Posted : Friday, April 23, 2010 2:54:35 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

Hi you were right I missunderstood the real problem, but now I understand what it is. But I'm sorry that I can't help you, maybe MSTT has some ideas how it can be realized.
I can only suggest you to write to formulas@equis.com maybe they can help you? (Mostly answers from them will delay 1-2 weeks)

I'm sry that I can't help further..

---

Hallo,
ja du hattest recht ich habe das Problem missverstanden. Leider kann ich dir dabei auch nicht weiterhelfen, da ich selbst nur auf täglicher Basis (zum Bar des nächsten Tages) ausgelöst habe und somit mit diesen "Intraday" StopOrders kaum Erfahrung habe. Ich befürchte allerdings, dass es dafür keine wirkliche Lösung gibt. Eventuell kann dir MSTT weiterhelfen, er ist ein wirklicher Experte in all diesen Fragen.

Du kannst auch probieren direkt an formulas@equis.com zu schreiben, diese Antworten zwar meist erst nach 1-2 Wochen, aber dafür müssten sie eigentlich wissen ob es möglich ist.

Sry dass ich nicht mehr helfen kann..
mstt  
#7 Posted : Friday, April 23, 2010 4:47:49 AM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

H Scaleo

I'm sorry but I can't reply in German so English will have to do. My personal opinion is (and I might be wrong) that there's no need to use any order type other than "Good for Day". When it comes time to enter any trade (when you're testing) you already know what the state of all entry conditions are. At that point you simply need to execute the trade based on all needed conditions being TRUE and use a Limit or Stop Price for setting the purchase price. The Buy Order window will generate a TRUE, and the almost identical Limit or Stop Price code window will generate the PRICE.

What I'm suggesting is that you take control of the order process away from the EST and manage it with code in the Buy Order and Sell Order windows. If the requirements of your trade are logical then I'm sure that it can be done with code rather than trying to do it with EST settings and simulation parameters.

Your code should not be written with a perspective of looking from the present into the future but of looking from the present to the past. While this is probably not the way you trade it is certainly the easiest way to write code for the EST. I strongly get the feeling that you're making the order process more complicated than it needs to be. I would only generate (and execute) an order once all conditions were TRUE. Until that happens it's not a real order and the EST doesn't need to know about it.

Roy

Scaleo  
#8 Posted : Monday, April 26, 2010 3:36:53 AM(UTC)
Scaleo

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/29/2009(UTC)
Posts: 13
Location: Germany

Hi Vienna, Hi MSTT, I got it! The key point gave me MSTT to write my code like I would trade backwards. It is of course not realistic for real trading, but it gaves me the real and true backtasting resulsts. Thanks a lot! Scaleo
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.