PureBytes Links
Trading Reference Links
|
I don't have TS6 so this may not be of any help.
>Sell from Entry ("LngEntry") At$ Low - MML points stop;
It appears the example code is using the entryprice in the calculation
something I have always found troublesome in TS4.
In TS4 it's best to keep the word Entryprice out of math calculations.
You can use entryprice directly if it is comparing > < to a
calculation
If (Low + MMS) < Entryprice then
Exitlong("LMMS") next bar at market;
However if you want to include the entryprice in the calculation it
needs to be assigned as a variable.
Var: LngMMS(0);
LngMMS = EntryPrice - MML points
IF MP = 1 then begin
Exitlong("LMMS") next bar at LngMMS points stop;
For testing purposes I always use "next bar at market" to allow for
delays, trigger hesitation or a slow data feed etc.
NS
HTP> This is the exact code regarding "At$" copied directly from the Help
HTP> Index in TS6:
HTP> "At$ (Reserved Word)
HTP> Used in trading strategies to anchor exit prices to the bar where the entry
HTP> order was placed. At$ must be used in conjunction with an entry order that
HTP> has an assigned label.
HTP> Example
HTP> The following order buys when the 10-bar moving average crosses over the
HTP> 20-bar moving average, placing a stop loss order 1 point under the Low of
HTP> the bar where the cross over occurred by appending At$ to the Sell
HTP> statement.
HTP> If Average(Close, 10) Crosses Over Average(Close, 20) then
HTP> Buy ("MA Cross Over") next bar at market;
HTP> Sell from entry ("MA Cross Over") At$ Low - 1 point stop;"
HTP> _______________________________________________________
HTP> Here is my code, nothing complicated as you can see.
HTP> Copy and Paste into any new Strategy, call it "New Strategy" and Press F3.
HTP> Why do I get an error message on the Sell (Exiting the Long position) order
HTP> when the wording appears to match that of the Reserved Word example?
HTP> What is happening that I keep missing?
HTP> Thanks in advance,
HTP> HTP
HTP> Inputs: BZone(70.0), SZone(30.0), Factor(.5), MML(5), MMS(5);
HTP> Vars: MP(0);
HTP> Value1 = StochasticKSlow;
HTP> MP = MarketPosition(0);
IF CurrentBar >> 1 then begin
HTP> IF Time > 830 and Time <= 1500 then begin
HTP> {***LONG ENTRY***}
HTP> IF Value1 > BZone then begin
HTP> BUY ("LngEntry") Next Bar at HIGH + Factor Stop;
HTP> END;
HTP> {***LONG EXIT***}
HTP> IF MP = 1 then begin
HTP> Sell from Entry ("LngEntry") At$ Low - MML points stop;
HTP> END;
HTP> {***SHORT ENTRY***}
HTP> IF Value1 < SZone then begin
HTP> SELL SHORT ("ShtEntry") Next Bar at LOW - Factor Stop;
HTP> END;
HTP> {***SHORT EXIT***}
HTP> IF MP = -1 then begin
HTP> Buy to cover from Entry ("ShtEntry") Next Bar at$ High + MMS points stop;
HTP> END;
HTP> END;
HTP> END;
|