I am having difficulties to set stoploss as i want in my script, for example in this script:
Code: Select all
input:
AVGFAST(50),
AVGMID(100),
AVGSLOW(200);
vars:
maFast(0),
maMid(0),
maSlow(0),
isLongCondtion(false),
entryBarLow(0),
stopLossPrice(0),
takeProfitPrice(0);
maFast = XAverage(close, AVGFAST);
maMid = XAverage(close, AVGMID);
maSlow = XAverage(close, AVGSLOW);
isLongCondtion = (maFast > maMid and maMid > maSlow);
if marketposition = 0 then
begin
if isLongCondtion and close cross above maFast then
begin
entryBarLow = low[0] - 1;
buy next bar at market;
end;
end;
if marketposition = 1 then
begin
if close cross below entryBarLow then
sell next bar at market;
setprofittarget(50);
end;
Many thanks.