Quote from bwolinsky:
I guess I'm missing the close out EOD spot, so I'll have to come back and redo the backtests. But you want to know what I think before I do that? It's not going to help in the least bit. I think that will put it over the edge to unprofitable, even though it's already there.
Here it is with a sell on the close. It does look like the EOD exit helped results, and I probably don't need the 3% stop anymore:
for Bar := 5 to BarCount - 1 do
begin
var SMADiff : float =(SMA( bar, #close , 20 ) - SMA( bar - 1, #close, 20 ));
var MACDday : integer = MACDExSeries( #Close, val1, val2 );
if lastbar(bar) then begin
lbar:=bar;
end;
if (bar>lbar+2) and (gettime(bar)<1600) and (@#Volume[bar]>20000) then begin
if not (lastpositionactive) and (crossovervalue(bar,HersheyStochK,50)) then begin
buyatmarket(Bar+1,'Jacks friend scott d says to buy here');
end;
if not (lastpositionactive) and (crossundervalue(Bar,HersheyStochK,50)) then begin
shortatmarket(Bar+1,'Jacks friend scott d says to sellshort here');
end;
if (positionlong(lastposition)) and (@HersheyStochK[bar]<@HersheyStochD[bar]) and (crossundervalue(Bar,HersheyStochK,80)) then begin
sellatmarket(Bar+1,LastPosition,'');
end;
if (positionshort(lastposition)) and (@HersheyStochK[bar]>@HersheyStochD[bar]) and (crossovervalue(Bar,HersheyStochK,20)) then begin
coveratmarket(Bar+1,lastposition,'');
end;
if (positionlong(lastposition)) and (abs(@HersheyStochD[bar]-SMA(Bar,HersheyStochD,6))<1.4) then begin sellatmarket(Bar+1,LastPosition,''); end;
if (positionshort(lastposition)) and (abs(@HersheyStochD[bar]-SMA(Bar,HersheyStochD,6))<1.4) then begin coveratmarket(Bar+1,LastPosition,''); end;
if (gettime(Bar)=1555) and positionlong(lastposition) then sellatmarket(Bar+1,#All,'');
if (gettime(Bar)=1555) and positionshort(lastposition) then coveratmarket(Bar+1,#All,'');
end;
end;