Quote from Wayne Gibbous:
I think I see a problem here. Looks like you are closing the trades on the same bar as the entry:
<hr> *****ENTRIES ON BAR + 1******
if not (lastpositionactive) and (crossovervalue(bar,HersheyStochK,50) ) and (@#Volume[bar-1]>20000) then begin
{ if (@MACDH[bar]>0) then }buyatmarket(Bar+1,'Jacks friend scott d says to buy here');
end;
if not (lastpositionactive) and (crossundervalue(Bar,HersheyStochK,50)) and (@#Volume[bar-1]>20000) then begin
{ if (@MACDH[bar]<0) then }shortatmarket(Bar+1,'Jacks friend scott d says to sellshort here');
end;
***************THESE SHOULD ALL BE BEFORE THE ENTRY CODE*******
if (positionlong(lastposition)) and (@HersheyStochK[bar]<@HersheyStochD[bar]) and (crossundervalue(Bar,HersheyStochK,80)) then begin
sellatmarket(Bar+1,LastPosition,'');
end;
******EXIT ON BAR + 1*********,
if (positionshort(lastposition)) and (@HersheyStochK[bar]>@HersheyStochD[bar]) and (crossovervalue(Bar,HersheyStochK,20)) then begin
coveratmarket(Bar+1,lastposition,'');
end;
******EXIT ON BAR + 1*****
if (positionlong(lastposition)) and (abs(@HersheyStochD[bar])<1.4) then begin sellatmarket(Bar+1,LastPosition,''); end;
******EXIT ON BAR + 1*****
if (positionshort(lastposition)) and (abs(@HersheyStochD[bar])<1.4) then begin coveratmarket(Bar+1,LastPosition,''); end;
******EXIT ON BAR + 1*****
if (positionlong(lastposition)) and (lastbar(bar)) then begin sellatclose(Bar,lastposition,'');end;
****POSSIBLE EXIT ON BAR BEFORE!!!!!********
if (positionshort(lastposition)) and (lastbar(bar)) then begin coveratclose(Bar,lastposition,'');end;
****POSSIBLE EXIT ON BAR BEFORE!!!!!********<hr>