Hello everyone
i am trying to write a simple setup using CCI
Everything is fine, except the exit orders…
i would like to close positions on the CLOSE of the bar on the first day in profit.
For now lets put a 5% stop
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = CCI[72]
indicator2 = Average[5](CCI[72])
indicator3 = BollingerDown[21](close)
c1 = (indicator1 CROSSES OVER indicator2)
c2 = (close[3] > indicator3[3])
c3 = (close[2] <= indicator3[2])
c4 = (close[1] <= indicator3[1])
IF c1 AND c2 AND c3 AND c4 THEN
BUY 1 SHARES AT MARKET
ENDIF
// Conditions to exit long positions
c5 = (close > 0) ????????????????????????
IF c5 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator1 = CCI[72]
indicator2 = Average[5](CCI[72])
indicator3 = BollingerUp[21](close)
c6 = (indicator1 CROSSES UNDER indicator2)
c7 = (close[3] < indicator3[3])
c8 = (close[2] >= indicator3[2])
c9 = (close[1] >= indicator3[1])
IF c6 AND c7 AND c8 AND c9 THEN
SELLSHORT 1 SHARES AT MARKET
ENDIF
// Conditions to exit short positions
c10 = (close > 0) ???????????????????????????
IF c10 THEN
EXITSHORT AT MARKET
ENDIF
Thank you everyone
You can not sell on the close with PRT.
>> For clarity of messages on ProRealCode’s forums, please use the “<>” (insert code PRT) button to separate the text of the code part! Thank you! <<
thank you for your answers
if i cannot exit on close on PRT, i can set a time 5 minutes before close…
the question is:
How to set a condition to exit if the trade is in profit ?
Thank you.
Some ideas:
Time based end of day exit (adjust to your market’s close)
DefParam FlatAfter = 173000
How to see if your current position is in gain, but it does not take transaction cost/slip into consideration as far as I know.
IF PositionPerf(0) > 0.001 THEN