MQ4 CODIGOS EA, QUE TIENEN MUY BUENA PINTA PERO NO CONSIGO..
Publicado: 10 Jul 2008 11:41
Buenas a todos y a todas ;).
me llamo jordi y desde hace un mes aproximadamente que estoy investigando el tema de los Expert Advisor y los Indicadores.
Hasta el momento he estado probando EA, y bueno he encontrado unos codigos de EA, que parecen tener muy buena pinta pero que al compilar me petan. No tengo ni idea de Mq4 aunque intento aprender buscando informacion aqui alla.. el tito google... etc (ya que lo mio es encontrar) pero beno al grano.
Aqui dejo el primer codigo que me peta con 5 errores.
En el primer error me dice algo de double quote nedded en un apartado en el que parece faltar algo entre parentesis antes de un ;
los siguientes errores se refieren todos a los datos GMT+2?);
Ire posteando haber si alguien le encuentra solucion al tema y empiezan ya las pruevas XD. un saludo
/*[[
Name := FAB4X 3*7*21 System
Author := Fabio Lio Copyright © DEC 2004
Link := RUN ONLY ON A 15MIN CHART.GBP/USD BEST
Lots := 1.00
Stop Loss := 0
Take Profit := 50
Trailing Stop := 15
]]*/
Input : FastPeriod(7), SlowPeriod(21);
Input : FastPeriodX(3), SlowPeriodX(21);
Input : FastPeriodE(3), SlowPeriodE(7);
Defines : risk(10),mm(1),settime(15),endtime(23);
Variable : shift(0);
Variable : iMASlowPrevious(0), iMaSlowCurrent(0), iMaFastPrevious(0), iMaFastCurrent(0);
Variable : iMASlowPreviousE(0), iMaSlowCurrentE(0), iMaFastPreviousE(0), iMaFastCurrentE(0);
Variable : iMASlowPreviousX(0), iMaSlowCurrentX(0), iMaFastPreviousX(0), iMaFastCurrentX(0);
Variable : val1(0), val2(0);
Variables : EACross1(0),EACross2(0),Current(0),cnt(0);
Var : TR(0),TR1(0),TR2(0),TRPREV(0);
var: myFileName(” “),myFile(0);
var: alertTime(”"),;
var: OrderText(”"),AlertText(”");
var: lotsi(0);
var: vMode11(0);
var: vMode12(0);
myFileName=Symbol + Period + ” FAB4X3721?;
//MONEY MANAGEMENT
if mm<>0 then
lotsi=Ceil(Equity*risk/10000)/10
else
lotsi=lots;
vMode11 = iCustom(”iTrend”,0,0,0,20,2,5,MODE_FIRST,0);
vMode12 = iCustom(”iTrend”,0,0,0,20,2,5,MODE_SECOND,0);
//IF bars<250 then exit;
If (DayOfWeek <2 or DayOfWeek >6 or hour < 15 or hour >22) then exit;
if TotalTrades < 1 then
{
iMaSlowPrevious = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrent = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPrevious = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrent = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
If iMaFastPrevious<iMaSlowPrevious and iMaFastCurrent>iMASlowCurrent and vMode11= 1 and vMode12= 0 then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to buy “,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Buy “,Symbol,” @”,OPEN, ” “, AlertText);
SetOrder(OP_BUY,lotsi,OPEN,3,0,OPEN+TakeProfit*Point,Green);
};
If iMaFastPreviousX>iMaSlowPreviousX and iMaFastCurrentX<iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,pricebid, ” “, AlertText);
};
If iMaFastPreviousE>iMaSlowPreviousE and iMaFastCurrentE<iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING SHORT “,Symbol,” @”,pricebid, ” “, AlertText);
};
If iMaFastPrevious>iMaSlowPrevious and iMaFastCurrent<iMASlowCurrent and vMode11= 0 and vMode12= -1 Then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to sell”,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Sell “,Symbol,” @”,OPEN,AlertText);
SetOrder(OP_SELL,lotsi,OPEN,3,0,OPEN-TakeProfit*Point,RED);
};
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPreviousE<iMaSlowPreviousE and iMaFastCurrentE>iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING LONG “,Symbol,” @”,priceask, ” “, AlertText);
};
};
///////////////Allow For Attachment to more than one Chart
If TotalTrades > 0 then
{
Current = 0;
for cnt = 1 to TotalTrades
Begin
If Not Ord(cnt,VAL_SYMBOL) = Symbol then
{
Current = Current+1; // if this trade is NOT in the currency pair that the advisor is attached to than add 1 to Current
}
else
{
if Ord(cnt,VAL_SYMBOL) = Symbol then
{
iMaSlowPreviousE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
If iMaFastPreviousX>iMaSlowPreviousX and iMaFastCurrentX<iMASlowCurrentX Then
{
if Ord(cnt,VAL_TYPE) = OP_BUY then
{
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),pricebid,3,Red);
exit;
};
};
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
if Ord(cnt,VAL_TYPE) = OP_SELL then
{
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),priceask,3,Red);
exit;
}; };
};
};
End;
If Current = TotalTrades then // There are NO open positions in the currency pair that the advisor is attached to
{
iMaSlowPrevious = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrent = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPrevious = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrent = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
If iMaFastPrevious<iMaSlowPrevious and iMaFastCurrent>iMASlowCurrent and vMode11= 1 and vMode12= 0 Then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to buy “,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Buy “,Symbol,” @”,OPEN, ” “, AlertText);
SetOrder(OP_BUY,lotsi,OPEN,3,0,OPEN+TakeProfit*Point,GREEN);
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPreviousE<iMaSlowPreviousE and iMaFastCurrentE>iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING SHORT “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPrevious>iMaSlowPrevious and iMaFastCurrent<iMASlowCurrent and vMode11= 0 and vMode12= -1 Then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to sell “,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Sell “,Symbol,” @”,OPEN,AlertText);
SetOrder(OP_SELL,lotsi,OPEN,3,0,OPEN-TakeProfit*Point,RED);
};
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPreviousE<iMaSlowPreviousE and iMaFastCurrentE>iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING LONG “,Symbol,” @”,priceask, ” “, AlertText);
};
};
};
///////////////End Allow For Attachment to more than one Chart
//////////////////////////////////////////////////////////
/////////////////////////Trailing Stop Code /////////////////////
//////////////////////////////////////////////////////////
If TotalTrades > 0 then
{
for cnt = 1 to TotalTrades
Begin
If Ord(cnt,VAL_TYPE)=OP_BUY then
{
///////////////////
If Ord(cnt,VAL_SYMBOL)= Symbol then
{
If Ord(cnt,VAL_OPENPRICE) + TrailingStop*Point < Bid Then
{
If Ord(cnt,VAL_STOPLOSS)<(Bid-TrailingStop*Point) then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),
Bid-TrailingStop*Point,Ord(cnt,VAL_TAKEPROFIT),Red);
Exit;
};
};
If Ord(cnt,VAL_TAKEPROFIT) = 0 Then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),
Ord(cnt,VAL_OPENPRICE)-StopLoss*Point,Ord(cnt,VAL_OPENPRICE)+TakeProfit*Point,Red);
Exit;
};
};
};// End of BUY
If Ord(cnt,VAL_TYPE)=OP_SELL then
{
///////////////////
If Ord(cnt,VAL_SYMBOL)= Symbol then
{
If Ord(cnt,VAL_OPENPRICE) - TrailingStop*Point > Ask Then
{
If Ord(cnt,VAL_STOPLOSS)>(Ask+TrailingStop*Point) then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ask+TrailingStop*Point,
Ord(cnt,VAL_TAKEPROFIT),White);
Exit;
};
};
If Ord(cnt,VAL_TAKEPROFIT) = 0 Then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),
Ord(cnt,VAL_OPENPRICE)+StopLoss*Point,Ord(cnt,VAL_OPENPRICE)-TakeProfit*Point,Red);
Exit;
};
};
};//End of Sell
End;
};
};
me llamo jordi y desde hace un mes aproximadamente que estoy investigando el tema de los Expert Advisor y los Indicadores.
Hasta el momento he estado probando EA, y bueno he encontrado unos codigos de EA, que parecen tener muy buena pinta pero que al compilar me petan. No tengo ni idea de Mq4 aunque intento aprender buscando informacion aqui alla.. el tito google... etc (ya que lo mio es encontrar) pero beno al grano.
Aqui dejo el primer codigo que me peta con 5 errores.
En el primer error me dice algo de double quote nedded en un apartado en el que parece faltar algo entre parentesis antes de un ;
los siguientes errores se refieren todos a los datos GMT+2?);
Ire posteando haber si alguien le encuentra solucion al tema y empiezan ya las pruevas XD. un saludo
/*[[
Name := FAB4X 3*7*21 System
Author := Fabio Lio Copyright © DEC 2004
Link := RUN ONLY ON A 15MIN CHART.GBP/USD BEST
Lots := 1.00
Stop Loss := 0
Take Profit := 50
Trailing Stop := 15
]]*/
Input : FastPeriod(7), SlowPeriod(21);
Input : FastPeriodX(3), SlowPeriodX(21);
Input : FastPeriodE(3), SlowPeriodE(7);
Defines : risk(10),mm(1),settime(15),endtime(23);
Variable : shift(0);
Variable : iMASlowPrevious(0), iMaSlowCurrent(0), iMaFastPrevious(0), iMaFastCurrent(0);
Variable : iMASlowPreviousE(0), iMaSlowCurrentE(0), iMaFastPreviousE(0), iMaFastCurrentE(0);
Variable : iMASlowPreviousX(0), iMaSlowCurrentX(0), iMaFastPreviousX(0), iMaFastCurrentX(0);
Variable : val1(0), val2(0);
Variables : EACross1(0),EACross2(0),Current(0),cnt(0);
Var : TR(0),TR1(0),TR2(0),TRPREV(0);
var: myFileName(” “),myFile(0);
var: alertTime(”"),;
var: OrderText(”"),AlertText(”");
var: lotsi(0);
var: vMode11(0);
var: vMode12(0);
myFileName=Symbol + Period + ” FAB4X3721?;
//MONEY MANAGEMENT
if mm<>0 then
lotsi=Ceil(Equity*risk/10000)/10
else
lotsi=lots;
vMode11 = iCustom(”iTrend”,0,0,0,20,2,5,MODE_FIRST,0);
vMode12 = iCustom(”iTrend”,0,0,0,20,2,5,MODE_SECOND,0);
//IF bars<250 then exit;
If (DayOfWeek <2 or DayOfWeek >6 or hour < 15 or hour >22) then exit;
if TotalTrades < 1 then
{
iMaSlowPrevious = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrent = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPrevious = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrent = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
If iMaFastPrevious<iMaSlowPrevious and iMaFastCurrent>iMASlowCurrent and vMode11= 1 and vMode12= 0 then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to buy “,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Buy “,Symbol,” @”,OPEN, ” “, AlertText);
SetOrder(OP_BUY,lotsi,OPEN,3,0,OPEN+TakeProfit*Point,Green);
};
If iMaFastPreviousX>iMaSlowPreviousX and iMaFastCurrentX<iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,pricebid, ” “, AlertText);
};
If iMaFastPreviousE>iMaSlowPreviousE and iMaFastCurrentE<iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING SHORT “,Symbol,” @”,pricebid, ” “, AlertText);
};
If iMaFastPrevious>iMaSlowPrevious and iMaFastCurrent<iMASlowCurrent and vMode11= 0 and vMode12= -1 Then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to sell”,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Sell “,Symbol,” @”,OPEN,AlertText);
SetOrder(OP_SELL,lotsi,OPEN,3,0,OPEN-TakeProfit*Point,RED);
};
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPreviousE<iMaSlowPreviousE and iMaFastCurrentE>iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING LONG “,Symbol,” @”,priceask, ” “, AlertText);
};
};
///////////////Allow For Attachment to more than one Chart
If TotalTrades > 0 then
{
Current = 0;
for cnt = 1 to TotalTrades
Begin
If Not Ord(cnt,VAL_SYMBOL) = Symbol then
{
Current = Current+1; // if this trade is NOT in the currency pair that the advisor is attached to than add 1 to Current
}
else
{
if Ord(cnt,VAL_SYMBOL) = Symbol then
{
iMaSlowPreviousE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
If iMaFastPreviousX>iMaSlowPreviousX and iMaFastCurrentX<iMASlowCurrentX Then
{
if Ord(cnt,VAL_TYPE) = OP_BUY then
{
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),pricebid,3,Red);
exit;
};
};
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
if Ord(cnt,VAL_TYPE) = OP_SELL then
{
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),priceask,3,Red);
exit;
}; };
};
};
End;
If Current = TotalTrades then // There are NO open positions in the currency pair that the advisor is attached to
{
iMaSlowPrevious = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrent = iMAEx(SlowPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPrevious = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrent = iMAEx(FastPeriod, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentE = iMAEx(SlowPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentE = iMAEx(FastPeriodE, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaSlowPreviousX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaSlowCurrentX = iMAEx(SlowPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
iMaFastPreviousX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 1);
iMaFastCurrentX = iMAEx(FastPeriodX, MODE_EMA, 0, PRICE_CLOSE, 0);
If iMaFastPrevious<iMaSlowPrevious and iMaFastCurrent>iMASlowCurrent and vMode11= 1 and vMode12= 0 Then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to buy “,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Buy “,Symbol,” @”,OPEN, ” “, AlertText);
SetOrder(OP_BUY,lotsi,OPEN,3,0,OPEN+TakeProfit*Point,GREEN);
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPreviousE<iMaSlowPreviousE and iMaFastCurrentE>iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING SHORT “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPrevious>iMaSlowPrevious and iMaFastCurrent<iMASlowCurrent and vMode11= 0 and vMode12= -1 Then
{
myFile = FileOpen(myFileName,”,”);
FileWrite(myFile, “It is a good time to sell “,symbol,”@”,OPEN + hour +”:”+ Minute + “:” + Seconds +” GMT+2?);
FileClose(myFile);
Alert(Month,”/”,Day,” “,alertTime,” Sell “,Symbol,” @”,OPEN,AlertText);
SetOrder(OP_SELL,lotsi,OPEN,3,0,OPEN-TakeProfit*Point,RED);
};
If iMaFastPreviousX<iMaSlowPreviousX and iMaFastCurrentX>iMASlowCurrentX Then
{
Alert(Month,”/”,Day,” “,alertTime,” EXIT NOW “,Symbol,” @”,priceask, ” “, AlertText);
};
If iMaFastPreviousE<iMaSlowPreviousE and iMaFastCurrentE>iMASlowCurrentE Then
{
Alert(Month,”/”,Day,” “,alertTime,” TRADE NOW GOING LONG “,Symbol,” @”,priceask, ” “, AlertText);
};
};
};
///////////////End Allow For Attachment to more than one Chart
//////////////////////////////////////////////////////////
/////////////////////////Trailing Stop Code /////////////////////
//////////////////////////////////////////////////////////
If TotalTrades > 0 then
{
for cnt = 1 to TotalTrades
Begin
If Ord(cnt,VAL_TYPE)=OP_BUY then
{
///////////////////
If Ord(cnt,VAL_SYMBOL)= Symbol then
{
If Ord(cnt,VAL_OPENPRICE) + TrailingStop*Point < Bid Then
{
If Ord(cnt,VAL_STOPLOSS)<(Bid-TrailingStop*Point) then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),
Bid-TrailingStop*Point,Ord(cnt,VAL_TAKEPROFIT),Red);
Exit;
};
};
If Ord(cnt,VAL_TAKEPROFIT) = 0 Then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),
Ord(cnt,VAL_OPENPRICE)-StopLoss*Point,Ord(cnt,VAL_OPENPRICE)+TakeProfit*Point,Red);
Exit;
};
};
};// End of BUY
If Ord(cnt,VAL_TYPE)=OP_SELL then
{
///////////////////
If Ord(cnt,VAL_SYMBOL)= Symbol then
{
If Ord(cnt,VAL_OPENPRICE) - TrailingStop*Point > Ask Then
{
If Ord(cnt,VAL_STOPLOSS)>(Ask+TrailingStop*Point) then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ask+TrailingStop*Point,
Ord(cnt,VAL_TAKEPROFIT),White);
Exit;
};
};
If Ord(cnt,VAL_TAKEPROFIT) = 0 Then
{
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),
Ord(cnt,VAL_OPENPRICE)+StopLoss*Point,Ord(cnt,VAL_OPENPRICE)-TakeProfit*Point,Red);
Exit;
};
};
};//End of Sell
End;
};
};