//+------------------------------------------------------------------+ //| BigP.mq4 | //| Copyright © 2009, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ #include <commonEA.mqh> double maxValue = -999999999; int MAGIC = 12; int orderType ; int decision () { double x0 = iCustom (NULL,0,"ravi fx fisher",0,0); double x1 = iCustom (NULL,0,"ravi fx fisher",0,1); double x2 = iCustom (NULL,0,"ravi fx fisher",0,2); double y0 = iCustom (NULL,0,"smAdxBars",0,0); double y1 = iCustom (NULL,0,"smAdxBars",0,1); double z0 = iCustom (NULL,0,"smAdxBars",1,0); double z1 = iCustom (NULL,0,"smAdxBars",1,1); double max0 = z0-y0 ; double max1 = z1-y1 ; /* if ( max > maxValue ) { maxValue = max; // diffs(); } */ if ( calculateBuy(0.005) /*max0 > 0.0050 && max1 > 0.0050*/ ) return(1); else return(0); int adx = 0; if ( y1 < z1 && y0 > z0 ) adx = 1; if ( y1 > z1 && y0 > z0 ) adx = -1; //if ( adx != 0 ) Print(" realmente atinginf "); /* if ( x0 > 0.09 && x1 < 0.09 && x2 < -0.09 ) { // Print ( "buy " , adx ); return(1); } if ( x2 > 0.09 && x0 < -0.09 && x1 > -0.09 ) { // Print ( "sell " , adx ); // diffs(); return(-1); } */ // Comment ( x0 , " " , x1 , " " , y0 , " " , y1 , " " , z0 , " " , z1 ); } bool calculateBuy (double value ) { int pos = 0; double vals[14]; int z = 0; for(int i=1;i<14;i++) { double x = iCustom (NULL,0,"smAdxBars",0,i); //azzul double y = iCustom (NULL,0,"smAdxBars",1,i); //vermelho double diff = y -x ; if ( diff > 0 ) { pos++; } else z =i; if ( diff < 0 ) return(false); if ( diff > value) return (false); } //Print("prob " , pos , " %" , z ); return(true); } void diffs (string str) { // double vs[14]; for(int i=0;i<14;i++) { double x = iCustom (NULL,0,"smAdxBars",0,i); //azzul double y = iCustom (NULL,0,"smAdxBars",1,i); //vermelho double diff = y -x ; str = StringConcatenate(str , " , " , diff ); } Print ( str ) ; } int init() { //---- //---- return(0); } double calculateDiff(int i) { double y0 = iCustom (NULL,0,"smAdxBars",0,i); double z0 = iCustom (NULL,0,"smAdxBars",1,i); return ( z0 -y0 ) ; } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- Print ( " max " , maxValue ) ; return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if ( !NewBar() ) return(0); int decision = decision(); if ( OrdersTotal() > 0 ) { if ( orderType == OP_BUY) { double x0 = calculateDiff(0); double x1 = calculateDiff(1); double x2 = calculateDiff(2); if ( x0 < x1 && x1 < x2 ) { OrderClose(ticket,0.1,Bid,3,Red); diffs("closebuy" ); } } if ( decision == 1 && orderType == OP_SELL ) { OrderClose(ticket,0.1,Ask,3,Red); diffs("closesell"); // diffs(); } return(0); } if ( !canTrade() ) return(0); if ( decision == 1 && (TimeCurrent() - lastOrder ) > (60*60*3 ) ) { if ( OrdersTotal() == 0 ) { // // Print("buy " , y0 , " " , y1); // Print("buy ", (x0 - y0)*1000 , " ==>" , l0, " =>", val); ticket = OrderSend(Symbol(),OP_BUY, 0.1, Ask, 3, 0,0/*Ask+50*Point*/,"", MAGIC, 0, Red); lastOrder = TimeCurrent(); diffs("buy"); orderType = OP_BUY; } } else if ( decision == -1 && (TimeCurrent() - lastOrder ) > (60*60*3 ) ) { if ( OrdersTotal() == 0 ) { ticket = OrderSend(Symbol(),OP_SELL, 0.1, Bid, 3, 0,0,"", MAGIC, 0, Red); lastOrder = TimeCurrent(); orderType = OP_SELL; diffs("sell"); } } //---- //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
It Closes Orders by itself
It automatically opens orders when conditions are reached
Other Features: