How check what level was last time?

 

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);
  }
//+------------------------------------------------------------------+
 
if(Bid-500*Point>Open[0] || Bid+500*Point<Open[0]) Alert("500");
 
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.

 
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).
 
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 :)

 
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.

Reason: