PDA

View Full Version : Entering on a buy stop


markcollins
17th December 2006, 02:51 AM
I am new to tradesim and I was wondering if it is possible to set my entry price to occur only if todays price was above yesterdays close. I have used the system test from the tradesim manual and changed the entry price conditions. Is this the correct formula?

EntryTrigger := Cross(MACD(),Mov(MACD(),9,E));
EntryPrice := If(OPEN>Ref(C,-1),OPEN,0);
ExitTrigger := Cross(Mov(MACD(),9,E),MACD());
ExitPrice := CLOSE;
InitialStop:=0; { No Initial Stop used }

ExtFml( "TradeSim.Initialize");
ExtFml( "TradeSim.EnableDelayOfEntryByOneBar");
ExtFml( "TradeSim.SetValue",SystemID,0);
ExtFml( "TradeSim.RecordTrades",
"MACD Crossover Test", { Trade Database Filename }
LONG, { Trade Position Type }
EntryTrigger, { Entry Trigger }
EntryPrice, { Entry Price }
InitialStop, { Optional Initial Stop }
ExitTrigger, { Exit Trigger }
ExitPrice, { Exit Price }
START); { Recorder Control }

Regards
Mark Collins

Jose
18th December 2006, 06:15 PM
Mark, I would code it this way:

---8<-------------------------
slip:=1; { Price slippage % }

EntryTrigger:=Cross(MACD(),Mov(MACD(),9,E)) AND H>Ref(C,-1);
EntryPrice:=Min(If(H>Ref(C,-1),Ref(C,-1)*(1+slip/100),0),H);
{...}
---8<-------------------------


jose '-)

markcollins
19th December 2006, 07:16 PM
Thanks Jose,

I also tried this formula to enter a trade only if the price of today is greater than yesterdays close + 0.25*ATR(25).

EntryPrice :=Ref(C,-1) + (Ref(ATR(25),-1)*0.25);

NewEntryPrice := If(0>EntryPrice,O,EntryPrice)

This formula seems to work.

Regards
Mark Collins