int tmf(var Price) {
return 0;
}
// helper function for finding trades at a grid line
bool findTrade(var Price,var Grid,bool IsShort) {
for(open_trades)
if((TradeIsShort == IsShort)
and between(TradeEntryLimit,Price-Grid/2,Price+Grid/2))
return true;
return false;
}
function run() {
set(LOGFILE);
set(PLOTNOW);
// set(TICKS);
BarPeriod = 1440;
StartDate = 20140101;
EndDate = 20140114;
Hedge = 2;
EntryTime = 50;
Trail = 1000*PIP;
TrailLock = 90;
var Price;
var Grid = 10*PIP; // grid spacing
var Current = priceClose();
// place pending trades at 5 grid lines
// above and below the current price
if (Bar>=LookBack) {
for(Price = Current-5*Grid; Price <= Current+5*Grid; Price += Grid) {
if(Price <= Current and !findTrade(Price,Grid,true)) {
Stop = 10000*PIP;
// enterLong(tmf,-Price);
enterLong(0,Price);
}
else if(Price > Current and !findTrade(Price,Grid,false)) {
Stop = 100*PIP;
// enterShort(tmf,-Price);
enterShort(0,-Price);
}
}
}
}