Thanks very much for the feedback.
I've tried to look at the ticks flag and tick() function (struggling to get my head around the purpose of TMFs and AssetVar). Would I be correct in thinking that as a series can't be defined within a tick function I would be using it to determine the current price at each tick thus triggering the TP?
The amendment I've made reduces the losses by 5% - I think testing at this level going struggle with slippage. Hope this isn't too messy:
function Scalp()
{
vars Price = series(price());
vars EMA100 = series(EMA(Price,100));
vars EMA50 = series(EMA(Price,50));
vars SOsc = series(Stoch(5,3,MAType_EMA,3,MAType_EMA));
int OscCrossUpp = 80;
int OscCrossLow = 20;
TakeProfit = PIP*7;
Stop = PIP*2;
if(crossUnder(SOsc,OscCrossUpp) && EMA50[0] < EMA100[0] && between(Price[0], EMA50[0],EMA100[0])){
Stop = PIP*3+EMA100[0]-Price[0];
enterShort();
AssetVar[1] = Price[0];
}
else if(crossOver(SOsc,OscCrossLow) && EMA50[0] > EMA100[0] && between(Price[0], EMA100[0],EMA50[0])){
Stop = PIP*3-EMA100[0]+Price[0];
AssetVar[1] = Price[0];
enterLong();
}
}
var CurrentPrice()
{ var Price = price();
return Price;
}
function tick()
{
AssetVar[0] = CurrentPrice();
if(AssetVar[0] <= AssetVar[1]-TakeProfit)
exitShort();
if(AssetVar[0] >= AssetVar[1]+TakeProfit)
exitLong();
//Scalp();
}
function run()
{
set(TICKS); //4234
BarPeriod = 1;
LookBack = 140;
StartDate = 2009;
Spread = 0.2*PIP;
Scalp();
}
I might try optimizing the SL and TP, see if that helps.