NexusFi: Find Your Edge


Home Menu

 





Multi time frame MACD signal help needed


Discussion in ThinkOrSwim

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




 
Search this Thread

Multi time frame MACD signal help needed

  #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?
Quantum physics & Trading dynamics
The Elite Circle
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
  #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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts