It seems to be working….. almost correctly!
Yes, you have the same reference to 30 in both lines 9 and 13, so should X be equal to 30 both IFs will be executed thus making line 10 superfluous. I suggest that you either replace 30 in line 9 with 29 OR 30 in line 13 with 31.
ramaParticipant
Senior
Code works well for
defparam cumulateorders = false
if I want run the same code
defparam cumulateorders = TRUE
what changed I need to make to single order code to make it multiple orders, I am running this on IG UK spread betting account
I never used more than one order per strategy.
What I know for sure is that there is ONE single SL and TP for each strategy, so if you accumalate contracts you have to set them only once. Also, no partial closing is allowed as of the current version of ProOrder, so all contracts need to be sold at one time, no matter whether you bought them at different times.
I cannot tell you more about this, but according to what I said above, I think you don’t have to change anything since you have ONE trailing stop.
ramaParticipant
Senior
PRT really worrying
it worked on demo on live placed plenty of unwanted orders
Set stop loss 36
ret=.5
ret1=.75
ret2=.8
IF Not OnMarket THEN
y = 0
ENDIF
IF LongOnMarket AND close > (TradePrice + (y * pipsize)) THEN
x = (close - tradeprice) / pipsize //convert price to pips
IF x >= 15 and x<=20 THEN //go ahead only if 30+ pips
y = max(x * ret, y) //y = 66.6% of max profit
ENDIF
IF x >= 20.1 and x<=100 THEN //go ahead only if 30+ pips
y = max(x * ret1, y) //y = 66.6% of max profit
ENDIF
IF x >= 101 and x<=200 THEN //go ahead only if 30+ pips
y = max(x * ret2, y) //y = 66.6% of max profit
ENDIF
ENDIF
IF y THEN //Place pending LIMIT (not STOP) order when y>0
SELL AT Tradeprice + (y * pipsize) stop //convert pips to price
ENDIF
If you post the whole strategy I’ll take a look at it.
ramaParticipant
Senior
I ran the following code. I expect the system should stop out either 99 GBP loss or 90 GBP minimum profit or more
results attached ( why the system stopped out 49.8 gbp loss)
//-------------------------------------------------------------------------
// Main code : 3secsell(2)
//-------------------------------------------------------------------------
defparam cumulateorders = false
DEFPARAM Preloadbars = 2000
DEFPARAM flatafter = 205900
//startBreakeven = y//how much pips/points in gain to activate the breakeven function?
//PointsToKeep = x//how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
ctime1 = time > 161500 and time < 162500
x=2
IF not onmarket and ctime1 THEN
sellshort .5 perpoint at market
ENDIF
Set stop loss 99
ret=.1
IF Not OnMarket THEN
y = 0
ENDIF
IF shortonMarket AND close < (TradePrice - (y * pipsize)) THEN
x = (tradeprice-close) / pipsize //convert price to pips
IF x >=98 then//go ahead only if 30+ pips
y = max(x * ret, y) //y = 66.6% of max profit
ENDIF
ENDIF
IF y THEN //Place pending LIMIT (not STOP) order when y>0
exitshort AT Tradeprice - (y * pipsize) stop //convert pips to price
ENDIF
Set stop loss 99
DEFPARAM flatafter = 205900
What time was the system stopped out 49.8 gbp loss??
ramaParticipant
Senior
system worked correctly, i was betting .5 per point so .5*99=49.5 system booked 49.8 as expected
Yeah I ran your System and used GRAPH and came to the same conclusion about 20 seconds ago! 🙂 Pat on the back for both of us!!! Well done rama! 🙂