//+------------------------------------------------------------------+ //| VCS-read_up-or-down.mq4 | //| Copyright © 2009, Nonnodom | //| Some code lines are courtesy of ROBERT HILL | //| //| //| //| A.3 : DISEGNA BENE LE FRECCE ED E' OK. Procederemo ad implementare gli ordini per il trading. //| //| A.2 : rinunciato a rilevare il momento dell'inversione. OGNI TANTO RILEVA UNO STATO OPPOSTO (QUANDO LA CHIUSURA č MOMENTANEMANTE DALL'ALTRA PARTE) //| //| A.1 : non rileva bene l'incrocio RIALZISTA //| //|------------------------------------------------------------------+ #property copyright "Copyright © 2009, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ extern int Volty_MALenght = 1; extern int Volty_AtrLenght = 10; extern double Volty_Kv = 1.2; extern double Volty_MoneyRisk = 1.0; extern int offset = 10; datetime bartime=0; // used to determine when a bar has moved int bartick=0; // number of times bars have moved double up = 0.0; double down = 0.0; int i; int n=0; int m=0; string direzione; bool rialzista = 0; int init() { //---- ObjectsDeleteAll(0,OBJ_ARROW); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- // THIS SECTION IS COURTESY OF ROBERT HILL // bar counting if(bartime!=iTime(Symbol(), 0, 0) ) { bartime=iTime(Symbol(), 0, 0) ; bartick++; //uncomment for SINGLE trade per bar //if(OrdersPerSymbol==0) TradeAllowed=true; //uncomment for trade EVERY bar //TradeAllowed=true; //+-----------------------------+ //| Code here will execute once | //| at the OPEN of a NEW BAR | //+-----------------------------+ // Questo č il mio codice up = iCustom(NULL,0,"VoltyChannel_Stop_v2.1",0,Volty_MALenght,0,Volty_AtrLenght,Volty_Kv,Volty_MoneyRisk,0,0); // Buffer for down is 1, not 0 // down = iCustom(NULL,0,"VoltyChannel_Stop_v2.1",0,Volty_MALenght,0,Volty_AtrLenght,Volty_Kv,Volty_MoneyRisk,0,0); down = iCustom(NULL,0,"VoltyChannel_Stop_v2.1",0,Volty_MALenght,0,Volty_AtrLenght,Volty_Kv,Volty_MoneyRisk,1,0); // Alert ("VoltyChannelUP = ", up, " e VoltyChannelDOWN = ", down); double actual_close = iClose(NULL,0,1); // if (up == down && up <= actual_close ) // up and down are never both visible // if (up < 1000 && down > 1000 ) // Check for up visible if (up < 1000) { direzione = "va SU\' => RIALZISTA"; if (rialzista == 0) { Alert ("INVERSIONE RIALZISTA"); n=n+1; if ( !ObjectCreate("ARROWbuy"+n, OBJ_ARROW, 0, iTime(NULL,0,0), Ask+offset*Point) ) { Print ("error; non puņ crere la freccia ARROWbuy"+n," - codice # ", GetLastError() ); //return(0); } else { ObjectSet("ARROWbuy"+n,OBJPROP_STYLE, STYLE_SOLID); ObjectSet("ARROWbuy"+n,OBJPROP_COLOR, Lime); Sleep(Seconds()*100); } } rialzista = 1; } // up and down are never both NOT visible // Check for down visible if (down < 1000 ) { direzione = "va GIU\' => RIBASSISTA"; if (rialzista == 1) { Alert ("INVERSIONE RIBASSISTA"); m=m+1; if ( !ObjectCreate("ARROWsell"+m, OBJ_ARROW, 0, iTime(NULL,0,0), Bid-offset*Point) ) { Print ("error; non puņ crere la freccia ARROWsell"+m," - codice # ", GetLastError() ); //return(0); } else { ObjectSet("ARROWsell"+m,OBJPROP_STYLE, STYLE_DASH); ObjectSet("ARROWsell"+m,OBJPROP_COLOR, Red); Sleep(Seconds()*100); } rialzista = 0; } } Alert ("Mentre Ask=",Ask," e Bid=",Bid," : ICLOSE = ", actual_close, " => VCS Up = ",up, " e VCS Down = ",down," - Dunque ",direzione); // END OF MY CODE LINES //+------------+ //| End Insert | //+------------+ } //---- return(0); } //+------------------------------------------------------------------+