MarcParticipant
Average
Hi together,
I’d like to close a position at the open of the next bar. As i found out nextbaropen can not be used to close positions. Am I right?
Perhaps somebody can help me with the snippet.
DEFPARAM CumulateOrders = FALSE
A = ABS(Dclose(1))-ABS(Dopen(1)) //inner Range
B = ABS(dhigh(1))-ABS(Dlow(1)) //outer Range
C = 0.25 //Faktor
n = 1//Lotsize
// Conditions to enter long positions
IF NOT LongOnMarket AND CLOSE > OPEN AND (A/B) < C THEN
BUY 1 SHARES AT HIGH STOP
ENDIF
// Conditions to exit long and short positions
IF LongOnMarket THEN
SELL n SHARES AT NextBarOpen
ENDIF
// Conditions to enter short positions
IF NOT LongOnMarket AND CLOSE < OPEN AND (A/B) < C THEN
SELLSHORT n SHARES AT LOW STOP
ENDIF
// Conditions to exit short long positions
IF ShortOnMarket THEN
EXITSHORT AT NextBarOpen
ENDIF
All you need is:
if onmarket then
sell at market
exitshort at market
endif
MarcParticipant
Average
Here is the amended code…
It’s ony working for long positions. Short didn’t work well.
A = Close[1]-Open[1] //inner Range
B = High[1]-Low[1] //outer Range
C = y //Faktor
n = 1//Lotsize
// Conditions to enter long positions
IF NOT OnMarket AND (A/B) < C THEN
BUY n SHARES AT MARKET
ENDIF
// Conditions to exit long and short positions
IF OnMarket THEN
SELL AT Market
ENDIF
For C = 0,43 worked best
When you say ‘Short didn’t work well’ you mean the strategy not the code.
If you look at the Wall Street chart then only a fool would try to short it! The trend is your friend! That is your first edge!
I think GraHal that he means that he has removed the short side of the strategy because it does not work on the DJI. Which is not surprising if you look at the DJI chart – low on the left and high on the right and virtually a straight line in between!
MarcParticipant
Average
Hi GraHal,
I forgot to delete or amend the phrase after //.
This strategy currently works only for long positions and doesn’t allow short positions…
MarcParticipant
Average
This system shall refer a litle bit to Andrea Unger’s pattern strategy. The biggest difference is that the rules for this strategy here enters market orders and not orders at high or low…
Perhaps I will add a MA for trend direction
MarcParticipant
Average
Hi together,
I have a suggestion regarding this system…perhaps somebody can help me amending this code.
I thought about following thing.
Each day I have a reference candle for example at 8 o’clock.
I enter a long trade (either at market or as High Stop order) when close of a following candle is above open of reference candle and range of High and Low is bigger compared with Open and Close (bigger than variable factor)
I enter a short trade (either at market or as Low Stop order) when close of a following candle is below open of reference candle and range of High and Low is bigger compared with Open and Close (bigger than variable factor)
Exit shall be at open of next bar Open or Close of current bar after order was placed.
Can anybody help me?
Thank you in advance
Marc
Hi Marc, I think that it could be a good idea to learn to code a bit. What you request is easy to add to your strategy.
Learn to program for ProRealTime