I m posting this simple strategy to ask someone an advice or.

It is on supertrend indicator contrarian.

it works more o less and close all at 16.00but I m not able to setting to exit when the profit pr loss is 100 euro for example.

to me is just good if is reach 100 profit so ,if someone has some good advice is welcome.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Code: Select all

` [LegacyColorValue = TRUE];`

inputs:

ATRLength(1.5), ATRMult(4.9), UpColor(cyan), DnColor(magenta),

starttrade (0800),

endtrade(1600),

dailyprofit(500),

dailyloss(250);

vars:

ATR(0),

avg(0),

dn(0),

up(0),

trend(1),

flag(0),

flagh(0),

SuperTrend(0),

todaynet(0),

yesterdaynet(0);

if date <> date[1] then begin

yesterdaynet = NetProfit;

end;

ATR = AvgTrueRange(ATRLength) * ATRMult;

avg = (high + low)/2;

up = avg + ATR;

dn = avg - ATR;

if close > up[1] then

trend = 1

else if close < dn[1] then

trend = -1;

if trend < 0 and trend[1] > 0 then flag=1 else flag=0;

if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0;

if trend > 0 and dn < dn[1] then dn=dn[1];

if trend < 0 and up > up[1] then up=up[1];

if flag = 1 then up = avg + ATR;

if flagh = 1 then dn = avg - ATR;

todaynet = NetProfit + openpositionprofit - yesterdaynet;

condition98 = (-dailyloss < todaynet and todaynet < dailyprofit) and (Time > starttrade and time < endtrade);

if condition98 then begin

if trend = 1 and trend[1]< 0 Then sellshort next bar at open;

if trend = -1 and trend[1]< 0 then buy next bar at open;

end;

if trend = 1 and time >endtrade then buy to cover this bar Close;

if trend = -1 and time >endtrade then sell this bar close;