Download MetaTrader 5

from march 1st to April 3rd in MQL4 ?

To add comments, please log in or register
AYMERIC75
112
AYMERIC75  

I want my EA to check something for each tick between the 1st of March 2013 and the 3rd of April 2013.


What should i put inside for(???) ?




Thanks


Aymeric


p.s after this one i swear i stop asking silly questions for today :-)

whroeder1
16086
whroeder1  
AYMERIC: I want my EA to check something for each tick between...
Can't be done as mt4 doesn't have tick data. Only OHLC of bars.
AYMERIC75
112
AYMERIC75  
WHRoeder:
Can't be done as mt4 doesn't have tick data. Only OHLC of bars.

In fact in want to make a "historic" of each buy signal with ichimoku from from march to april. Impossible to do that ?
qjol
3243
qjol  
what TF are you talking about ?
AYMERIC75
112
AYMERIC75  

Sorry I didn't express myslef well.

I want to put a little thumb up on a chart of any pair (for instance EUR/UD) on any duration (for instance from last March 1st 2013 to April 1st 2013) for each time (or each bar) Ichi say it's time to buy.

So i need a loop that should looks like the following:


for ( March 1st 2013 to April 1st 2013)

{

if (Ichi says BUY)

{put a thump up on the chart}

}


I already made my Ichimoku program i just need to know what to put in the brackets of the for loop... like how to tell the program : test something from the date to this date (but in the past)...



Thank you


Aymeric

AYMERIC75
112
AYMERIC75  

Thanks for your answer but there is still a problem :

iTime(string symbol, int timeframe, int shift)


The timeframe value goes to maximum 1 month back in time (using PERIOD_MN1), so is it possible to go further ?



Secondly if i write something like this :


datetime t1 = iTime(0, PERIOD_MN1, 0) // return the time of the bar corresponding to exactly one month ago

datetime t1 = iTime(0, PERIOD_CURRENT, 0) // return the time of the current bar

for (datetime t = t1; t<t2; t++)

{

}


How do the t variable will be incremented ? Second per second ? Minute per minute ?




AYMERIC75
112
AYMERIC75  
Anyone ?
Keith Watford
Moderator
10617
Keith Watford  
datetime t1 = iTime(Symbol(), PERIOD_MN1, 0) // return the time of the bar corresponding to exactly one month ago
//It doesn't. It returns the start time of the current Monthly bar
Do not use 0 instead of Symbol() or NULL
AYMERIC75
112
AYMERIC75  
Ok, i really try hard to find the solution to my problem but i'm thinking maybe it's impossible to make an EA "scanning" and execute something at a moment in the past ...
Keith Watford
Moderator
10617
Keith Watford  
AYMERIC:
Ok, i really try hard to find the solution to my problem but i'm thinking maybe it's impossible to make an EA "scanning" and execute something at a moment in the past ...


It is not impossible

Why don't you just have your EA put a thumbs up at every past signal and then look at any particular period that you are interested in?

Keith Watford
Moderator
10617
Keith Watford  

Here's some indicator code that simply places an arrow at Tenkan/Kijun cross or touch and reverse. Maybe you will find something useful

#property copyright "GumRai"
#property link      "none"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters
input int      Tenkan_Sen1=9;
input int      Kijun_Sen1=26;
input int      Senkou_Span_B1=52;
input color    ArrowColour=clrDodgerBlue;
input int      ArrowSize=3;

int ZeroBars;
string Signal;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {

   ZeroBars = MathMax(Tenkan_Sen1,Kijun_Sen1);
   ZeroBars = MathMax(ZeroBars,Senkou_Span_B1);
   ZeroBars=ZeroBars*2;

//--- indicator buffers mapping

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   for(int i=ObjectsTotal()-1;i>=0;i--)
     {
      string ObName=ObjectName(i);
      if(StringFind(ObName,"FXX_Ichi",0)!=-1)
         ObjectDelete(ObName);
     }

  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

   int limit=rates_total-prev_calculated+1;
   if(prev_calculated==0)
      limit=rates_total-ZeroBars;

   double cloud_1a,cloud_1b,tenkan,tenkan_prev,kijun,kijun_prev,cloud_high1,cloud_low1
      ;
   for(int index=limit;index>0;index--)
     {
      cloud_1a = iIchimoku(Symbol(),0,Tenkan_Sen1,Kijun_Sen1,Senkou_Span_B1,MODE_SENKOUSPANA,index);
      cloud_1b = iIchimoku(Symbol(),0,Tenkan_Sen1,Kijun_Sen1,Senkou_Span_B1,MODE_SENKOUSPANB,index);
      tenkan= iIchimoku(Symbol(),0,Tenkan_Sen1,Kijun_Sen1,Senkou_Span_B1,MODE_TENKANSEN,index);
      kijun = iIchimoku(Symbol(),0,Tenkan_Sen1,Kijun_Sen1,Senkou_Span_B1,MODE_KIJUNSEN,index);
      tenkan_prev= iIchimoku(Symbol(),0,Tenkan_Sen1,Kijun_Sen1,Senkou_Span_B1,MODE_TENKANSEN,index+1);
      kijun_prev = iIchimoku(Symbol(),0,Tenkan_Sen1,Kijun_Sen1,Senkou_Span_B1,MODE_KIJUNSEN,index+1);
      cloud_high1= MathMax(cloud_1a,cloud_1b);
      cloud_low1=MathMin(cloud_1a,cloud_1b);

      //Buy Condition 1 tenken-sen crosses the kijun-sen from below ( and both above the cloud after the cross)
      //Bar closed above cloud
      //if(tenkan>kijun && tenkan_prev<kijun_prev && kijun>cloud_high1 && Close[index]>cloud_high1)
      if(tenkan>kijun && tenkan_prev<=kijun_prev )
        {
            Signal="Buy";
            string name="FXX_IchiupArrow"+(string)Time[index];
            if(ObjectFind(0,name)!=0)
              {
               ObjectCreate(name,OBJ_ARROW_UP,0,Time[index],Low[index]-(Period()*Point*2));
               ObjectSet(name,OBJPROP_COLOR,ArrowColour);
               ObjectSet(name,OBJPROP_WIDTH,ArrowSize);
               ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_TOP);
              }

           }

        
      //Sell Condition
      if(tenkan<kijun && tenkan_prev>=kijun_prev )
        {
            Signal="Sell";
            string name="FXX_IchidownArrow"+(string)Time[index];
            if(ObjectFind(0,name)!=0)
              {
               ObjectCreate(name,OBJ_ARROW_DOWN,0,Time[index],High[index]+(Period()*Point*2));
               ObjectSet(name,OBJPROP_COLOR,ArrowColour);
               ObjectSet(name,OBJPROP_WIDTH,ArrowSize);
               ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_BOTTOM);
              }

          

        }
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
12
To add comments, please log in or register