Ah ok I guess it doesn’t matter which but let me take a look at them using gold spot/USD is that ok?
Probably change the entry onto a higher timeframe as well just to get into a trade.
Quick question though (and you have probably realised by now that I’m a coding numpty!) how does the code know what SigHI1 is and how does this increase(lines 51 & 54 in my code version above)?
Also on line 51 where SigHI > 0 would I be able to to substitute 0 for a higher integer value say 20 to represent 20 pips in profit or is it just a 1-0 true – false statement?
Forgive me for my lack of understanding!
Steve
Don’t worry, newbie ISN’T numpty! (the same as Expert ISN’T smart!)
GraHal ‘s motto is “Ask a question, you may be a fool for a day. Don’t ask a question, you may be a fool for life!? ” and I subscribe to it!
that 0 is just a logical statement (true-false), 0=FALSE whichever value other than 0 is true.
But… what proves GraHal is right is just in your lines 51-54. Checking them I just realized a made a HUGE mistake in my first post, where I used logical values to compare higher and lower swing points.
Thanks for spotting that Steveaw.
This is the correct (?!) version of my first post:
ONCE SwingHI1 = 0
ONCE SwingHI = 0
ONCE SwingLO1 = 0
ONCE SwingLO = 0
ONCE LookBack = 10
IF Not OnMarket Then
MySL = 0
ENDIF
MaxHI = max(open,close)
MinLO = min(open,close)
Bullish = close > open
Bearish = close < open
SwingHI = highest[LookBack](MaxHI)
SwingLO = lowest[LookBack](MinLO)
SigHI = SwingHI AND Bearish AND Bullish[1]
SigLO = SwingLO AND Bullish AND Bearish[1]
IF LongOnMarket AND SigHI > 0 AND SwingHI > SwingHI1 THEN
SwingHI1 = SwingHI
IF SwingHI1 > SwingLO1 THEN
MySL = max(TradePrice,max(MySL,SwingLO1))
ENDIF
ELSIF ShortOnMarket AND SigLO > 0 AND SwingLO < SwingLO1 THEN
SwingLO1 = SwingLO
IF SwingLO1 < SwingHI1 THEN
MySL = min(TradePrice,min(MySL,SwingHI1))
ENDIF
ENDIF
IF OnMarket AND MySL <> 0 THEN
SELL AT MySL Stop
EXITSHORT AT MySL Stop
ENDIF
I’m so sorry you will have to change your strategy again!
Hi Roberto
I’ve attached a XAU/USD on 5 min entry & 1 Hr exit for the code.
settings are:
Set Point for Entry 1751 long
SL – 10
TP – 20
Steve
Please post your last used code.
// Hi Roberto - I've attached the code and another screenshot on XAU/USD
//Steve
// Solution from PRC For Finding a BOS5
//TAKE PROFITS AT BREAK OF MARKET STRUCTURE Test 3
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
if onmarket or strategyprofit<>strategyprofit[1] then
flag = 1
endif
if dayofweek <> dayofweek[1] then
flag = 0
endif
entry=1751
SET STOP pLOSS sl
SET TARGET pPROFIT tp
sl=10
tp=50
// Conditions to enter long position
notradetime1=213000
notradetime2=233000
notradetime=time>notradetime1 and time<notradetime2
timeframe (60 minute, updateonclose)
c1=low<=entry
timeframe(default, updateonclose)
IF not daysForbiddenEntry and not flag and not onmarket and not notradetime and c1 Then
Buy 1 perpoint AT MARKET
ENDIF
// from PRC
timeframe (60 minutes, updateonclose)
ONCE SigHI1 = 0
//ONCE SigHI2 = 0
ONCE SigLO1 = 0
//ONCE SigLO2 = 0
ONCE LookBack = 5
IF Not OnMarket Then
MySL = 0
ENDIF
MaxHI = max(open,close)
MinLO = min(open,close)
Bullish = close > open
Bearish = close < open
SwingHI = highest[LookBack](MaxHI)
SwingLO = lowest[LookBack](MinLO)
SigHI = SwingHI AND Bearish AND Bullish[1]
SigLO = SwingLO AND Bullish AND Bearish[1]
IF LongOnMarket AND SigHI > 0 AND SigHI > SigHI1 THEN
//SigHI2 = SigHI1
SigHI1 = SigHI
IF SigHI1 > SigLO1 THEN
MySL = max(TradePrice,max(MySL,SigLO1))
ENDIF
ELSIF ShortOnMarket AND SigLO > 0 AND SigLO < SigLO1 THEN
//SigLO2 = SigLO1
SigLO1 = SigLO
IF SigLO1 < SigHI1 THEN
MySL = min(TradePrice,min(MySL,SigLO1))
ENDIF
ENDIF
IF OnMarket AND MySL <> 0 THEN
SELL AT MySL Stop
EXITSHORT AT MySL Stop
ENDIF