LeoParticipant
Veteran
Hello Léo
I don’t understand : MaxX=MaxX=max(x,MaxX)
could you explain me well detailed ??
IF LongOnMarket AND close > TradePrice THEN
x = (close - tradeprice) / pipsize //convert price to pips
MaxX=max(x,MaxX) //store the max profit during trade
IF x >= 30 THEN //go ahead only if 30+ pips
y = MaxX * 0.666 //y = 66.6% of current profit
SELL AT TradePrice + Y*pipsize STOP //convert pips to price
ENDIF
ENDIF
Copy paste problem. MaxX is a variable which store the maximum profit and when the profit is at 66% of the higher value it closes the trade.
NOTE: always reset to 0 the MaxX when you open a trade
LeoParticipant
Veteran
Once MaxX=0
IF LongOnMarket AND close > TradePrice THEN
x = (close - tradeprice) / pipsize //convert price to pips
MaxX=MaxX=max(x,MaxX) //store the max profit during trade
IF x >= 30 and x < 0.66*MaxX THEN //Exit only if 30+ pips
SELL AT MARKET
MaxX=0
ENDIF
ENDIF
Maybe like this
MaxX=MaxX=max(x,MaxX)
Copy paste problem again Leo!
LeoParticipant
Veteran
Have you ever try to write a code from your mobile phone? No way!
Have you ever try to write a code from your mobile phone? No way!
I’m one of those weirdo’s in life who doesn’t have a mobile phone. If someone needs to talk to me that badly they can phone my girlfriend. And as for everything else that a phone can do these days the engineer in me says that it is not the right tool for most of those jobs anyway – which I think you may have just proven.
Must go as trying to add up my losses on my abacus.
thank you for your answer Leo I understand the purpose (( store the max profit) but there is something that I do not understand in the computer language of this line if someone can detail this formula for me to understand
The line should read
MaxX = MAX(x,MaxX)
It ensures that the value of MaxX remains at which ever is the highest value of the last highest MaxX and the new x calculated at this bar. This way the value of MaxX can only ever go up and not down.
ramaParticipant
Senior
I am back testing now, I will update the results
alternate way of coding is
x= time of the trade 1 initiated
y=(Highest(2000)(high)- tradeprice)
if ctime >= x and and y>=30 then
if close(1)<= tradeprice+.667*y
sell at market
endif
endif
what is x? in terms for PRT code
picture attached for x
After some testing I changed the code as follows (it seems to be working as expected):
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 >= 30 THEN //go ahead only if 30+ pips
y = max(x * 0.666, y) //y = 66.6% of max profit
ENDIF
ENDIF
IF y THEN //Place pending STOP order when y>0
SELL AT Tradeprice + (y * pipsize) STOP //convert pips to price
ENDIF
Give me some feedback.
ramaParticipant
Senior
Many thanks , code seems to be working well results attached.
I will evaluate results and post updates
I was looking for this Thread and instinctively went to the ProOrder Support Forum … with all the coding support shouldn’t this be in that Forum?
ramaParticipant
Senior
Admin can move this thread to appropriate place
Right. I didn’t even realize that.
ramaParticipant
Senior
I want introduce steps of trailing into the stop loss
for steps I have modified code as follows, can you confirm whether this will work ? if not suggest me code changes
ret=.2
ret1=.7
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 >= 10 and x<=30 THEN //go ahead only if 30+ pips
y = max(x * ret, y) //y = 66.6% of max profit
ENDIF
IF x >= 30 and x<=70 THEN //go ahead only if 30+ pips
y = max(x * ret1, 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
To write code, please use the <> “insert PRT code” button, to make code easier to read. Thank you.
I’ll take a look at your code ASAP.