EURUSD 15 min
Forums › ProRealTime forum Italiano › Supporto ProOrder › EURUSD 15 min
- This topic has 1 reply, 2 voices, and was last updated 4 years ago by robertogozzi.
-
-
05/30/2020 at 11:16 AM #133853
bool IsStartOfNewBar() {
static datetime oldTime = 0;
bool ret = false;if (oldTime == 0) oldTime = Time[0];
else if (oldTime != Time[0]) {
oldTime = Time[0];
ret = true;
}
return ret;
}//
// Calculate session OHLC for actual(0) and last 5 sessions (1-5)
// The session time is defined by startTime and endTime
// DayOpen[] has one value more(7), because DayOpen[6] is used internally
// IMPORTANT: Initialze DayOpen[0] with NULL, so the function can realize that it is not initialized yet
//
bool calcSessionValues(double &DayOpen[7], double &DayHigh[6], double &DayLow[6], double &DayClose[6], int startTime, int endTime, bool &inSessionTime, int shift = 0) {
int barTime = TimeHour(Time[0+shift])*100+TimeMinute(Time[0+shift]);
int barTime1 = TimeHour(Time[1+shift])*100+TimeMinute(Time[1+shift]);
int i;
int d = TimeDayOfYear(Time[0+shift]),d1 = TimeDayOfYear(Time[1+shift]);
if (startTime == endTime) endTime–; if (endTime%100 == 99) endTime-=40; if (endTime == -1) endTime = 2359; // if end and start time equal -> reduce end time by 1 min
bool oneDaySession = startTime < endTime; // if it’s not a oneDaySession(e.g. 8 till 20 o’clock), it’s a twoDaySession(e.g. 17 till 1659 o’clock) bool timeStarted = barTime >= startTime;
bool timeNotEnded = barTime < endTime;
bool prevTimeLessSTime = barTime1 < startTime;
bool isStartOfSession;if (oneDaySession) {
inSessionTime = timeStarted && timeNotEnded;
} else { // session goes over 2 days becaus EndTime <= StartTime
inSessionTime = timeStarted || timeNotEnded;
}
isStartOfSession = inSessionTime && timeStarted && (prevTimeLessSTime || (oneDaySession && d != d1));
//if (startTime < 0002) Print(” “, TimeToStr(Time[0+shift]), ” isOS “, isStartOfSession, ” “, shift, ” “, Open[0+shift]); if (!oneDaySession) { // if 2 day session and previous day had no prices for it isStartOfSession = isStartOfSession || (inSessionTime && d != d1 && prevTimeLessSTime); } // A session is split in two, if a) in a oneDaySession the day changes b) in a twoDaySession a missing day occours in session if (oneDaySession) { isStartOfSession = isStartOfSession || (inSessionTime && d != d1); } else { isStartOfSession = isStartOfSession || (inSessionTime && d>TimeDayOfYear(Time[1+shift])+1);
}if(DayOpen[0] == NULL && !isStartOfSession) return false; // waiting for the first session begin
if (inSessionTime) {
//Print(“InSession: “, inSessionTime);
DayHigh[0] = MathMax(DayHigh[0],High[1+shift]); DayLow[0] = MathMin(DayLow[0], Low[1+shift]); DayClose[0] = Close[1+shift]; // Print(“C: ” + Close[1]); Print(“O: ” + Open[1]); Print(“H: ” + High[1]); Print(“L: ” + Low[1]);
}inSessionTime = inSessionTime && !(barTime > endTime && barTime1 <= endTime); if (isStartOfSession) { //inSessionTime = true; //Print(“Day begins”); DayOpen[6] = DayOpen[5]; // just to evaluate if Array is completely filled for(i=5;i>0;i–) { DayOpen[i] = DayOpen[i-1]; DayHigh[i] = DayHigh[i-1]; DayLow[i] = DayLow[i-1]; DayClose[i] = DayClose[i-1]; }
DayOpen[0] = Open[0+shift]; DayHigh[0] = Open[0+shift]; DayLow[0] = Open[0+shift]; DayClose[0] = Open[0+shift];
}
return DayOpen[6] != NULL;
}//
// get open order via orderType
//
int getOpenOrder(int orderType, int MagicNbr) {
int total=OrdersTotal();
if (OrdersTotal() > 0) {
for(int pos=0;pos<total;pos++) { if(OrderSelect(pos,SELECT_BY_POS)==false) continue; if(OrderMagicNumber() != MagicNbr) continue; if(OrderType() == orderType) return OrderTicket(); } } return -1; } // // There should be NEVER be open positions in both directions // returns // 0 – if flat // 1 – if long // -1 – if short // int getOpenPositionDir(int MagicNbr) { if (OrdersTotal() > 0) {
int total=OrdersTotal();
for(int pos=0;pos<total;pos++) { if(OrderSelect(pos,SELECT_BY_POS)==false) continue; if(OrderMagicNumber() != MagicNbr) continue; if(OrderType() == OP_BUY) { return 1; } else { if (OrderType() == OP_SELL) return -1; } } } return 0; } void ChangeSL(int ticket, double stopLoss) { if (OrderSelect(ticket, SELECT_BY_TICKET)) { if(MathAbs(OrderStopLoss()-stopLoss) > _Point/10) // only if SL changes
if (!OrderModify(ticket, OrderOpenPrice(), stopLoss, OrderTakeProfit(),OrderExpiration())) Alert(“OrderModify failed: “, GetLastError(), ” SL: “, OrderStopLoss(), ” new: “, stopLoss);
} else Alert(“OrderSelect failed: “, GetLastError(), ticket);
}05/30/2020 at 12:15 PM #133856Per favore Non duplicare it tuoi post. Poni la tua domanda solo una volta e solo in un forum. Tutti i doppi post verranno comunque eliminati, quindi pubblicare più volte la stessa domanda ti farà perdere tempo e non ti farà avere una risposta più velocemente. Il doppio post crea solo confusione nei forum. 🙂
L’altro l’ho cancellato. Tra l’altro era più corto, pur avendo lo stesso titolo.
Per favore Dai un titolo significativo al tuo argomento. Descrivi la tua domanda o l’oggetto nel titolo. Non utilizzare titoli privi di significato come “Aiuto per la codifica”. Grazie 🙂
“EURUSD 15 min” cosa significa?
Per favore Pubblica il tuo argomento nel forum corretto: “ProOrder per le strategie”. Grazie 🙂
-
AuthorPosts
Find exclusive trading pro-tools on