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

Easylanguage coding Problem - Help really appreciated.



PureBytes Links

Trading Reference Links

Firstly sorry about Disclaimer at bottom - can't help it.

How can I get a system to add to a position - For example:

Assume the system is as follows:

- sells 1 contract if the market closes below the 100 day moving average
and buys one contract if the market closes above the 100 day moving
average.

sells further contracts (adds to position) if the market closes above the
10 day moving average whilst in the above trade.

exits all positions if the market closes above the 100 day moving average.

My actual example is as follows: The code is essentially for Wilders
Volatility SAR System (length 21, Factor 3)

I want to code the system to add to the position using a more sensitive
Factor (for example 1.5)  - ie be overall short if the market closes below
the SAR (length 21, Coefficient 3), yet add further shorts to the trade if
the market closes ABOVE the SAR (length 21, Coefficient 1.5)



Code is detailed below:

inputs: Coefficient (3);

Vars:
   VLineUp(0),
   VLineDn(0),
   Highest(0),
   Lowest(0),
   JustChanged(FALSE),
   VLine(0);

Array:
Highs[22](0),
Lows[22](0),
Range[22](0),
UpWave[1](FALSE),
DnWave[1](FALSE);

{MaxBarsBack = 21}

JustChanged = FALSE;

if CurrentBar <= 21 then begin
Highs[CurrentBar] = Close;
Lows[CurrentBar] = Close;
Range[CurrentBar] = (High - Low) /2;
end;

if CurrentBar = 22 then begin
if Highs[21] >= Highs[20] then begin
UpWave[1] = TRUE;
Highest = Highs[21];
VLineUp = Highest - (Coefficient * Average((High - Low),21));
end;

if Highs[21] < Highs[20] then begin
DnWave[1] = TRUE;
Lowest = Lows[21];
VLineDn = Lowest + (Coefficient * Average((High - Low),21));
end;
end;

if CurrentBar > 22 then begin

if DnWave[1] and Close > VLineDn then begin {WAVE CHANGE}
DnWave[1] = FALSE;
UpWave[1] = TRUE;
JustChanged = TRUE;
Highest = Close;
Lowest = 0;
end;

if UpWave[1] and Close < VLineUp and JustChanged = FALSE then begin
{WAVE CHANGE}
UpWave[1] = FALSE;
DnWave[1] = TRUE;
JustChanged = TRUE;
Lowest = Close;
Highest = 0;
end;

if JustChanged = FALSE then begin
if Close > Highest then Highest = Close
else if Close < Lowest then Lowest = Close;
end;

{CALCULATIONS AND PLOT STATMENTS}
VLineUp = Highest - (Coefficient * Average((High - Low),21));
VLineDn = Lowest + (Coefficient * Average((High - Low),21));

if UpWave[1] then buy this bar on close
else if DnWave[1] then sell this bar on close;
end
---------------------------------------------------------------------------
This message (including any attachments) is confidential and may be
privileged. If you have received it by mistake please notify the sender by
return e-mail and delete this message from your system. Any unauthorised
use or dissemination of this message in whole or in part is strictly
prohibited. Please note that e-mails are susceptible to change.
ABN AMRO Bank N.V. (including its group companies) shall not be liable for
the improper or incomplete transmission of the information contained in
this communication nor for any delay in its receipt or damage to your
system. ABN AMRO Bank N.V. (or its group companies) does not guarantee that
the integrity of this communication has been maintained nor that this
communication is free of viruses, interceptions or interference.
---------------------------------------------------------------------------