Dave,
LongEntry is a variable
This work is only a test for me, not a valid signal. That the reason for the stop not being moved.
I want to learn how to code for an entry that respond to my criterias
A stop entry on the following bar after a signal bar. Order to be canceled if target not reached.
Sligtly modified code. Quantity to trade modified after each new signal to better show my problem
Now I got duplicate entry and entry done after the order should had been canceled
Code: Select all
[intrabarOrderGeneration = true]
Variables:
BN (0),
Q (10000),
SL (0),
LE (0),
NB (False),
intrabarpersist Goentry (false);
if BN <> BarNumber then begin
NB = True;
BN = Barnumber;
end;
If barstatus = 2 then begin // Make sure the bar as terminated
if TSignal then begin // Look for a valid signal. If found compute the entry and exit
Q=Q + 10000;
LE = H + .0002;
SL = L - .0002;
Goentry = true; // All ok to send the order
end;
end;
// Put an order that should be valid for the entire bar (15 minutes or whatever scale) after the signal
// This section here cause problem. Stop Entry order look to be valid only for the next Tick after
// the order was sent.
If Goentry = True Then begin // Yes, I got the OK to send order
Buy ("Long1") next bars Q contracts at LE stop;
setstoploss (q * (Range + .0002) * bigpointvalue);
end;