sample code

anyone has a sample code for the following?

buy whn stoch<30 and exit 5 bars from entry

if next day stoch is <30 buy another unit and exit 5 bars from entry

if next next day stoch is <30 buy another unit and exit 5 bars from entry

try code them but the second and third entry all exit at the first exit altogether rather 5 bars from entry
 
anyone has a sample code for the following?

buy whn stoch<30 and exit 5 bars from entry

if next day stoch is <30 buy another unit and exit 5 bars from entry

if next next day stoch is <30 buy another unit and exit 5 bars from entry

try code them but the second and third entry all exit at the first exit altogether rather 5 bars from entry

add entry date and then do a diff
 
Come up with this code but is not dynamic

Any bars with stoch above 30 render the subsequent signals not registered

Anyone would tweak the code to account all signals?

If Count1 = 0 and Count2 = 0 and Count3 = 0 and Stock < 30 then begin
Buy x shares this bar on close;
Count1 = BarNumber
end;

If Count1 <> 0 and BarNumber >= Count1 + 5 then begin
Sell X shares this bar on close;
Count1 = 0;
end;

If Count1 <> 0 and BarNumber = Count1 + 1 and Count2 = 0 and Stoch < 30 then Begin
Buy x shares this bar on close;
Count2 = BarNumber
end;

If Count2 <> 0 and BarNumber >= Count2 + 5 then begin
Sell X shares this bar on close;
Count2 = 0;
end;
 
try commenting your pseudo code to get a clearer picture of what you're doing.

for example, why are you using 3 counts? what are you trying to achieve with each loop? why is it there ?
 
Back
Top