How can I add MTF arrows to my 5 min charts

robopro

New member
VIP
This is the script...can you please add the code that would make 15 min arrows appear on my 5 min charts. Thank you

input accelerationFactor = 0.02;
input accelerationLimit = 0.2;

def sar = ParabolicSAR(accelerationFactor=accelerationFactor, accelerationLimit=accelerationLimit);
def signalDown = sar crosses above close;;
def signalUp = sar crosses below close;
def mode = if signalUp then 1 else if signalDown then 0 else mode[1];

plot upArrow = if signalUp then low else double.nan;
plot downArrow = if signalDown then high else double.nan;

upArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
downArrow.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
This is the script...can you please add the code that would make 15 min arrows appear on my 5 min charts. Thank you

input accelerationFactor = 0.02;
input accelerationLimit = 0.2;

def sar = ParabolicSAR(accelerationFactor=accelerationFactor, accelerationLimit=accelerationLimit);
def signalDown = sar crosses above close;;
def signalUp = sar crosses below close;
def mode = if signalUp then 1 else if signalDown then 0 else mode[1];

plot upArrow = if signalUp then low else double.nan;
plot downArrow = if signalDown then high else double.nan;

upArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
downArrow.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);

Place this indicator on a five minute chart, and select the PSAR_Timeframe of 15m.

The 5m bars on the left are from the boxed area shown on the 15m chart on the right. On the 5m chart, you will see three dots per 15m bar. The signals shown were at 10:00 and 13:45.

PSAR_MTF.jpg


PSAR_MTF

Code:
#
# PSAR_MTF by @mark.917 
#

input accelerationFactor = 0.02;
input accelerationLimit = 0.2;

assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");

def state = {default init, long, short};
def extreme;
def SAR;
def acc;

input PSAR_Timeframe = AggregationPeriod.FIFTEEN_MIN;

def high = high(period = PSAR_Timeframe);
def low = low(period = PSAR_Timeframe);

switch (state[1]) {
case init:
    state = state.long;
    acc = accelerationFactor;
    extreme = high;
    SAR = low;
case short:
    if (SAR[1] < high)
    then {
        state = state.long;
        acc = accelerationFactor;
        extreme = high;
        SAR = extreme[1];
    } else {
        state = state.short;
        if (low < extreme[1])
        then {
            acc = min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = low;
        } else {
            acc = acc[1];
            extreme = extreme[1];
        }
        SAR = max(max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
case long:
    if (SAR[1] > low)
    then {
        state = state.short;
        acc = accelerationFactor;
        extreme = low;
        SAR = extreme[1];
    } else {
        state = state.long;
        if (high > extreme[1])
        then {
            acc = min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = high;
        } else {
            acc = acc[1];
            extreme = extreme[1];
        }
        SAR = min(min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
}

plot parSAR = SAR;
parSAR.SetPaintingStrategy(PaintingStrategy.POINTS);
parSAR.SetDefaultColor(GetColor(5));

def signalDown = sar crosses above close;;
def signalUp = sar crosses below close;
def mode = if signalUp then 1 else if signalDown then 0 else mode[1];

plot upArrow = if signalUp then low else double.nan;
plot downArrow = if signalDown then high else double.nan;

upArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
downArrow.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
Place this indicator on a five minute chart, and select the PSAR_Timeframe of 15m.

The 5m bars on the left are from the boxed area shown on the 15m chart on the right. On the 5m chart, you will see three dots per 15m bar. The signals shown were at 10:00 and 13:45.

View attachment 19832

PSAR_MTF

Code:
#
# PSAR_MTF by @mark.917
#

input accelerationFactor = 0.02;
input accelerationLimit = 0.2;

assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");

def state = {default init, long, short};
def extreme;
def SAR;
def acc;

input PSAR_Timeframe = AggregationPeriod.FIFTEEN_MIN;

def high = high(period = PSAR_Timeframe);
def low = low(period = PSAR_Timeframe);

switch (state[1]) {
case init:
    state = state.long;
    acc = accelerationFactor;
    extreme = high;
    SAR = low;
case short:
    if (SAR[1] < high)
    then {
        state = state.long;
        acc = accelerationFactor;
        extreme = high;
        SAR = extreme[1];
    } else {
        state = state.short;
        if (low < extreme[1])
        then {
            acc = min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = low;
        } else {
            acc = acc[1];
            extreme = extreme[1];
        }
        SAR = max(max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
case long:
    if (SAR[1] > low)
    then {
        state = state.short;
        acc = accelerationFactor;
        extreme = low;
        SAR = extreme[1];
    } else {
        state = state.long;
        if (high > extreme[1])
        then {
            acc = min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = high;
        } else {
            acc = acc[1];
            extreme = extreme[1];
        }
        SAR = min(min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
}

plot parSAR = SAR;
parSAR.SetPaintingStrategy(PaintingStrategy.POINTS);
parSAR.SetDefaultColor(GetColor(5));

def signalDown = sar crosses above close;;
def signalUp = sar crosses below close;
def mode = if signalUp then 1 else if signalDown then 0 else mode[1];

plot upArrow = if signalUp then low else double.nan;
plot downArrow = if signalDown then high else double.nan;

upArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
downArrow.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Its' Perfect...Thank you Mark
 
Place this indicator on a five minute chart, and select the PSAR_Timeframe of 15m.

The 5m bars on the left are from the boxed area shown on the 15m chart on the right. On the 5m chart, you will see three dots per 15m bar. The signals shown were at 10:00 and 13:45.

View attachment 19832

PSAR_MTF

Code:
#
# PSAR_MTF by @mark.917
#

input accelerationFactor = 0.02;
input accelerationLimit = 0.2;

assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");

def state = {default init, long, short};
def extreme;
def SAR;
def acc;

input PSAR_Timeframe = AggregationPeriod.FIFTEEN_MIN;

def high = high(period = PSAR_Timeframe);
def low = low(period = PSAR_Timeframe);

switch (state[1]) {
case init:
    state = state.long;
    acc = accelerationFactor;
    extreme = high;
    SAR = low;
case short:
    if (SAR[1] < high)
    then {
        state = state.long;
        acc = accelerationFactor;
        extreme = high;
        SAR = extreme[1];
    } else {
        state = state.short;
        if (low < extreme[1])
        then {
            acc = min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = low;
        } else {
            acc = acc[1];
            extreme = extreme[1];
        }
        SAR = max(max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
case long:
    if (SAR[1] > low)
    then {
        state = state.short;
        acc = accelerationFactor;
        extreme = low;
        SAR = extreme[1];
    } else {
        state = state.long;
        if (high > extreme[1])
        then {
            acc = min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = high;
        } else {
            acc = acc[1];
            extreme = extreme[1];
        }
        SAR = min(min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
}

plot parSAR = SAR;
parSAR.SetPaintingStrategy(PaintingStrategy.POINTS);
parSAR.SetDefaultColor(GetColor(5));

def signalDown = sar crosses above close;;
def signalUp = sar crosses below close;
def mode = if signalUp then 1 else if signalDown then 0 else mode[1];

plot upArrow = if signalUp then low else double.nan;
plot downArrow = if signalDown then high else double.nan;

upArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
downArrow.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
374 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top