[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stop Loss Code



PureBytes Links

Trading Reference Links

Hello NoddyHoddler,
Here is some money management stop code for TS4.
best regards
foolsgold

{ Indicator Money Management Stop }
Input: { Money Management Stop }  MMStp(.6);
Vars: { Money Management Stop } LngMMS(0), ShtMMS(0);
LngMMS = (I_AvgEntryPrice-MMStp);
ShtMMS = (I_AvgEntryPrice+MMStp);
if I_marketposition =1 then begin
plot1(LngMMS,"LngMMStop");
end;
if I_marketposition =-1 then begin
plot2(ShtMMS,"ShtMMStop");
end;
{Format Indicator / Style/ Type/ {Set as point))

******************

{ System Money Management Stop }
Input: { Money Management Stop } MMStp(.6);
  { Insert entry code here, for example }
if average(close,9) crosses over average(close,18) then buy next bar at market;
if average(close,9) crosses under average(close,18) then sell next bar at market;
  
if MarketPosition(0)=1 then begin
if (low+MMStp) < Entryprice then
ExitLong("LngMMStp") next bar at market;
end;
if MarketPosition(0)=-1 then begin
if (high-MMStp) > Entryprice then
ExitShort("ShtMMStp") next bar at market;
end;


Nac> I'm having problems writing a stop loss used on S&P Intraday data. The signal buys at the previous  High and my stop is the low of the Setup Bar (previous Low).  The stop signal works unless the
Nac> Low of the Entry Bar takes out the Low of the Setup Bar., which leaves me with an unrealistic trade of entering and exiting on the same bar.  Below are a few of my attempts at coding the stop. 
Nac> Any help would be greatly appreciated.  Thanks/Noddy
Nac> ExitLong ("Break LowStop")from entry ("Break")
Nac>    next bar at$  stop;
Nac> ExitLong ("Break LowStop")from entry ("Break")
Nac>    at$  stop;
Nac>  If Time > entrytime then begin
Nac>   ExitLong ("Break LowStop")from entry ("Break")
Nac>    next bar at$  stop;
Nac> End;
If BarsSinceEntry >>= 1 then ExitLong ("Break LowStop")from entry ("Break")
Nac>    next bar at$  stop;