NexusFi: Find Your Edge


Home Menu

 





Multi time frame MACD signal help needed


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,498 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
NC001
raleigh nc wake
 
Posts: 10 since May 2020
Thanks Given: 10
Thanks Received: 1

I have assembled the following code to check for MACD crossing on the 15min chart and plotting a signal line on the 5 min. It results in three lines plotting. One for each 5 min candle. My question, is it possible to display only one signal at the last 5 min candle in the 15 min range. Any help is appreciated.


script MACD15 {
input TimeFrame = 5;
def agg = TimeFrame * 60000;
def vClose15 = close(period = agg);

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

DEF Value = MovingAverage(averageType, vClose15, fastLength) - MovingAverage(averageType, vClose15, slowLength);

DEF Avg = MovingAverage(averageType, Value, MACDLength);


DEF BULL_MACD = if Value crosses above Avg and Value < 0 then 1 else 0;

PLOT BEAR_MACD = if Value crosses below Avg and Value > 0 then 1 else 0;

}

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

DEF Value = MovingAverage(averageType, CLOSE, fastLength) - MovingAverage(averageType, CLOSE, slowLength);

DEF Avg = MovingAverage(averageType, Value, MACDLength);


DEF BULL_MACD = if Value crosses above Avg and Value < 0 then 1 else 0;

DEF BEAR_MACD = if Value crosses below Avg and Value > 0 then 1 else 0;

plot BULL_CONVERGENCE = IF MACD15(15).BULL_MACD then 1 else 0;
AddVerticalLine(BULL_CONVERGENCE, "BULL MACD", Color.CYAN, Curve.FIRM);

plot BEAR_CONVERGENCE = IF MACD15(15).BEAR_MACD then 1 else 0;
AddVerticalLine(BEAR_CONVERGENCE, "BEAR MACD", Color.RED, Curve.FIRM);


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My Rant with AMP Futures
Trading Reviews and Vendors
Trump Media to sell instant access to market-moving soci …
Traders Hideout
Datafeed for Atas
Platforms and Indicators
No book, only a stair: journaling fills where price move …
Cryptocurrency
EA
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
Johnnys Journal
2 thanks
TopStep Trader disappointment
2 thanks
  #2 (permalink)
trader1973
BAKU+AZERBAIJAN
 
Posts: 1 since Apr 2017
Thanks Given: 2
Thanks Received: 0


NC001 View Post
I have assembled the following code to check for MACD crossing on the 15min chart and plotting a signal line on the 5 min. It results in three lines plotting. One for each 5 min candle. My question, is it possible to display only one signal at the last 5 min candle in the 15 min range. Any help is appreciated.


script MACD15 {
input TimeFrame = 5;
def agg = TimeFrame * 60000;
def vClose15 = close(period = agg);

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

DEF Value = MovingAverage(averageType, vClose15, fastLength) - MovingAverage(averageType, vClose15, slowLength);

DEF Avg = MovingAverage(averageType, Value, MACDLength);


DEF BULL_MACD = if Value crosses above Avg and Value < 0 then 1 else 0;

PLOT BEAR_MACD = if Value crosses below Avg and Value > 0 then 1 else 0;

}

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

DEF Value = MovingAverage(averageType, CLOSE, fastLength) - MovingAverage(averageType, CLOSE, slowLength);

DEF Avg = MovingAverage(averageType, Value, MACDLength);


DEF BULL_MACD = if Value crosses above Avg and Value < 0 then 1 else 0;

DEF BEAR_MACD = if Value crosses below Avg and Value > 0 then 1 else 0;

plot BULL_CONVERGENCE = IF MACD15(15).BULL_MACD then 1 else 0;
AddVerticalLine(BULL_CONVERGENCE, "BULL MACD", Color.CYAN, Curve.FIRM);

plot BEAR_CONVERGENCE = IF MACD15(15).BEAR_MACD then 1 else 0;
AddVerticalLine(BEAR_CONVERGENCE, "BEAR MACD", Color.RED, Curve.FIRM);

Great job is done.But did U ever use it on real market? Regards,


Reply With Quote
  #3 (permalink)
NC001
raleigh nc wake
 
Posts: 10 since May 2020
Thanks Given: 10
Thanks Received: 1


trader 1973,

I use this as part of my scalping routine on a daily basis.

I am confused by your reply. Did you figure out a solution to my problem or just commenting on my code?

If you have a solution, then perhaps I missed it. Either way, thank you for your interest


Reply With Quote
  #4 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43

This approach might help. Check the last 3 values of the function must add to 3 as the condition to draw the line.
 
Code
def bull15 = MACD15(15).BULL_MACD;
def bear15 = MACD15(15).BEAR_MACD;
AddVerticalLine(bull15 + bull15[1] + bull15[2] == 3, "BULL MACD", Color.CYAN, Curve.FIRM);
AddVerticalLine(bear15 + bear15[1] + bear15[2] == 3, "BEAR MACD", Color.RED, Curve.FIRM);
Regards,
JayC


Reply With Quote
Thanked by:
  #5 (permalink)
NC001
raleigh nc wake
 
Posts: 10 since May 2020
Thanks Given: 10
Thanks Received: 1

Thank you JayC. You provided a perfect solution to my problem. Your help is much appreciated!


Reply With Quote




Last Updated on May 28, 2020


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts