Hmm I can't find a problem with peeking in my script
It is a TMF which opens a new trade in the opposite direction when stopped out (like the one in the manual)
// TMF that opens an opposite trade when stopped out
int ReverseAtStop11()
{
if(TradeIsStop) { // stop loss hit?
Lots = 97;
if(TradeIsShort)
enterLong(); // enter opposite trade
else
enterShort();
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop10()
{
if(TradeIsStop) { // stop loss hit?
Lots = 72;
if(TradeIsShort)
enterLong(ReverseAtStop11); // enter opposite trade
else
enterShort(ReverseAtStop11);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop9()
{
if(TradeIsStop) { // stop loss hit?
Lots = 54;
if(TradeIsShort)
enterLong(ReverseAtStop10); // enter opposite trade
else
enterShort(ReverseAtStop10);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop8()
{
if(TradeIsStop) { // stop loss hit?
Lots = 41;
if(TradeIsShort)
enterLong(ReverseAtStop9); // enter opposite trade
else
enterShort(ReverseAtStop9);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop7()
{
if(TradeIsStop) { // stop loss hit?
Lots = 31;
if(TradeIsShort)
enterLong(ReverseAtStop8); // enter opposite trade
else
enterShort(ReverseAtStop8);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop6()
{
if(TradeIsStop) { // stop loss hit?
Lots = 23;
if(TradeIsShort)
enterLong(ReverseAtStop7); // enter opposite trade
else
enterShort(ReverseAtStop7);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop5()
{
if(TradeIsStop) { // stop loss hit?
Lots = 17;
if(TradeIsShort)
enterLong(ReverseAtStop6); // enter opposite trade
else
enterShort(ReverseAtStop6);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop4()
{
if(TradeIsStop) { // stop loss hit?
Lots = 13;
if(TradeIsShort)
enterLong(ReverseAtStop5); // enter opposite trade
else
enterShort(ReverseAtStop5);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop3()
{
if(TradeIsStop) { // stop loss hit?
Lots = 10;
if(TradeIsShort)
enterLong(ReverseAtStop4); // enter opposite trade
else
enterShort(ReverseAtStop4);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop2()
{
if(TradeIsStop) { // stop loss hit?
Lots = 7;
if(TradeIsShort)
enterLong(ReverseAtStop3); // enter opposite trade
else
enterShort(ReverseAtStop3);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop1()
{
if(TradeIsStop) { // stop loss hit?
Lots = 5;
if(TradeIsShort)
enterLong(ReverseAtStop2); // enter opposite trade
else
enterShort(ReverseAtStop2);
}
// call the TMF at stop loss / profit target only
return 16;
}
int ReverseAtStop()
{
if(TradeIsStop) { // stop loss hit?
Lots = 4;
if(TradeIsShort)
enterLong(ReverseAtStop1); // enter opposite trade
else
enterShort(ReverseAtStop1);
}
// call the TMF at stop loss / profit target only
return 16;
}
function run()
{
set(TICKS+LOGFILE); // normally needed for TMF
StartDate = 20150101;
EndDate = 20151231;
Weekend = 3; // don't run TMF at weekend
BarPeriod = 1440;
while(asset(loop("GER30"))){
Stop = 60*PIP;
TakeProfit = 180*PIP;
Lots = 10;
var openMonth = priceOpen(20);
vars ATR20 = series(ATR(20));
if((NumOpenLong + NumOpenShort == 0) and ATR20[0] >= 100*PIP){
if(price(0) >= openMonth){
enterLong(ReverseAtStop);
}
else if(price(0) < openMonth){
enterShort(ReverseAtStop);
}
}
}
}
Here is a screenshot of the logfile, in the green lines everything is correct, but in the red lines the trade is closed after one minute, even so no TP or SL was hit (in 1.30 this was not the case)
Also in the last line with the TP, the price should have moved 180 pips in 1 minute, when I check this in the FXCM trading station, this was not the case ?_?