PureBytes Links
Trading Reference Links
|
Peter I. asked about:
> IF Close < SwingLow[1] THEN begin;
> Sell 2 Contracts;
>
> IF MarketPosition < 0 AND SwingLow[1] <= SwingLow[2] THEN
> Sell 5 Contracts;
> end;
The syntax is wrong for the swinglow function. Check the online
documentation.
---------------
Function:
SwingLow(OCCUR,PRICE,STRENGTH,LENGTH)
Parameters:
OCCUR which occurrence (i.e., 1 = most recent, 2 = 2nd most recent, and
so on)
PRICE specifies which price of the asset of interest is to be used
STRENGTH specifies required number of bars on either side of swing bar
LENGTH specifies the number of trailing bars to consider
Returns:
The specified Swing Low value, or -1 if not found
-----------------
For your purposes, it might be more efficient to use the swinglowbar
function.
The advantage... you don't have to look back as many bars and the code
will
run faster.
-----------------
Function:
SwingLowBar(OCCUR,PRICE,STRENGTH,LENGTH)
Parameters:
OCCUR which occurrence (i.e., 1 = most recent, 2 = 2nd most recent, and
so on)
PRICE specifies which price of the asset of interest is to be used
STRENGTH specifies required number of bars on either side of the swing
bar
LENGTH specifies the number of trailing bars to consider
Returns:
The number of bars ago specified Swing Low value occurred, or -1 if not
found
------------------
input: stren(1);
var: sl(99999);
mp = marketposition;
if swinglowbar(1,low,stren,stren+1) = stren then begin
sl = low[stren];
if sl > sl[1] then sl = sl[1];
end;
if c < sl and sl < 99999 then begin
if marketposition >= 0 then sell 2 contacts
else sell 5 contracts;
end;
You will need to reset sl to 99999 if you go long.
I don't think you need an array but you can study the trendlines
automatic
indicator for the use of swinglowbar, loops and arrays.
--
Dennis
|