PDA

View Full Version : Recording problem and 2 exit methods


mary1
11th January 2008, 05:37 AM
Hi Jose,

There are two problems iwith the code below in using tradesim. The first one is tradesim does not seems to record the sell trades. Only buy trades are recorded. However when the sell trade code is placed above the buy code, tradesim does not record the buy trades and record only the sell trades.

The system is a simple breakout system where if filled, exit at the close on the same bar as entry.

Under the exploration result tab, no securities are report. And under reject tab, Error in column A: An MSX DLL is reporting an internal error. Referenced DLL: "TradeSim.RecordTrades" DLL Message: Invalid security data detected - Check the Error Log for details. However the trb have buy trades recorded.

The second problem is as regarding the previous post with using two exit method and exit price. The system is a breakout system where if filled, exit at the close (No delay) when RSI(C,10)>75 or exit at the open (no delay) if the open is less than yesterday close, whichever comes first. The code does not seems to differentiate if exit on rsi use close exit price and if exit on O<ref(C,-1) use open as exit price.

-----------------------------------------------------

EntryPrice1 := O+((Ref(H,-1)-Ref(L,-1)));
EntryTrigger1 := OPEN;
ExitPrice1 := Close;
ExitTrigger1 := Close;

InitialStop1 := 0; { optional initial stop }

ExtFml("TradeSim.Initialize"); { Initialize internal variables }
ExtFml("TradeSim.EnableDelayOfEntryByOneBar"); { delay entry trigger by one bar}

ExtFml("TradeSim.InitializeValues"); { always include this call }
ExtFml("TradeSim.AssignValue",PointValue,"S&P",250);

Tally:=ExtFml( "TradeSim.RecordTrades",
"S&P", { Trade Data Filename }
Long, { Trade Position Type }
EntryTrigger1, { Entry Trigger }
EntryPrice1, { Entry Price }
InitialStop1, { Initial Stop }
ExitTrigger1, { Exit Trigger }
ExitPrice1, { Exit Price }
Start); { Trade Recorder Control }

EntryPrice2 := O-((Ref(H,-1)-Ref(L,-1)));
EntryTrigger2 := OPEN;
ExitPrice2 := Close;
ExitTrigger2 := Close;

InitialStop1 := 0; { optional initial stop }

ExtFml("TradeSim.Initialize"); { Initialize internal variables }
ExtFml("TradeSim.EnableDelayOfEntryByOneBar"); { delay entry trigger by one bar}

ExtFml("TradeSim.InitializeValues"); { always include this call }
ExtFml("TradeSim.AssignValue",PointValue,"S&P",250);

Tally:=Tally + ExtFml( "TradeSim.RecordTrades",
"S&P", { Trade Data Filename }
Short, { Trade Position Type }
EntryTrigger2, { Entry Trigger }
EntryPrice2, { Entry Price }
InitialStop2, { Initial Stop }
ExitTrigger2, { Exit Trigger }
ExitPrice2, { Exit Price }
Continue); { Trade Recorder Control }

Tally;

-------------------------------------------------------

EntryPrice1 := O+((Ref(H,-1)-Ref(L,-1)));
EntryTrigger1 := OPEN;
ExitPrice1 := Close or open;
ExitTrigger1 := Rsi(C,10) > 75 Or O<Ref(C,-1);

InitialStop1 := 0; { optional initial stop }

ExtFml("TradeSim.Initialize"); { Initialize internal variables }
ExtFml("TradeSim.EnableDelayOfEntryByOneBar"); { delay entry trigger by one bar}

ExtFml("TradeSim.InitializeValues"); { always include this call }
ExtFml("TradeSim.AssignValue",PointValue,"S&P",250);

ExtFml( "TradeSim.RecordTrades",
"S&P", { Trade Data Filename }
Long, { Trade Position Type }
EntryTrigger1, { Entry Trigger }
EntryPrice1, { Entry Price }
InitialStop1, { Initial Stop }
ExitTrigger1, { Exit Trigger }
ExitPrice1, { Exit Price }
Start); { Trade Recorder Control }

-------------------------------------------------------

Jose
11th January 2008, 06:26 AM
Your TradeSim/MetaStock code does not have any entry or exit code whatsoever, so it's not surprising that you get error messages. What is it that you are trying to backtest?

Mary, I'm getting the distinct impression that your level of MetaStock/TradeSim programming is below basic - i.e. not suitable for building any trading strategy, no matter how much help you may receive.


jose '-)

mary1
11th January 2008, 02:58 PM
Jose,

Just want to simply buy every trading day if the market price trade to O+((Ref(H,-1)-Ref(L,-1))) entry price.

This does not have entry trigger, just buy every day if market trade to the entry price.

If market does not trade to entry price, there is no trade. If market does trade to entry price, exit at close on the same day

There must be some code in the entry and exit trigger... but the above system does not have entry trigger just buy everyday and filled the order if market trade to the entry price. So put in open for entry trigger and close will exit trigger.

In metastock, there must be too have some code in the formula area for buy instead of just putting O+((Ref(H,-1)-Ref(L,-1))) into the order price. If there are no code, MS have zero trades.

How would you code this simply buy system?

Jose
11th January 2008, 07:20 PM
EntryTarget:=O+(Ref(H,-1)-Ref(L,-1));
EntryTrigger:=C>=EntryTarget;

Hint 1:
Whatever does not seem to work (i.e. plot) in MetaStock, will also not work in TradeSim.

Hint 2:
Entry/Exit signals within the same bar will not work in either apps.


jose '-)

mary1
13th January 2008, 07:12 AM
Jose integrate your code into the system with simple entry C>Ref(C,-1) and exit rule C<Ref(C,-1) but the explorer still having error. No security under the tab. The problem seems to be have to do with dll require the entry price to be within the daily range.

Jose
13th January 2008, 08:42 AM
Works fine at this end, Mary.

Hint 3:
*Always* first plot any signal code as an indicator in MetaStock, in order to verify that it works as intended.

{plots +1/-1 entry/exit signals}
entry:=C>Ref(C,-1);
exit:=C<Ref(C,-1);
entry-exit


jose '-)