Hi Guys I’m looking to develop a code that will log the entry time a trade enters then uses that entry time to scan for a reversal and then exit. The sequence would be:
- Trade meets entry conditions and trade is entered (in this example short)
- Time trade enters becomes a reference point
- Code then scans back to the reference point (Entry time) to look to exit conditions
- Trade closes when 3 consecutive higher highs occur (When going short) after reference point (Note scan does not include anytime prior to entry) AND trade is in profit
- Trade re-enters if price retraces back to original entry price and the exit conditions reset.
I’ve attached a diagram to help explain.
I would be grateful for any help on this?
Kind regards
Steve
Thanks,
I had thought of the BBC codes but they have the timeframe entered already, I’m wanting to set the time from when a trade opens at the start reference point.
Not tested, but you can try with the below code (forum coding):
if not shortonmarket and sellcondition then //condition to open your sellshort order
sellshort at market
count = 0 //reset high count
endif
if shortonmarket then
if high>high[1] then //increase highest high count
count=count+1
endif
if count>=3 then
exitshort at market //exit order if highest high is >= 3
endif
else // not on market anymore
sellshort at tradeprice limit // put a pending limit order at the previous order entry
endif
Thanks Nicolas, I’ll give this a go and see how we get on. Will let you know.
Thanks again
Steve