I was able to resolve this issue myself.
Changed CurrentTime to use Hour,Minutes.
Other than that, I don’t know what the problem was, but I am surprised that it suddenly works.
Thank you very much.
// ===== ProOrder =====
// pair: EURUSD
// Generated: 2025/7/1 19:14:15
DEFPARAM CumulateOrders = True // Allow multiple positions
// ===== Entry Table Settings (Hour:Minute only) =====
// — Entry 1: 18:23 Buy —
EntryHour1 = 18
EntryMinute1 = 23
ExitHour1 = 18
ExitMinute1 = 24
Direction1 = 1 // 1=Buy, -1=Sell
Lot1 = 1
TP1 = 0 // pips (0=disabled)
SL1 = 15 // pips
// ===== Position Management =====
ONCE Entry1Done = 0
// ===== Entry 1 =====
IF Hour = EntryHour1 AND Minute = EntryMinute1 AND Entry1Done = 0 THEN
IF Direction1 = 1 THEN
BUY Lot1 CONTRACT AT MARKET
ELSIF Direction1 = -1 THEN
SELLSHORT Lot1 CONTRACT AT MARKET
ENDIF
// Set Stop Loss in pips
SET STOP pLOSS SL1
IF TP1 > 0 THEN
// Set Take Profit in pips
SET TARGET pPROFIT TP1
ENDIF
Entry1Done = 1
ENDIF
// Time-based exit for Entry 1
IF Hour = ExitHour1 AND Minute = ExitMinute1 AND Entry1Done = 1 THEN
IF Direction1 = 1 AND LONGONMARKET THEN
SELL Lot1 CONTRACT AT MARKET
ELSIF Direction1 = -1 AND SHORTONMARKET THEN
EXITSHORT Lot1 CONTRACT AT MARKET
ENDIF
ENDIF
// ===== Daily Reset =====
IF Hour = 0 AND Minute = 0 THEN
Entry1Done = 0
ENDIF
// ===== Position Information Display =====
totalPositions = COUNTOFPOSITION
This works fine on a 1-hour TF (DAX):
// Minimal Test Code
// I set the TargetTime to a few minutes in the future for testing.
TargetTime = 140000 // e.g., Set to 2:00 PM
ONCE TradeAttempted = 0
IF IntraDayBarIndex = 0 THEN
TradeAttempted = OnMarket //make sure TradeAttempted is cleared when not OnMarket
ENDIF
IF Time >= TargetTime AND TradeAttempted = 0 AND Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
TradeAttempted = 1
set target %profit 1
set stop %loss 0.5
ENDIF
as to the other code, pleas append this line to your code:
graph USDJPYCheckLot
you will notice that
USDJPYCheckLot is set to 0.1 only from 000000 to 080000 (0am through 8am), but your code won’t enter trades before 060000 (6am).
Moreover, are you sure 0.1 contracts is allowed for the instrument you are trading?
BUY 0.1 CONTRACT AT MARKET
Maybe it is now working because you ceased using above (0.1 Contract) and are now using Lot1 = 1 ?
What Instrument allows 0.1 Contract?
EDIT / PS
Has seems mine and Roberto posts
crossed.
Hi robertogozzi
Wow, thank you for the fantastic help! Your analysis was spot on.
I graphed the variable as you said, and you were totally right about the timing issue. But the real ‘aha!’ moment was your question about the contract size. I checked, and you were right, the minimum is 1, not 0.1. That was the root of the problem.
Seriously, thank you. You’ve saved me a ton of time and frustration. It’s all working now!
Hi GraHal,
That was a fantastic catch, thank you so much! You were 100% right, the ‘0.1 Contract’ was an error.
And yes, you’re right about 0.1 lots being common elsewhere. As you suspected, this particular instrument was the exception and needs a minimum of 1.
Thanks again for the sharp eye, it was a huge help!