Murray Ruggiero
Sponsor
Quote from samuel_weber_74:
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.
Value1=Max(H,NextOpen(0))+PercOfBar/100*(H-L)
Value2=Min(L,NextOpen(0))-PercOfBar/100*(H-L)
Why are you looking at tomorrow open in this case, Is that what you want to do, or are you comparing the H and L to todays open ?. We will work on this example for you , but I want to understand what you are trying to do.
