Strategy Using the Low of Previous candle as Entry II


Category:
0
0

I am reposting this questions to include a screenshot..

Hello all. I am building a strategy to back test and I cannot figure out if there is a way to use the low of a previous candle for an entry.  On this particular strategy, after a RED candle crosses below the 10EMA, and there is a RED candle after that, I want it to trigger in a “SELL” if the price drops to -.01 below the low of the 2nd Red candle. Is there a way to do that? Here is my code so far.

input tradeSize = 100; def signal = high[1] crosses above MovAvgExponential(“length” = 10).”AvgExp” and (TTM_Squeeze().”Histogram”[1] is less than 0 and TTM_Wave().”Wave2High”[1] is less than 0) AND (close[1]< open[1]) AND (TTM_Wave().”Wave2LOW” < TTM_Wave().”Wave2LOW”[1]) AND (close[0] < open[0]);

AddOrder(OrderType.SELL_TO_OPEN, signal, open[0], tradeSize, Color.CYAN, Color.CYAN);

def exit = TTM_Wave().”Wave2LOW” > TTM_Wave().”Wave2LOW”[1]; AddOrder(OrderType.BUY_TO_CLOSE, exit, open, tradeSize, Color.MAGENTA, Color.MAGENTA);

I know it sounds weird, but I prefer the “cross” signal to go off when the high crosses above the 10ema, because if it does that and comes back down to form a red candle, it reinforces the resistance of that 10ema. I copied a screen shot of my entry and stop. Then second candle needs to be red and go below the signal candle. Once that happens, take the trade .01$ below 2nd candle with protective stop .01$ above signal candle. If possible, I would like to get out the open of the first candle after the first “yellow” ttm squeeze bar. I hope this clarifies my question a bit more sir.
(the red arrow signifies a red candle crossing above 10ema)

Attachments:
Marked as spam
Posted by (Questions: 2, Answers: 3)
Asked on December 28, 2018 9:44 am
298 views
0
Private answer

Ok, much better than the original post. However there is still a discrepancy between you code and your stated goal for the signal candle: “the red arrow signifies a red candle crossing above 10ema”

Your code is actually doing this: “the high of the previous candle is greater than the 10 ema of the current candle”. Got that? This means that in your code it is entirely possible for that signal candle to have a high that is below the value of its own 10 ema and not crossing at all. (example shown in the screenshot below)

As long as you see and understand this, not an issue. It’s just that in my line of work details are the only thing that matter. So I like to make sure folks understand when something is misstated. Could make all the difference in the world.

In order to handle the entry you have specified we will add a new variable statement to handle that entry of one penny below the low of the 2nd candle:

def entryCandle = signal and low < low[1] - 0.01;

Next, we make a simple modification to your AddOrder statement:

AddOrder(OrderType.SELL_TO_OPEN, signal and entryCandle, Min(open[-1], low[0] - 0.01), tradeSize, Color.CYAN, Color.CYAN);

Now it’s very important to notice the section of the AddOrder statement that handles the entry price. You must be very careful to ensure the value used there is a value that was achievable in live trading. So if your entry is at the low of the previous candle, you need to check if the open of the next candle is less than that low. Your trade will execute at the lesser of the two values.

As to your protective stop. That is a bit too far advanced for something we provide at no charge in our Q&A forum. There are complexities there which are often difficult to nail down.

 

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on December 31, 2018 9:20 am