Hi
Once you conditions have been met is it possible to place an order to trigger at a predetermined point NOT at market.
i.e ALL the conditions are met but your order would be X pips higher than the current price at your trigger point Or when c1 and C2 and c3 and c4 are met. So then effectively placing an order etc ?
Yes, you can use pending orders. Use STOP pending orders when the entry price il worse than current price, LIMIT pending orders when it’s better (higher if yiu sell or lower if you buy):
// Long trades
BUY 1 CONTRACT AT MyEntryPrice STOP //current price is lower
BUY 1 CONTRACT AT MyEntryPrice LIMIT //current price is higher
// Short trades
SELLSHORT 1 CONTRACT AT MyEntryPrice STOP //current price is higher
SELLSHORT 1 CONTRACT AT MyEntryPrice LIMIT //current price is lower
Be warned that pending orders expire after one bar, so you need to place then again next bar if still needed.
Set TP & SL as usual.
Thanks Roberto ,
So if i envisaged myentryprice may not be hit for 5 or more bars after initial conditions were me how would be best to cope with that ?
If your conditions are met keep placing them again and again, bar after bar, until those conditions are no more met (or orders are triggered and you do not want to enter again until NEW conditions are met).
Once the conditions are met for placing an order at myentrypoint – i want the order to stay current until the entry point is achieved. The initial conditions to trigger myentrypoint will not be met going forward from the point of order as these are historical conditions to trigger my entry point.
When you say keep placing the order bar after bar how is this coded to express the order is valid until achieved ? Regardless of the initial conditions to initially achieve the first placement of myentrypoint.
There you go:
If MyConditions AND Not OnMarket THEN //make sure your conditions are still met to place a pending order
BUY 1 CONTRACT AT MyEntryPrice STOP //or LIMIT
ENDIF
MyConditions can be any condition or combination of conditions linked either with AND or OR.
There you go:
DEFPARAM CumulateOrders = FALSE
ONCE CondL = 0
ONCE Count = 0
ONCE Entry = 0
ONCE Dist = 10 //minimum distance from current price required by the broker
// to place pending orders
//reset variables when on market
IF OnMarket THEN
CondL = 0
Count = 0
Entry = 0
ENDIF
//increnment count
IF Count > 0 THEN
Count = Count + 1
//reset count and conditions after 10 bars have elapsed
IF Count > 10 THEN
Count = 0
CondL = 0
Entry = 0
ENDIF
ENDIF
// LONG condition
IF close crosses over Average[200] then
CondL = 1
Count = 1
Entry = high
ENDIF
// entry
IF Entry > 0 AND Not OnMarket THEN
IF (close + Dist) < Entry THEN
BUY 1 Contract AT Entry STOP
ELSIF (close - Dist) > Entry THEN
BUY 1 Contract AT Entry LIMIT
ELSE
BUY 1 Contract AT Market
ENDIF
ENDIF
// exit
IF close crosses under Average[200] and LongOnMarket then
sell at market
ENDIF
Thanks so much for the help Roberto