Honolulu + Hawaii / USA
Posts: 18 since Jul 2014
Thanks Given: 16
Thanks Received: 1
|
Aloha,
Trying to have my program sell short the TF, once certain parameters are met. When I go to backtest the strategy it is not performing how I expected, with it selling short and then immediately triggering stop loss on days when there is a ski slope down. What am I missing? Since I am selling short, does the STP and TGT need to be negative?
Mahalo
{short Russell}
Inputs:
Price( Open ),
Length1 ( 12 ),
Length2 ( 15 ),
Cts ( 1 ),
TGT ( 300 ),
STP ( 100 );
Vars:
ExpAv1 ( 0 ),
PrevNetProfit ( 0 ),
PrevNetLoss ( 0 ),
StopTrading (false),
ROC1 ( 0 );
ExpAv1 = XAverage ( Price, Length1 ) ;
ROC1 = ( PRICE - PRICE[Length2] ) / PRICE[Length2] * 100 ; { RATE OF CHANGE }
if Date <> Date [1] then
begin
PrevNetProfit = NetProfit;
StopTrading = false;
end;
if NetProfit >= PrevNetProfit + 100 then StopTrading = true;
if Date <> Date [1] then
begin
PrevNetLoss = GrossLoss;
StopTrading = false;
end;
if GrossLoss >= PrevNetLoss + 80 then StopTrading = true;
{Buy or short sell contracts at exponential average crossovers}
if volume > 2000 and ROC1 < 1 and Price[1] crosses below ExpAv1[1] then
begin
Sellshort ( "sellshort") Cts contracts next bar at market ;
setprofittarget (TGT);
setstoploss (STP);
end;
value97 = text_new ( D, T, ExpAv1, "*" );
text_setcolor (Value97, Cyan);
|