How to set aggregation on conditional orders


Category:
0
0

I have been working with the “Thinkorswim AutoTrade Almost” video and was wondering how the aggration is managed, ie daily, Hourly, 30 minute and so on.

Marked as spam
Posted by (Questions: 5, Answers: 2)
Asked on January 30, 2019 7:07 am
385 views
0
Private answer

Screenshot below shows how to set the aggregation period when entering a conditional order.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 30, 2019 10:40 am
0

I’d like to expand on the original question a bit. How can you, in the thinkScript Editor assign a secondary aggregate period to a study such as MACD? For example, if my primary aggregate period is 1 Min how do I set an order trigger when the 5 Min MACD and 1 Hour MACD conditions are met?

Thanks!

( at February 16, 2019 8:25 am)
0

To reference the 5 min close from a 1 min aggregation period use this: def fiveMinClose = close(period = AggregationPeriod.FIVE_MIN);

From what you have described so far, your full request is going to be far more complex than what we provide at no charge in the Q&A forum. So if you need someone to write the entire code for you I suggest you consider submitting a custom project request here: https://www.hahn-tech.com/about/

( at February 16, 2019 11:05 am)
0

Thanks for the reply so soon! I think I found a workaround but i’ll give your method a try too.

input MINprice = close;
input MINlength = 14;
input MINover_bought = 70;
input MINover_sold = 40;
input MINrsiAverageType = AverageType.WILDERS;

input MIN5price = close;
input MIN5length = 70;
input MIN5over_bought = 70;
input MIN5over_sold = 40;
input MIN5rsiAverageType = AverageType.WILDERS;

input MINfastLength = 12;
input MINslowLength = 26;
input MINmacdLength = 9;
input MINaverageType = AverageType.EXPONENTIAL;

input MIN5fastLength = 60;
input MIN5slowLength = 130;
input MIN5macdLength = 45;
input MIN5averageType = AverageType.EXPONENTIAL;

input HOURfastLength = 720;
input HOURslowLength = 1560;
input HOURmacdLength = 540;
input HOURaverageType = AverageType.EXPONENTIAL;

def MINrsi = reference RSI(price = MINprice, length = MINlength, averageType = MINrsiAverageType);
def MIN5rsi = reference RSI(price = MIN5price, length = MIN5length, averageType = MIN5rsiAverageType);
def MINdiff = reference MACD(MINfastLength, MINslowLength, MINmacdLength, MINaverageType).Diff;
def MIN5diff = reference MACD(MIN5fastLength, MIN5slowLength, MIN5macdLength, MIN5averageType).Diff;
def HOURdiff = reference MACD(HOURfastLength, HOURslowLength, HOURmacdLength, HOURaverageType).Diff;

I need to test this strategy deeper to see how it performs. Thank you for your vids on creating strategies by the way. They are so powerful.

( at February 16, 2019 11:20 am)
0
My method doesn’t quite work…Using your method, where do I apply the new definition to the MACD? input fastLength = 12; input slowLength = 26; input macdLength = 9; input averageType = AverageType.EXPONENTIAL; def fiveMinClose = close(period = AggregationPeriod.FIVE_MIN); def diff = reference MACD(fastLength, slowLength, macdLength, averageType).Diff; AddOrder(OrderType.BUY_AUTO, diff crosses above 0, tickcolor = GetColor(0), arrowcolor = GetColor(0)); AddOrder(OrderType.SELL_AUTO, diff crosses below 0, tickcolor = GetColor(1), arrowcolor = GetColor(1));
( at February 16, 2019 8:14 pm)
0

Nevermind, I got it!

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
def Min5Value = MovingAverage(averageType, close(period = AggregationPeriod.FIVE_MIN), fastLength) – MovingAverage(averageType, close(period = AggregationPeriod.FIVE_MIN), slowLength);
def Min5Avg = MovingAverage(averageType, Min5Value, MACDLength);
AddOrder(OrderType.BUY_AUTO, Min5Value – Min5Avg > 0;

( at February 18, 2019 8:48 am)
0

Great, glad you worked it out. If you want to see an example, be sure to check out this video: https://www.hahn-tech.com/thinkorswim-mtf-macd-indicator/

( at February 18, 2019 1:31 pm)
0

THAT’S AMAZING!!! Exactly what I was trying to achieve. So much headache for something that already exists…

( at February 19, 2019 11:09 am)