How do I add a 5 min timeframe filter to strategy based on 400 tick bars?


0
0

I trade using 400 tick charts using the code below

Question: How do I add another condition based on a 5 min timeframe.

I only want the alert above to trigger if the closing price is above the 20 EMA on a 5 min chart. If the closing price of the latest 5 min bar is below the 20 EMA I don’t want the alter to trigger.

 

See attached 5 min and 400 tick charts side by side

Attachments:
Marked as spam
Posted by (Questions: 7, Answers: 11)
Asked on May 18, 2018 1:53 pm
80 views
0
Private answer

I’ll have to make some assumptions since the code was not included. So I will give you a piece of code that evaluates to true if the close of the 5 min candle is above the 20 period ema of the 5 min time frame.

def ema = ExpAverage(close(period = AggregationPeriod.FIVE_MIN), 21);
def isTrue = close(period = AggregationPeriod.FIVE_MIN) > ema;

I have not tested this on a 400 tick chart. Should work on any time frame of 5 min and below.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 18, 2018 2:04 pm