i want to have add position for a long strategy, using the following scripts, but doesn't work.
Code: Select all
input: AddFunction(True), StopLoss(50);
if AddFunction then
begin
if marketposition = 1 then
begin
if (High - entryprice) > StopLoss then
buy("L-Add") next bar market;
end;
what i want is that, after entering a trade, say like buy at 15000, then the system keep adding at price like 15050, 15100, 15150, etc.
adding every 50 points.
you may notice that from the entry point, after the price move up for 50pts, the signal keep buying one more contract every bar afterward( 5mins chart)
i noticed that maybe i've got some wrong understanding about "entryprice", i thought that "entryprice" will return the value of the buy price of the latest long contract, but it seems not, it can only returns the first long contract's buy price from the chart above.....
so i modified part of the code, like using new variable "addlevel" and add a loop like " addlevel = addlevel+50" to manually calculate the latest reference level, but the result is that the add Function completely failed to work....the modified script and screenshot shown below for your reference.
Code: Select all
input: AddFunction(True), StopLoss(50);
var: addlevel(entryprice);
if AddFunction then
begin
if marketposition = 1 then
begin
if (High - addlevel) > StopLoss then
buy("L-Add") next bar market;
addlevel = addlevel + StopLoss;
end;
ps:
1. the EOD exit signal is just a signal that close all existing opening position on daily session close, no big deal with the problem.
2. AddFunction is a switch that turn on and off the add function of the strategy
3. variable StopLoss is a constant in this case, so it's just a value "50"
any idea guys? thank you!