Not more trade than 2 in one hour
// this is a draft version of a function that I've made. // It checks how many closed trades of a type (buy, sell) were made during the last candle. Check if OK. int ordersLastBarHistory(int order_type,int time_frame) { int count=0; int time_ini = iTime(Symbol(),time_frame,0); int time_end = time_ini + time_frame*60; for(int i=OrdersHistoryTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue; if(OrderSymbol()!=Symbol()) continue; if(OrderType()==order_type) if(OrderOpenTime()>=time_ini && OrderOpenTime()<=time_end) count++; if(OrderOpenTime()<time_ini) break; } return(count); } //how to use it if(ordersLastBarHistory(OP_BUY,PERIOD_H1)<2) { // check to make another trade } //how to use it (buy and sell) if((ordersLastBarHistory(OP_BUY,PERIOD_H1)+ ordersLastBarHistory(OP_SELL,PERIOD_H1))<2) //if buy and sells during last candle are less than 2, then { // check to make another trade }
PS: did you take the red or blue pill?
Ok thanks i try this in my EA
The red one....u want too?
i think this condition is better mean i can have 2 consecutive long or 1 long and one sell
//how to use it (buy and sell) if((ordersLastBarHistory(OP_BUY,PERIOD_H1)+ ordersLastBarHistory(OP_SELL,PERIOD_H1))<2) //if buy and sells during last candle are less than 2, then { // check to make another trade }
The_Matrix:
this owrk for one hour time frame, but if i want to ultilize 4 houre time frame i cand do 4*60
int time_end = time_ini + time_frame*4*60;
Don't change that line. Instead do this:
//how to use it (buy and sell) PERIOD_H4 <---------- if((ordersLastBarHistory(OP_BUY,PERIOD_H4)+ ordersLastBarHistory(OP_SELL,PERIOD_H4))<2) //if buy and sells during last candle are less than 2, then { // check to make another trade }
Not more trade than 2/3 in one hour how i can do it??
if i look in the orderhistory i can know the orderclos time, but how work it?? he give me the hour minute and second??
and after i stop it how i restar the trade the next hour??
i found this solution