Download MetaTrader 5
To add comments, please log in or register
Publish your application in Cobe Base. Millions of traders will see it!
fxono
68
fxono 2016.03.16 13:30 

Hi,

how check what 500 pips level was last time?

I need set buy if last 500pips level was below curent open bar and sell when was above current bar open.

I have got something like this :

(Please excuse any errors in english.)

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(6);
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---

      int isBuyOpen = 0;
      int isSellOpen = 0;
   
      for (int i = OrdersTotal()-1; i > 0; i--)
      {
         if ( OrderSelect(i, SELECT_BY_POS) )
         {
            if (OrderType() == OP_BUY)isBuyOpen = 1;
            if (OrderType() == OP_SELL)isSellOpen = 1;
         }     
      }
   
        int i = 100;
        double time = 0;
        int level =0;
        int level1 = 0; 
        int level66 = 0;
       
        Print("Next bar time ========= "+ time);
        for(i=1;i<300;i++)
        {

         double high  = High[i];
         double low   = Low[i];
         double open  = Open[i];
         double close = Close[i];
      
         //Print("Prev Bar Open " + DoubleToStr(open) );
         
         level66 = (int)(Ask * 100000/500000);
         level = level66 * 5;
         level1 = level+5;
         
         
         if( close < level || open < level || high < level || low < level && isBuyOpen == 0)
           {
            Alert("UP " + level1 + " DN " + level + " Ostatni level 500Pips " + level + " BUY Position ");
            Print("UP " + level1 + " DN " + level + " Ostatni level 500Pips " + level + " BUY Position ");
           }
           
         
         if( close > level1 || open > level1 || high > level1 || low > level1 && isSellOpen == 0)
           {
            Alert("UP " + level1 + " DN " + level + " Ostatni level 500Pips " + level1 + " SELL Position ");
            Print("UP " + level1 + " DN " + level + " Ostatni level 500Pips " + level1 + " SELL Position ");
         }
                      
        }
        
        
  }
//+------------------------------------------------------------------+
//| Tester function                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
//---
   double ret=0.0;
//---

//---
   return(ret);
  }
//+------------------------------------------------------------------+
Vasyl Nosal
18220
Vasyl Nosal 2016.03.17 23:15  
if(Bid-500*Point>Open[0] || Bid+500*Point<Open[0]) Alert("500");
fxono
68
fxono 2016.03.18 13:46  
Vasyl Nosal:

Thanks, but something like this :

//                                                        fxono.mq4
#property version   "1.0"
#property strict
 
#define MAGICMA  6666
//--- Inputs
input double Lot =1;
input int    sl = 50;
input int    tp = 50;
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+
void CheckForOpen()
  {
   double ma;
   int    res;

   // Here set last 500 pips level (How do it in mql4?)!!!!!!!!!!!!!!!!!
   ma= iOpen(NULL,PERIOD_W1,0);
    
   if(Open[1]<ma && Close[1]<ma)
     {
      res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,ma + sl*Point*10,Bid - tp*Point*10,"",MAGICMA,0,Red);
      return;
     }
//--- buy conditions
   if(Open[1]>ma && Close[1]>ma)
     {
      res=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,ma - sl*Point*10,Ask + tp*Point*10,"",MAGICMA,0,Blue);
      return;
     }
  }
void OnTick()
{
   if(Bars<100)return;  
   if(OrdersTotal() == 0)CheckForOpen();
}


But this

ma= iOpen(NULL,PERIOD_W1,0);

change to last 500 pips level.

How to do it?

Nice day.

Alain Verleyen
Moderator
28659
Alain Verleyen 2016.03.18 14:11  
fxono:

Thanks, but something like this :


But this

change to last 500 pips level.

How to do it?

Nice day.

You should specify what you mean by 500 pips level, provide example(s).
fxono
68
fxono 2016.03.18 15:10  
Alain Verleyen:
You should specify what you mean by 500 pips level, provide example(s).

Hi,

this YellowGreen lines every 500Pips for GBPJPY

500 Pips levels GBPJPY

( 1000 Points = 100 Pips for me :) )


Nice day :)

Siti Latifah
6087
Siti Latifah 2016.03.27 05:49  
fxono:

Hi,

this YellowGreen lines every 500Pips for GBPJPY


( 1000 Points = 100 Pips for me :) )


Nice day :)

If I see your screenshot..

try to search Sweetspot indicator, then you can modaify to put alert at each level.

/
To add comments, please log in or register