Can anyone help me with this ? Thanks. As exercise I wrote a system to trade inside days. If today is an inside day I place an order to buy tomorrow 1 tick above today's high and a second order to sell 1 tick below today's low. I also place 2 profit targets for tomorrow and the next days. Let's say this target is 5 ticks. Too small for a profitable system in reality but a very close profit taking limit order fits well in this example. If today is an inside day, it is likely that tomorrow one of the stop orders will be filled and also that the limit order above/under it will be touched exiting me from the position..... well, it does not happen ! The stop order is filled, let's say I am long, the profit target is hit, too, but the position is not exited at that price ( with the limit order ), it is exited only the next day on the open !! I am sure I missed something. If someone could help .... I tried everything ... my head is spinning ! This is the code: Code: Sub Inside_Days_prova(PercOfBar) Dim InBar Dim StopXLong Dim StopXShort Dim Value1 Dim Value2 InBar = High < High[1] And Low > Low[1] If MarketPosition=0 And InBar Then Buy("Long", 1, H + GetActiveMinMove(), Stop, Day) Sell("Short", 1, Low - GetActiveMinMove(), Stop, Day) Value1=Max(H,NextOpen(0))+PercOfBar/100*(H-L) Value2=Min(L,NextOpen(0))-PercOfBar/100*(H-L) ExitFirstDayLong("","Long", 1, Value1, Limit) ExitFirstDayShort("","Short", 1, Value2, Limit) End If If MarketPosition > 0 Then ' Profit Target If Date = EntryDate Then StopXLong=L[1] - GetActiveMinMove() Value1=EntryPrice+PercOfBar/100*(H[1]-L[1]) End If ExitLong("", "", 1, StopXLong, Stop, Day) ExitLong("", "", 1, Value1, Limit, Day) End If If MarketPosition < 0 Then If Date = EntryDate Then StopXShort=H[1] + GetActiveMinMove() Value1=EntryPrice-PercOfBar/100*(H[1]-L[1]) End If ExitShort("", "", 1, StopXShort, Stop, Day) ExitShort("", "", 1, Value1, Limit, Day) End If marketbreakdown() End Sub I also attach a screen shot: you see, the position in not exited at the limit order's price but the next day on the open.
Hi Samuel Weber, I do not have enough programming experience to see where the problem might be within your coding BUT the first thing I thought of was that it could be because Traders Studio is primarily designed for End of Day data so it might only allow one trade per day. Once it enters a trade one your first order it has to wait for a data refresh prior to making another order. I have no idea if this is correct or not but just a thought. Maybe when Murray returns he could confirm/deny this. Andrew.
Dim InBar Dim StopXLong Dim StopXShort Dim Value1 Dim Value2 I just looked at it quick, try making these all bararrays Dim InBar as bararray Dim StopXLong as bararray Dim StopXShort as bararray Dim Value1 as bararray Dim Value2 as bararray I know this will solve several problems with the system, from there you can debug it. If you have any more problems let me know.
Hello Murray ! Thanks for the input ! You are a so kind person and I sincerely hope you do not feel disturbed/offended because of my insistence about a much better documentation. Your software is wonderful and I recommend its purchase to anyone who asks for my opinion. It is great. I am very close to do with it all the things Trade Station did not allow me to do. And the genetic optimizer is another wonderful tool. I simply ask to have a documentation having the same quality of your software ! Today I was reading the virtual system's reserved words ....."this allows to access the interface of the virtual backtester". Only this. May I know what this "interface" is ??? Just another example of what I mean ! I sincerely hope you understand me and do not feel offended !
About the inside days code: I just tried to declare all variables as bar arrays but the result did not change. Most of the time it still exits on the next day's open
TradersStudio really does not allow, entry in both directions on the same day. It's really a bad idea. Let's look at today, We started new the low of the day, rallied, bottomed again and then finished near the middle of the range in the Dow. Based on your rules, we would of assumed We open near the low, rallied and then sold off the the middle of the range, well based on the real price action and depending on the system we might of been stop out of the buy signal , if we used intra-day data. The fact that the assumptions of intra-day topology can be wrong means we have to make sure false assumptions do not give us overstated results. Systems like channel breakout do allow buy and sells on same day but if we are using a 20 day high and low , we will only very very rarely see a buy and sell on the same day. You should test the long and short entries seperately and use a tradeplan to combine both sides. We are trying to cut some of these restrictions in the new version but I need to protect the backtester from producing false , too optimistic results. In terms of the Virtural functionss, have you looked at the ChannelWithFilters(SLen as integer). This is a good example. Please ask me whatever questions you have after looking at this example. In terms of the documentation we hear you and the documentation for the new version will be much better.
It does not work. I have now divided the system in 2: one for the long and one for the short side. The long system places a stop order 1 tick above the inside day's high and a profit target ( limit order ) above the entry point. The profit target is hit but not filled ! It keeps getting out on the next day's open ! I can understand protecting the backtester but, for the same reason, it is much more important to be sure orders are filled exactly as the user coded them ( just my humble opinion ). Murray, would you be so kind to place your version of a system taking only the long side after an inside day ? With a profit target say 5 ticks above it ( limit order ), to be sure it is filled on the same bar of entry, so I can see how this works in TradersStudio. Just to teach me how to write this type of signals. Thanks.
and does "entrydate" work ? I tried If Date = EntryDate then ..... to determine if today I have entered a new position but entrydate is always zero even if MarketPosition>0 How can I determine if today I have entered a new position ?
I have spent all the morning try to make things work. It seems that on the day of entry it is impossible even to have filled a simple stop loss placed 1 tick below the low of the inside day ......
EntryDate is not set till the close of that bar, so what you are doing will not work. Tell me what you are trying to do. Entrying and Exiting on the same day are special cases and we have special functions to be able to handle that. I will give you an example if you explain what you are trying to accomplish.