Sono un appassionato di trading e ho alcune strategie da automatizzare e infatti da pochi mesi sto studiando il linguaggio MQL4!
qualcuno è cosi gentile da aiutarmi? sto cercando di fare un expert che quando un ordine pendente tocca un prezzo fa una sola operazione al giorno.
Se durante la giornata quel prezzo viene ritoccato l'expert non deve più rientrare anche se l'ordine è stato chiuso.
Vi scrivo il codice:
Soltanto che con questo codice che ho scritto funziona solo su una valuta per volta e vorrei farlo andare su più valute insieme
Codice: Seleziona tutto
int start()
{
double HGrid_Pips = 50.0;
double dayH = iHigh(NULL, PERIOD_D1, 0);
double dayL = iLow(NULL, PERIOD_D1,0);
double pipRange=HGrid_Pips *10*Point;
double top1 = (dayH + pipRange) - MathMod(dayH, pipRange);
double top2 = (dayH + pipRange) - MathMod(dayH, pipRange)+ 500 *Point;
double bot1 = dayL - MathMod(dayL, pipRange);
double bot2 = dayL - MathMod(dayL, pipRange)- 500 *Point;
ObjectCreate("topline1",OBJ_HLINE,0,0,top1);
ObjectCreate("topline2",OBJ_HLINE,0,0,top2);
ObjectCreate("botline1",OBJ_HLINE,0,0,bot1);
ObjectCreate("botline2",OBJ_HLINE,0,0,bot2);
{
if (candleHasOrders () == false)
OrderSend(NULL,OP_SELLLIMIT,0.01,top1,0,top1 + 200 *Point,top1 - 50 *Point,NULL,0,0,clrAliceBlue);
}
{
if (candleHasOrders () == false)
OrderSend(NULL,OP_SELLLIMIT,0.01,top2,0,top1 + 200 *Point,top2 - 50 *Point,NULL,0,0,clrAliceBlue);
}
{
if (candleHasOrders () == false)
OrderSend(NULL,OP_BUYLIMIT,0.01,bot1, 0,bot1 - 200 *Point,bot1 + 50 *Point,NULL,0,0,clrAquamarine) ;
}
{
if (candleHasOrders () == false)
OrderSend(NULL,OP_BUYLIMIT,0.01,bot2, 0,bot2 - 200 *Point,bot2 + 50 *Point,NULL,0,0,clrAquamarine) ;}
return(0);
}
bool candleHasOrders(){
for(int i = 3; i < Bars; i++) Ho provato anche con OrdersTotal () soltanto che il risultato non cambia
if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol())
if (iBarShift(NULL, PERIOD_D1, OrderOpenTime() , true) == 0)
return true;
for(int i2 = 0; i2 < OrdersHistoryTotal(); i2++)
if(OrderSelect(i2, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol() == Symbol())
if (iBarShift(NULL, PERIOD_D1, OrderCloseTime(), true) == 0)
return true;
return false;
return false;
}