最後有把指標寫出來,給有需要的人參考。
inputs:
len_latern(25),
len_atr(50),
len(50),
coef(2);
vars:
cond5(False),
cond6(False),
call_stop(H),
put_stop(L),
Pos_H(0),
Pos_L(0),
var1(0),
var2(0),
status(0);
if CurrentBar = 100 then
begin
Pos_H = H ;
Pos_L = L ;
status = 0;
// call_stop = Pos_H - 100;
// put_stop = Pos_L + 100;
end ;
if currentbar = 100 then
begin
Pos_H = H ;
call_stop = Pos_H - coef * AvgTrueRange(len); // Call stop line
Pos_L = L ;
put_stop = Pos_L + coef * AvgTrueRange(len); // Put stop line
end;
if currentbar > 100 then
begin
if status = 1 and H > Pos_H then // Do the call
begin
Pos_H = H ;
call_stop = Pos_H - coef * AvgTrueRange(len); // Call stop line
end;
if status = -1 and L < Pos_L then // Do the put
begin
Pos_L = L ;
put_stop = Pos_L + coef * AvgTrueRange(len); // Put stop line
end;
// call_stop = highest(h,len_latern) - coef * AvgTrueRange(len_atr); // Call stop line
// put_stop = lowest(l,len_latern) + coef * AvgTrueRange(len_atr); // Put stop line
if c cross below call_stop then begin
status = -1;
Pos_L = L ;
put_stop = Pos_L + coef * AvgTrueRange(len); // Put stop line
end;
if c cross above put_stop then begin
status = 1;
Pos_H = H ;
call_stop = Pos_H - coef * AvgTrueRange(len); // Call stop line
end ;
end;
if status = 1 then begin
plot1(call_stop,"",RED);
// plot4(Pos_H,"",YELLOW);
end;
if status = -1 then begin
Plot2(put_stop,"",GREEN);
// Plot3(Pos_L,"",BLUE);
end;
|