//TODO TO IMPROVE:
// make TP a % of DAily ATR
//limit so it stops after one profit per session
//limit so it stops after 2 losses per session
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
//DEFPARAM FLATBEFORE = 130000
//DEFPARAM FLATAFTER = 130000 //<<<<<ALTER THIS TO CLOSING TIME!!!!!!!!!!
ONCE UKAMopenstart = 093000
ONCE UKAMopenfinish =120000
ONCE UKAMexit =130000
ONCE USPMopenstart = 173000
ONCE USPMopenfinish =201500
//Exit after x minutes
indicator11 = ADX[14]
c11 = (indicator11[1] > 20.46)
indicator1 = Average[3](close) //// note of4/4/22: changed this to [1] as NVIDIA and Micron didnt take and I'm wondering if thats the reason ?
indicator2 = ExponentialAverage[9](close)
b1 = (indicator1 < indicator2)
indicator4 = Average[20](close)
d1 = (indicator2 < indicator4)
// Conditions to enter long positions
IF NOT ShortOnMarket and ((time>=UKAMopenstart AND time<=UKAMopenfinish) or (time>=USPMopenstart AND time<=USPMopenfinish))AND b1 and d1 and c11 THEN
SELLSHORT QTY LOT AT MARKET
ENDIF
// Conditions to exit long positions
//timeframe(10 minutes, updateonclose)
indicator23 = ExponentialAverage[9](close)
c21 = (indicator21 > indicator23)
IF c21 or (time=>UKAMexit and time<=USPMopenstart) or time>235900 THEN
EXITSHORT AT MARKET
ENDIF
indicator211 = ADX[14]
c211 = (indicator211[1] < 20.46)
indicator21 = Average[3](close) //// note of4/4/22: changed this to [1] as NVIDIA and Micron didnt take and I'm wondering if thats the reason ?
indicator22 = ExponentialAverage[9](close)
b21 = (indicator21 > indicator22)
indicator24 = Average[20](close)
d21 = (indicator22 > indicator24)
// Conditions to enter long positions
IF NOT LongOnMarket and ((time>=UKAMopenstart AND time<=UKAMopenfinish) or (time>=USPMopenstart AND time<=USPMopenfinish))AND b21 and d21 and c211 THEN
BUY QTY LOT AT MARKET
ENDIF
// Conditions to exit long positions
//timeframe(10 minutes, updateonclose)
indicator3 = ExponentialAverage[9](close)
c21 = (indicator21 < indicator23)
IF c21 or (time=>UKAMexit and time<=USPMopenstart) or time>235900 THEN
SELL AT MARKET
ENDIF
SET STOP $LOSS 110
SET TARGET $PROFIT 31