ONCEDistance=0//distance require by the broker, if any
IFNotOnMarketTHEN
//
LongEntry=open+(open*x2/100)
IFclose>(LongEntry+Distance*PipSize)THEN
BUY1ContractatLongEntryLIMIT
ELSIFclose<(LongEntry-Distance*PipSize)THEN
BUY1ContractatLongEntrySTOP
ELSE
//BUY 1 Contract at MARKET //enter at MARKET when the distance is not enough
ENDIF
//
ShortEntry=open-(open*x1/100)
IFclose>(ShortEntry+Distance*PipSize)THEN
SELLSHORT1ContractatShortEntrySTOP
ELSIFclose<(ShortEntry-Distance*PipSize)THEN
SELLSHORT1ContractatShortEntryLIMIT
ELSE
//SELLSHORT 1 Contract at MARKET //enter at MARKET when the distance is not enough
ENDIF
ENDIF
SET TARGET%PROFITx3
SET STOP%LOSSx4
//graphonprice LongEntry coloured("Green")
//graphonprice ShortEntry coloured("Red")
the pending orders that haven’t been triggered are automatically cancelled when a candle closes.
Be warned that it’s not possible to prevent both of them from being triggered, as PRT has no control over pending orders once they are sent to the broker, until the candle closes. If both pending orders are triggered, the latter one will close the first one triggered, as there cannot be opposite trades open at the same time.
Seems to be working fine! When using this “live” (i.e. not back testing) I suppose I would be able to define “max position” as 1 contract which would in practice cancel the other pending order thus preventing both to be triggered. Would that be correct?
I never tried it, but I don’t think so, as max positions is a directive to ProRealTime. But PRT loses control over orders as soon as thay are sent to the broker.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue