Sorry for the maybe stupid question. I’ve been working on this little breakout system for hours now. But I can’t get the Tradecounter to work. It doesn’t open any trades. What am I doing wrong? It should be able to open a trade once a day in each direction. So a maximum of once long and once short. Somehow I can’t get the counter loop through. Could anyone help me, please?
DEFPARAM CumulateOrders = FALSE
Defparam Preloadbars = 1000
defparam Flatafter = 210000
ONCE TradeLong = 0
ONCE TradeShort = 0
IF IntraDayBarIndex = 0 THEN
TradeLong = 0
TradeShort = 0
ENDIF
dis = 20
hl = dis
gl = hl + 10
//start = hl
IF Time = 080000 THEN
EntryLong = close + dis * pipsize
EntryShort = close - dis * pipsize
ENDIF
IF Time >= 080000 AND Time <= 140000 THEN
IF EntryLong and not tradelong THEN
BUY 1 Contract AT EntryLong STOP
SET STOP pLOSS hl
SET TARGET pPROFIT gl
Tradelong = 1
ENDIF
IF EntryShort and not tradeshort THEN
SELLSHORT 1 Contract AT EntryShort STOP
SET STOP pLOSS hl
SET TARGET pPROFIT gl
tradeshort = 1
ENDIF
endif
You put STOP orders and increment your variable Tradelong and Tradeshort. But that stop orders might not trigger, so you are counting for nothing.
Without a tradecounter, the stop orders are triggered. But not with Tradecounter. Can you try EurUsd Mini M1 was my attempt.
Ha, I have it. the counter has to get out of the loop for stop orders and only count when the order is triggered and you are in the market. Thank you anyway.
My Insert Code button doesn’t exist.
if longonmarket then
Tradelong = 1
endif
if shortonmarket then
tradeshort = 1
endif
Yes, sorry.
if longonmarket then
Tradelong = 1
endif
if shortonmarket then
tradeshort = 1
endif
Sorry for a stupid question. What do u do with the counter? Resultscreen show you how many trade the algo have done?
No, the other way around. You can use it to determine how many trades can be made in one day in each direction. In this case, one trade long, one trade short maximum per day.
Hi,
If you fix the counter issue and it still isn’t putting trades or it is erratic when it goes live, on you may want to try using “Buy at Market” rather than using a “buy stop” at the market level
Yes I know. But I wanted to build the strategy with stop orders.