I develop a intraday strategy like this,
if thisbar's high > the highest of pre 52 bar's high then buy;
if thisbar's low < the lowest of pre 24 bar's low then sell;
if thisbar's low < the lowest of pre 52 bar's low then sellshort;
if thisbar's high > the highest of pre 24 bar's high then buytocover;
concret code:
Code: Select all
[intrabarordergeneration=True]
inputs:fastlen(24),slowlen(52);
vars:tradingtime(false);
tradingtime=time>=1001 and time<=1458;
if marketposition=0 then begin
if high > Highest(high,52)[1] then
buy 1 contract this bar at close;
if tradingtime and low crosses below Lowest(low[1],slowlen) then
sellshort 1 contract next bar at Lowest(low[1],slowlen) limit;
end;
if marketposition>0 then begin
if tradingtime and low crosses below Lowest(low[1],fastlen) then
sell currentcontracts contracts next bar at Lowest(low[1],fastlen) limit;
if not tradingtime then
sell currentcontracts contracts next bar at close limit;
end;
if marketposition<0 then begin
if tradingtime and high crosses above Highest(high[1],fastlen) then
buytocover currentcontracts contracts next bar at Highest(high[1],fastlen) limit;
if not tradingtime then
buytocover currentcontracts contracts next bar at close limit;
end
I wonder what's wrong in my code.
please help me root out bugs in my strategy.
thanks in advance.