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

Coding a stop loss



PureBytes Links

Trading Reference Links

Hi All,

I have a fairly large coding question that I need some help with. I have had
some great help to make the exit part of a system but I want it as an 
indicator.
Would anyone be able to help me fill in the blanks?

Thanks in advance
Paul


Inputs: myDate(1000201), myTime(0900);
Var: Stoploss(0);

{Stop Loss needs 3 bars to initialise}


If {third bar (could be daily or intraday) from the date and time that you 
specify} then begin

	{The next few lines will initialise the stoploss at the left hand }
	{side of the screen}

	If close of the third bar is >= open of the first bar then begin
		Stoploss = lowest low of those three bars;
	End;

	If close of the third bar is < open of the first bar then begin
		Stoploss = highest high of those three bars;
	End;
End;


{The trick is in the next section}
{If the low comes down and equals the stoploss then it would have to
change direction, sort of like how the parabolic stop and reverse stoploss
and system work}

If low > stoploss then begin
	1) Determine the highest close in the up move so far
	2) Count that as bar 1 and go back 2 more bars
	3) None of these bars can be an inside bar
	4) Once all 3 bars have been noted then determine the lowest true low
	of those 3 days
	Stoploss = lowest true low of those 3 days
End;

If high < stoploss then begin
	1) Determine the lowest close in the down move so far
	2) Count that as bar 1 and go back 2 more bars
	3) None of these bars can be an inside bar
	4) Once all 3 bars have been noted then determine the highest true high
	of those 3 days
	Stoploss = highest true high of those 3 days
End;

Plot1(Stoploss,"Stop Loss");