Yes, that's clear. I am only using Trail and TrailLock, no changes of stop limit through the TMF. Still it doesn't close the trade at the designated % of profit. Both in "Test" and "Trade" mode. Please see code and picture.

[code][/code]
// ============== Uwe_20131230simple.c ==============

static bool initRun = true;
static int startHour = 8; // 8 is standard
static int endHour = 22; // 22 is standard

set(TICKS);

function run()
{
bool isLookBackPeriod,canTrade,closingHour;

BarPeriod = 2;
BarOffset = 0;

StartDate = 20130730;
EndDate = 20130730;

StartWeek = 10600; // start Monday 6 am
EndWeek = 52200; // end Friday 10 pm
Weekend = 3; // log off during the weekend


// ============== SET TRADING HOURS ==============

isLookBackPeriod = (year()*10000+month()*100+day()<StartDate);

canTrade = workday and lhour(CET,0)>=startHour and lhour(CET,0)<endHour and !(isLookBackPeriod);


// ============== TRADING ==============

bool Cond_LongEntry = priceHigh(0)<priceHigh(1) and rising(price);
bool Cond_ShortEntry = priceLow(0)>priceLow(1) and falling(price);

TrailLock = 90;
Stop = 6;
Trail = Stop;

if(Cond_LongEntry and canTrade and NumOpenLong==0 and NumPendingLong==0){

Entry = priceHigh(0)+Spread;
enterLong();
}

if(Cond_ShortEntry and canTrade and NumOpenShort==0 and NumPendingShort==0){

Entry = priceLow(0)-Spread;
enterShort();
}


// ============== CLOSE ALL POSITIONS AT END OF THE DAY ==============

closingHour = lhour(CET,0)==endHour-1 and minute()==60-2*BarPeriod and (!isLookBackPeriod);

Attached Files
Capture.PNG (123 downloads)