I think I found the answer .
I wrote a Boolean function to check it .
If you have any idea for make it better or more correct , I'd like to learn .
I like to understand how professionals are thinking.
//+------------------------------------------------------------------+ //| 2nd Project.mq4 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict input int HighParts = 4; input int TimeParts = 10; input double Lot=0.1; input int TP=50; input int SL=20; long handle=ChartID(); double point; int TF; //Time Frame string tf;//TimeFrame as text for posiotion comment double high_0; //High [0] in any TimeFrame double high_1; double low_0; double low_1; long vol_0; long vol_1; datetime OpTime_0;//Time[0] in any TimeFrame datetime OpTime_1; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { point=Point; if((Digits==3) || (Digits==5)) { point*=10; } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) {} //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { TF=PERIOD_M1; SendPositions(TF); TF=PERIOD_M5;SendPositions(TF); TF=PERIOD_M15;SendPositions(TF); TF=PERIOD_M30;SendPositions(TF); TF=PERIOD_H1;SendPositions(TF); TF=PERIOD_H4;SendPositions(TF); TF=PERIOD_D1;SendPositions(TF); TF=PERIOD_W1;SendPositions(TF); TF=PERIOD_MN1;SendPositions(TF); } //+------------------------------------------------------------------+ void SendPositions(int timeframe) { tf=string(timeframe); high_0=iHigh(NULL,timeframe,0); high_1=iHigh(NULL,timeframe,1); low_0=iLow(NULL,timeframe,0); low_1=iLow(NULL,timeframe,1); vol_0=iVolume(NULL,timeframe,0); vol_1=iVolume(NULL,timeframe,1); OpTime_0=iTime(NULL,timeframe,0); OpTime_1=iTime(NULL,timeframe,1); if(Allowed(TF,OpTime_0)) { if(high_1==high_0 && low_1==low_0) { if(vol_0>vol_1) { if(TimeCurrent()-OpTime_0>=(((OpTime_0-OpTime_1)/TimeParts)*(TimeParts-1))) { if(Bid>=(high_0-((high_0-low_0)/HighParts))) { if(!OrderSend(Symbol(),OP_BUY,Lot,Ask,0,Bid-(SL*point),Bid+(TP*point),tf+" Nasimi Project2",0,0,clrBlue)) Print(GetLastError()); Comment(Symbol()," ",tf+" Buy Position "); } if(Bid<=(low_0+((high_0-low_0)/HighParts))) { if(!OrderSend(Symbol(),OP_SELL,Lot,Bid,0,Ask+(SL*point),Ask-(TP*point),tf+"Nasimi Project2",0,0,clrBlue)) Print(GetLastError());Comment(Symbol()," ",tf+" Sell Position "); } } } } } } //+------------------------------------------------------------------+ bool Allowed(int timframe,datetime BarOpenTime) { datetime opt=0; bool allowed=true; for(int i=OrdersTotal();i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderComment()==tf+" Nasimi Project2") { if(OrderOpenTime()>opt) { opt=OrderOpenTime(); } } } } if(opt>=BarOpenTime) { allowed=false; } return(allowed); } //+------------------------------------------------------------------+
That is how professionals are thinking.
Well done.
Marco vd Heijden:
That is how professionals are thinking.
Well done.
Hi Marco vd Heijden
THANK YOU !!
I feel SOOOOOO GOOOOOD !!

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
I'm trying to make an EA which check some conditions in all time frames . whenever conditions output was true in one of time frames it must send the position .
my questions :
1- is it correct way to make it multi time ?
2 - i don't know how to say if you sent a position don't repeat sending orders for the same time frame before next bar getting open .(I afraid if my English is not understandable )