Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
Exittrigger:=H>REF(Mov(C,100,S),-1); Exitprice:=REF(Mov(C,100,S),-1); Want to exit with price on REF(Mov(C,100,S),-1); The exitprice on the trades have no problem but putting on an extra exit on 60 bars, the trades exiting on 60 bars have exit price on the high of the bar rather on the close How to adjust to allow those trades exiting on 60 bars to exit on the close using tradesim?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
It's not clear what "60 bars" has to do with your code...I'd think ExitPrice would have to be OHLC or the HL range, rather than an MA.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
60 bar is another exit and want the exit to be on close but why tradesim use high rather the close?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
If you are using a trailing stop, usually the High is used when Short, and the Low when Long.
Otherwise, without seeing the code, I have no idea.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
StoH:=Fml("stoH") EntryTrigger := Cross(C,stoH); EntryPrice := C; ExitTrigger := H>Ref(Mov(H,100,S),-1); ExitPrice :=Ref(Mov(H,100,S),-1); ActualExitPrice :=If(ExitPrice<O,O,ExitPrice);
ExtFml( "TradeSim.Initialize"); ExtFml( "TradeSim.EnableProtectiveStop",0); ExtFml( "TradeSim.EnablePriceFilter"); ExtFml( "TradeSim.SetTimStop",60);
Those trades exit without exittrigger are on H rather on C
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
Well, first off, I don't see "RecordTrades", which is where you'd specify the ExitPrice.
Second, merely because you WANT for the ExitPrice to be yesterday's moving average of the High price, does NOT mean the price hit that number -- in fact, it would not happen very often! Plot that 100 MA on the chart and have a look for yourself.
I'd guess you've set ExitPrice above the High price, which is invalid, so it uses the High price instead.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
Flexi -- You might play with this, and see if it does what you want (exit on close), then modify as needed, one item at a time:
{ Entry/Exit on CLOSE } ExtFml("TradeSim.Initialize"); ExtFml("TradeSim.EnableProtectiveStop",0); ExtFml("TradeSim.EnablePriceFilter"); ExtFml("TradeSim.SetTimeStop",20);
FastD:=Fml("_Stochastic");
EntryTrig:=Cross(FastD,20); ExitTrig:=Cross(80,FastD); ExitTrig:=0; { OVERRIDE TO TEST TIME STOP }
ExtFml("TradeSim.RecordTrades", "_Test", LONG, EntryTrig, CLOSE, { Entry Price } OPEN-(OPEN*.10), { 10% Initial Stop } ExitTrig, CLOSE, { Exit Price } START);
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
Try using this as your "ExitPrice" code:-
ExitPrice :=If(ExitTrigger,Ref(Mov(H,100,S),-1),C);
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
oz -- Won't that just result in a bunch of "invalid price data" warnings, since ExitPrice won't be in the range of Low-to-High?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
Hi Johnathan,
"The exitprice on the trades have no problem but putting on an extra exit on 60 bars, the trades exiting on 60 bars have exit price on the high of the bar rather on the close
How to adjust to allow those trades exiting on 60 bars to exit on the close using tradesim?"
Above is the original question which Flexi posted so I was only concentrating on providing a solution which forces TradeSim to use the closing price in all other circumstances.
I believe that the ExitTrigger shown is only for example purposes as it could be applicable on the day the Buy signal was triggered!
To avoid using invalid data I use the following code:-
ExtFml("TradeSim.DisablePriceFilter");
ExtFml("TradeSim.ShowRejectedTradeDetails");
Cheers
oz
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
How to round off the the entry and exit price to 2 decimals?
|
|
|
|
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.