TradingView strategy connected to TradeLocker

How to Automate a MACD SMA 200 Strategy with TradeLocker

MACD reacts to changing momentum. SMA 200 barely notices the noise of a single candle. This strategy makes the impatient signal ask permission from the slow trend filter before an SP500 order is allowed to reach TradeLocker.

Strategy MACD + SMA 200
Chart used Vantage SP500 CFD
Timeframe 30 minutes
Destination TradeLocker

A momentum indicator can be like a man at the window who announces a revolution every time three people run across the street. Sometimes he is right. Sometimes they are only trying to catch a bus.

MACD is useful because it notices changes in momentum. That same sensitivity can make it enthusiastic during a market that has no lasting direction. The MACD + SMA 200 Strategy by ChartArt gives MACD a slower companion. Before the strategy acts, price must also be on the correct side of a 200-period simple moving average.

The script is open source and can be used without purchasing it. That fact makes the experiment accessible, but it is not the main story. The important question is whether a slow trend filter can prevent a quicker momentum system from trading against the larger direction.

MACD finds movement, but SMA 200 decides where movement is allowed

MACD is built from moving averages of the same price series. The strategy checks the MACD histogram, MACD momentum and the relationship between the two internal MACD averages.

For a long condition, the histogram and momentum must be above zero, and the moving average identified by the script as fast must be above the one identified as slow. Even then, no long trade is allowed unless the recent price is above SMA 200.

The short condition turns the entire argument upside down. The MACD components must support bearish momentum, and price must be below SMA 200.

SMA 200 is a gatekeeper, not the entry signal.

MACD brings the trade proposal. SMA 200 checks whether that proposal agrees with the larger chart direction. The gate opens only when both conditions point toward the same side.

Consider price slightly below SMA 200 while MACD suddenly becomes bullish. MACD may have detected a real upward bounce, but the strategy refuses the long order because the broader filter remains bearish.

The filter can keep the strategy out of a weak countertrend move. It can also make the strategy late when a genuine trend reversal begins. A gatekeeper avoids some bad guests, but occasionally keeps a good guest waiting outside.

The tested MACD values are not arranged in the usual order

The visible inputs on the TradingView chart are:

MACD fast moving average 14
MACD slow moving average 9
MACD signal line 15
Very slow moving average 200

The names fast and slow belong to the input fields. The numbers create an unusual situation. A moving average using nine candles responds to new prices faster than one using fourteen candles.

Therefore, the field labelled slow contains the more responsive length, while the field labelled fast contains the less responsive length. The script still compares the two series according to its own logic, but we should not pretend that this is a conventional MACD arrangement.

The signal line uses 15 periods, adding another layer of smoothing before the histogram describes the relationship between MACD and its signal.

Do not silently exchange 14 and 9 because their order looks strange.

Swapping the values creates a different experiment. The recorded result belongs to the exact configuration shown on the chart.

Source remains set to Close. Bar Color, Moving Averages and Background Color affect what the chart displays. They do not change the conditions used to generate strategy orders.

Thirty-minute candles change the meaning of the 200-period filter

The market remains the Vantage S&P Index Cash CFD (USD), but the timeframe has changed from the five-minute chart used in the previous experiment to 30 minutes.

A 200-period average on this chart contains 200 completed 30-minute candles. That equals 100 chart-hours of price history. The same period value on a five-minute chart would contain only about sixteen hours and forty minutes of chart time.

The number written in the input remains 200, but the memory behind it becomes six times wider when the timeframe moves from five minutes to thirty minutes.

The MACD components also slow down in clock time. A 14-period average now covers seven chart-hours, while nine periods cover four and a half chart-hours. The signal line covers seven and a half chart-hours.

This is why moving a strategy to another timeframe is not merely enlarging the candles on the screen. It changes the real duration represented by every period input and therefore changes the personality of the system.

The SP500 test was kept inside the same laboratory

The recorded test covers January 2, 2025 through July 25, 2026. The initial capital is $100,000, and every strategy order uses 10% of equity.

Script execution remains On bar close. The strategy waits for the current 30-minute candle to finish before it accepts the final values of MACD, SMA 200 and price.

A bullish condition may appear ten minutes into a candle and disappear before minute thirty. With bar-close execution, that unfinished opinion does not become a strategy order.

Commission and slippage remain zero in the recorded Strategy Tester result. This allows the strategy logic to be examined under the same baseline, but it also means the report does not contain the full cost of broker execution.

Test element Recorded value What it controls
Chart Vantage SP500 CFD The candle stream used by the indicators and strategy.
Timeframe 30 minutes The clock duration represented by every indicator period.
Initial capital $100,000 The starting balance of the TradingView simulation.
Order size 10% of equity The quantity calculated by the TradingView strategy.
Script execution On bar close The strategy acts only after the candle is complete.
Max Intraday Loss 50% The script's emergency daily equity-loss boundary.

A Max Intraday Loss value of 50% is not a sensible risk recommendation. It is a very distant emergency wall inherited from the strategy configuration. An account losing half of its equity in one day would already be in disastrous condition.

The win rate tells only half of the result

Total P&L +$4,527.47 +4.53%
Maximum drawdown $559.27 0.54%
Profitable trades 53 of 90 58.89%
Profit factor 2.528 Simulated result

The strategy completed ninety simulated trades. Fifty-three were profitable and thirty-seven were not, producing a win rate of 58.89%.

That percentage is lower than the result of the Bollinger RSI test, but the MACD SMA 200 report produced a slightly higher profit factor of 2.528.

Profit factor compares total gross profit with total gross loss. During this sample, the strategy generated approximately $2.53 of simulated gross profit for every $1 of simulated gross loss.

Total simulated profit reached $4,527.47, while maximum drawdown was $559.27. This is why a strategy should not be judged by win rate alone. The size of wins and losses matters as much as the number of each.

Ninety trades across more than eighteen months create a useful test record, but they do not remove uncertainty. Another SP500 provider, realistic costs or an unseen period can produce another outcome.

Reverse/Netting keeps TradeLocker in one resulting direction

The strategy expresses one current market state. It can be long, short or flat. It is not designed to preserve an old bullish SP500 position while opening an independent bearish SP500 position beside it.

Hedge/Dual Side

Hedge mode can keep long and short exposure as separate positions. A new sell instruction does not necessarily erase the existing buy side. TradeLocker could therefore contain both directions while TradingView reports only one current strategy state.

Reverse/Netting

Reverse/Netting maintains one resulting exposure for the instrument. An opposite instruction works against the current position. The existing direction is reduced or removed, and any remaining quantity establishes the new net direction.

Opposite/Flip

Flip mode explicitly closes the previous side and opens the newly requested direction. It is useful when an integration must perform that two-stage change regardless of the incoming and existing quantities.

For this TradeLocker route, the selected mode is Reverse/Netting. The choice follows the account's one-way position model and the strategy's single directional state.

Suppose the account is long SP500 and the next strategy order is short. In a netting model, the sell quantity first meets the existing buy exposure. It may close it exactly, reduce it or continue through zero into a short position, depending on the quantities involved.

This behaviour is fundamentally different from keeping two separate tickets alive. The TradeLocker account and the TradingView strategy continue describing one net market direction.

Creating the TradeLocker webhook means identifying one exact account

Open Dashboard >> Trade Webhooks in AlgoWay and create a new route from TradingView to TradeLocker.

  1. Select TradingView as the source. AlgoWay will expect a message produced by a TradingView alert rather than an instruction arriving from Telegram or another source.
  2. Select TradeLocker as the destination. The form will request the connection details TradeLocker needs: environment, account credentials, server and Account ID.
  3. Choose Reverse/Netting as Trade Type. This keeps the SP500 exposure as one resulting position instead of preserving buy and sell sides independently.
  4. Choose the correct TradeLocker URL. Demo and live accounts can belong to different environments. The URL must match the environment where the intended account actually exists.
  5. Enter the account email, password, server and Account ID. Together these values identify the destination account. None of them belongs in the TradingView alert message, and none should appear in a public image.
  6. Set Quantity Multiplier to Absolute 1. A multiplier of 1 leaves the incoming TradingView quantity unchanged. It should not secretly enlarge or shrink the first strategy order.
  7. Check the TradeLocker instrument name. TradingView sends SP500 from the current chart. When TradeLocker uses another name, enter a Symbol Mapping from the TradingView ticker to the exact broker symbol.
  8. Save the webhook. Saving creates the route, but it does not yet prove that authentication, symbol recognition and order submission all work.

The 0.01 test order is a knock on the door, not a strategy signal

After creating the webhook, open Dashboard >> Webhook Logs and select Test Webhook.

Choose the new TradeLocker route, enter SP500 or the mapped broker symbol, select Buy and enter the smallest quantity that the instrument accepts. The recorded example uses 0.01.

The manual test has one narrow purpose.

It checks whether AlgoWay can authenticate with TradeLocker, locate the account, recognize the symbol and submit the selected volume. It does not evaluate MACD, SMA 200 or any historical strategy condition.

Send the test, read the resulting AlgoWay log and confirm the position inside TradeLocker. Then close the test position before the TradingView strategy begins sending its own orders.

A successful test tells us the road is open. It does not tell us what vehicle the strategy will send down that road or when it will begin the journey.

The final alert must preserve the strategy's calculated quantity

The TradingView strategy calculates order size from the Properties setting of 10% of equity. Hardcoding 0.01 in the final alert would discard that calculation and replace every strategy order with the manual test quantity.

The working TradeLocker message is:

{"platform_name":"tradelocker","ticker":"{{ticker}}","order_contracts":"{{strategy.order.contracts}}","order_action":"{{strategy.market_position}}","price":{{close}}}
{{ticker}}

TradingView replaces this placeholder with the ticker of the chart where the strategy alert was created. AlgoWay applies Symbol Mapping when the TradeLocker broker uses another name.

{{strategy.order.contracts}}

TradingView replaces this placeholder with the number of contracts in the executed strategy order. It preserves the strategy calculation instead of reusing the temporary 0.01 test quantity.

{{strategy.market_position}}

TradingView inserts the resulting strategy state as long, short or flat. AlgoWay uses that state to determine the direction that TradeLocker must hold after the instruction is processed.

{{close}}

TradingView inserts the closing price of the alert candle. This provides context in the webhook log, but it is not a promise that TradeLocker will execute at exactly that price.

Creating the alert transfers the tested chart state to TradingView's servers

Return to the Vantage SP500 30-minute chart and confirm the visible inputs: source Close, MACD values 14, 9 and 15, SMA 200 and Max Intraday Loss 50%.

Open Create Alert and choose CA_-_MACD_SMA_strategy as the condition. Select strategy order fills so the alert is generated when the TradingView broker emulator executes a strategy order.

Paste the JSON message into the Message field. Open Notifications, enable Webhook URL and paste the unique URL copied from the AlgoWay TradeLocker webhook.

The webhook URL is a private command address. It should not appear in public screenshots, shared code or support messages containing unrelated recipients.

TradingView places a copy of the strategy configuration on its own alert servers. Changing the visible chart later does not update that existing copy. When the timeframe or strategy inputs change, remove the old alert and create a new one.

The first autonomous order must be checked in two different places

When a completed 30-minute candle creates a strategy order, TradingView fills the placeholders and sends the resulting JSON to AlgoWay.

AlgoWay validates the message, applies Symbol Mapping when required and submits the instruction to the selected TradeLocker account.

First open Dashboard >> Webhook Logs. Check the ticker, direction, quantity, status and TradeLocker response. Then open TradeLocker and inspect the actual position.

The broker execution price may differ from the TradingView candle close because of spread, market movement and the time required to deliver and execute the instruction. The critical comparison is whether the instrument, accepted volume and resulting net direction match the strategy order.

When the strategy later changes direction, the old exposure should not remain as an independent opposite position. Reverse/Netting should leave one resulting SP500 exposure.

The completed route

What this MACD SMA 200 experiment establishes

MACD provides the momentum conditions. SMA 200 decides whether those conditions agree with the larger chart direction. The 30-minute timeframe determines how much clock time every period represents.

On the selected Vantage SP500 history, the configuration produced ninety trades, $4,527.47 in simulated profit, a profit factor of 2.528 and maximum drawdown of $559.27.

The TradeLocker route uses Reverse/Netting because the strategy and destination account must describe one resulting direction. The manual 0.01 order verifies only the connection. The final alert restores the strategy's calculated quantity through {{strategy.order.contracts}}.

The result does not prove that the strategy will repeat its historical performance. It does provide a complete, reproducible path from the original TradingView script to an authenticated TradeLocker order.

Original strategy: MACD + SMA 200 Strategy by ChartArt . Execution route: AlgoWay TradingView Automation .

Direct answers

Direct answers about the MACD SMA 200 TradeLocker setup

Can a MACD SMA 200 TradingView strategy be automated with TradeLocker?

Yes. A MACD SMA 200 TradingView strategy can send its executed strategy orders to TradeLocker through an AlgoWay webhook. TradingView creates the strategy order, AlgoWay processes the alert message, and TradeLocker receives the broker-side instruction.

What does the SMA 200 do in this MACD strategy?

The SMA 200 acts as a direction filter. The strategy permits long conditions only while price is above the SMA 200 and permits short conditions only while price is below the SMA 200.

Why does this MACD SMA 200 test use a 30-minute chart?

The 30-minute timeframe reduces the number of short intrabar changes considered by the strategy and gives the 200-period moving average a much longer chart horizon than it would have on a five-minute chart.

Why are the MACD fast and slow values unusual in this configuration?

The field labelled MACD fast moving average contains 14 while the field labelled MACD slow moving average contains 9. A 9-period average responds faster than a 14-period average, so the practical responsiveness of the two averages is opposite to their field labels.

Which AlgoWay trade mode should this strategy use with TradeLocker?

This strategy should use Reverse/Netting mode because it maintains one resulting market direction for SP500 instead of keeping independent long and short positions open together.

Why should Hedge/Dual Side not be used for this TradeLocker setup?

Hedge/Dual Side can preserve a long position and a short position as separate exposures. That would allow the TradeLocker account to hold both directions while the TradingView strategy reports only one current market state.

What is the purpose of the AlgoWay Test Webhook?

The Test Webhook checks whether AlgoWay can authenticate with the TradeLocker account, recognize the selected symbol and submit a small manual order. It does not test the MACD strategy logic or the strategy's calculated position size.

Should 0.01 be used in the final TradingView strategy alert?

No. The value 0.01 is used only for a small manual connection test when the broker accepts that volume. The final strategy alert should use {{strategy.order.contracts}} so TradingView supplies the quantity calculated for the executed strategy order.

Which TradingView placeholders are used for TradeLocker automation?

The alert uses {{ticker}} for the chart symbol, {{strategy.order.contracts}} for the executed order quantity, {{strategy.market_position}} for the resulting long, short or flat state, and {{close}} for the closing price of the alert candle.

What results did the MACD SMA 200 SP500 test produce?

The recorded test produced $4,527.47 in simulated profit, a profit factor of 2.528, 53 profitable trades out of 90 and a maximum drawdown of $559.27 on $100,000 of simulated starting capital.

Historical backtest and risk notice

Test the strategy independently before using it

This page documents a historical TradingView backtest covering through . The reported results are simulated and depend on the selected symbol, data provider, timeframe, strategy settings, position-sizing rules, trading costs and execution assumptions. Market conditions, broker feeds and strategy performance may be different by the time you read this page.

This material is provided for research and technical demonstration only. It is not investment advice, a recommendation, or an invitation to begin using the strategy. Historical performance does not guarantee future results. AlgoWay accepts no responsibility for trading decisions or losses resulting from the use of this information.

Run your own backtest on the intended symbol, provider and timeframe using realistic spread, commission and slippage. After that, verify the complete alert, webhook, symbol, quantity and execution workflow on a demo account before considering any live trading.