Hi all,
I’m just getting started with Prorealtime coding, so apologies up front if this is a noddy question. I have a basic strategy I’m trying to set up for testing.
The idea is to catch a pullback into a trend (downtrend in the example here, but inverse would apply for uptrend) by identifying a candle which pushes up though a descending EMA but closes below, and using this as a trigger from which to place an order. As an example, a short entry 3 points below the lowest Low of the 5 candles preceding the Trigger candle. I’ve managed to get as far as identifying the Trigger candle and coding an entry which works provided the candle immediately following the Trigger candle hits the entry price, but if I’m understanding correctly, the order effectively dies if not hit by this next candle. I want to keep the order valid until hit, or cancelled by an intervening close above an EMA. Hopefully the attached image illustrates.
Any pointers greatly appreciated.
Regards
WT
Easiest way to get an answer is to post your code thus far (using the Insert PRT Code on the toolbar above each new post).
Are you using the Select File button below each new post to (try) and attach an image?
Just set a flag to keep putting the order on the market until you no longer want to: Something like:
if not onmarket and (your signal candle conditions) then
flag = 1
endif
if flag and not onmarket then
sellshort 1 contract at (my price) stop
endif
if onmarket or (your stop placing orders condition) then
flag = 0
endif
Not tested.
Thanks for the replies both, I’ll have a play around and see what I can do. Is it the case then that if I assign a variable a value, that value is ‘remembered’ beyond the next candle? Is it just the Order that gets forgotten?
Re. the image yeah I tried the Select File thing… In fact I’ll try it again here now…
Variable values are remembered candle to candle. You can use the instruction ONCE before assigning a variable value and this means that that value is only set on the very first run through the code and not on subsequent candles.
Limit and stop orders last for just one candle.
Your image is very clear and should be easy to code. Often the best way to code is to write down what you want in clearly defined steps and often you will find that the code is not far off what you have written down so you are half way there already.
I think it is best if you have a crack at it yourself and ask any questions that crop as you will learn so much more doing it that way.
Absolutely, thanks very much for the response. Will have a go over the next few days.
cheers,
WT