View Full Version : Entry Date
Dave
23rd September 2003, 10:33 PM
I am trying to work out an exit price based on a 0.10 move from the entry price.
Is there a way to reference the entry price on a position so I can calculate an exit price?
David Samborsky
23rd September 2003, 11:42 PM
Hello Dave
Unfortunately the way that Metastock language is aranged there is simply no easy way to this.
However TradeSim comes to the rescue with the SetProfitStop function which exits a trade when a profit gain threshold has been exceeded.
SetProfitStop ExtFml(“TradeSim.SetProfitStop”,ProfitThreshol d%);
This function is used to automatically exit a trade irrespective of the ExitTrigger when a profit threshold exceeds an amount determined by the ProfitThreshold parameter. The ProfitThreshold parameter must be positive and is expressed in percentage. The profit calculation takes into account which side of the market (Long or short) the trade has been taken and the profit threshold is always referenced to the entry criteria. When a trade is exited in this manner the trade is flagged in the database and is shown in the TradeSim Trade Database Manager as a profit stop. A call to the Initialize function disables the effects to a call to this function. For long trades a profit stop is generated when the following criteria is satisfied:-
(100 x (XP – EP)/EP) > PercentProfitThreshold
For short trades a profit stop is generated when the following criteria is satisfied:-
(100 x (EP – XP)/EP) > PercentProfitThreshold
where:- EP is the value of the EntryPrice parameter in the RecordTrades function at the point of entry into the trade.
XP is the value of ExitPrice parameter in the RecordTrades function when the above relationship is satisfied.
Note. The true profit is never known until a simulation is actually run due to transaction costs and slippage.
Example The following example sets up the RecordTrades function to automatically exit a trade when the open trade profit exceeds 10 percent.
ExtFml(“TradeSim.SetProfitStop”,10);
Dave
24th September 2003, 02:10 AM
Thanks for the info David. That gives me many ideas.
But couldn't I use the initial stop function to exit by calculating 10 cents from the entry price by using the entry price calculations I already have?
eg
EntryPrice = yesterdays high + 0.02
InitialStop = EntryPrice +0.08
Dave
24th September 2003, 02:26 AM
Another question...
Do I set a variable as
SetProfitStop:=ExtFml(“TradeSim.SetProfitStop” ,ProfitThreshold%);
or
do I use the
ExtFml(“TradeSim.SetProfitStop”,ProfitThreshol d%) line after the
ExtFml( "TradeSim.Initialize");
line??
David Samborsky
24th September 2003, 12:11 PM
Always make
ExtFml( "TradeSim.Initialize");
the first in a series of commands because this resets all internal variables to their default inactive state.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.