montreal, qc, canada
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18
|
Here is the main logic of what I would code. This assumes that you will sell the balance of your position if the Price is still below 9EMA
If Price crosses below 9EMA AND Var_sharestosell = 100
then begin
sell 50% of my shares;
Var_barnumber = bar number + 15;
Var_sharestosell = 50;
end;
If Price below 9EMA AND bar number >= Var_barnumber AND Var_sharestosell = 50
then begin
sell 50% of my shares;
Var_sharestosell = 0;
end;
// at some point in your code Var_sharestosell will have to be reset to = 100 .... likely when you buy
// This is far from complete but it is a start ...
|