TradingView
TradeSmart22
2023年6月30日早上8點53分

ATR GOD Strategy by TradeSmart (PineConnector-compatible) 

Euro Fx/U.S. DollarFXCM

描述

This is a highly-customizable trading strategy made by TradeSmart, focusing mainly on ATR-based indicators and filters. The strategy is mainly intended for trading forex, and has been optimized using the Deep Backtest feature on the 2018.01.01 - 2023.06.01 interval on the EUR/USD (FXCM) 15M chart, with a Slippage value of 3, and a Commission set to 0.00004 USD per contract. The strategy is also made compatible with PineConnector, to provide an easy option to automate the strategy using a connection to MetaTrader. See tooltips for details on how to set up the bot, and check out our website for a detailed guide with images on how to automate the strategy.

The strategy was implemented using the following logic:

Entry strategy:
A total of 4 Supertrend values can be used to determine the entry logic. There is option to set up all 4 Supertrend parameters individually, as well as their potential to be used as an entry signal/or a trend filter. Long/Short entry signals will be determined based on the selected potential Supertrend entry signals, and filtered based on them being in an uptrend/downtrend (also available for setup). Please use the provided tooltips for each setup to see every detail.

Exit strategy:
4 different types of Stop Losses are available: ATR-based/Candle Low/High Based/Percentage Based/Pip Based. Additionally, Force exiting can also be applied, where there is option to set up 4 custom sessions, and exits will happen after the session has closed.

Parameters of every indicator used in the strategy can be tuned in the strategy settings as follows:
Plot settings:
  • Plot Signals: true by default, Show all Long and Short signals on the signal candle
  • Plot SL/TP lines: false by default, Checking this option will result in the TP and SL lines to be plotted on the chart.


Supertrend 1-4:
All the parameters of the Supertrends can be set up here, as well as their individual role in the entry logic.

Exit Strategy:
  • ATR Based Stop Loss: true by default
  • ATR Length (of the SL): 100 by default
  • ATR Smoothing (of the SL): RMA/SMMA by default
  • Candle Low/High Based Stop Loss: false by default, recent lowest or highest point (depending on long/short position) will be used to calculate stop loss value. Set 'Base Risk Multiplier' to 1 if you would like to use the calculated value as is. Setting it to a different value will count as an additional multiplier.
  • Candle Lookback (of the SL): 50 by default
  • Percentage Based Stop Loss: false by default, Set the stop loss to current price - % of current price (long) or price + % of current price (short).
  • Percentage (of the SL): 0.3 by default
  • Pip Based Stop Loss: Set the stop loss to current price - x pips (long) or price + x pips (short). Set 'Base Risk Multiplier' to 1 if you would like to use the calculated value as is. Setting it to a different value will count as an additional multiplier.
  • Pip (of the SL): 10 by default
  • Base Risk Multiplier: 4.5 by default, the stop loss will be placed at this risk level (meaning in case of ATR SL that the ATR value will be multiplied by this factor and the SL will be placed that value away from the entry level)
  • Risk to Reward Ratio: 1.5 by default, the take profit level will be placed such as this Risk/Reward ratio is met


Force Exiting:
4 total Force exit on custom session close options: none applied by default. If enabled, trades will close automatically after the set session is closed (on next candle's open).

Base Setups:
  • Allow Long Entries: true by default
  • Allow Short Entries: true by default
  • Order Size: 10 by default
  • Order Type: Capital Percentage by default, allows adjustment on how the position size is calculated: Cash: only the set cash amount will be used for each trade Contract(s): the adjusted number of contracts will be used for each trade Capital
  • Percentage: a % of the current available capital will be used for each trade


ATR Limiter:
  • Use ATR Limiter: true by default, Only enter into any position (long/short) if ATR value is higher than the Low Boundary and lower than the High Boundary.
  • ATR Limiter Length: 50 by default
  • ATR Limiter Smoothing: RMA/SMMA by default
  • High Boundary: 1000 by default
  • Low Boundary: 0.0003 by default
  • MA based calculation: ATR value under MA by default, If not Unspecified, an MA is calculated with the ATR value as source. Only enter into position (long/short) if ATR value is higher/lower than the MA.
  • MA Type: RMA/SMMA by default
  • MA Length: 400 by default


Waddah Attar Filter:
  • Explosion/Deadzone relation: Not specified by default, Explosion over Deadzone: trades will only happen if the explosion line is over the deadzone line; Explosion under Deadzone: trades will only happen if the explosion line is under the deadzone line; Not specified: the opening of trades will not be based on the relation between the explosion and deadzone lines.
  • Limit trades based on trends: Not specified by default, Strong Trends: only enter long if the WA bar is colored green (there is an uptrend and the current bar is higher then the previous); only enter short if the WA bar is colored red (there is a downtrend and the current bar is higher then the previous); Soft Trends: only enter long if the WA bar is colored lime (there is an uptrend and the current bar is lower then the previous); only enter short if the WA bar is colored orange (there is a downtrend and the current bar is lower then the previous); All Trends: only enter long if the WA bar is colored green or lime (there is an uptrend); only enter short if the WA bar is colored red or orange (there is a downtrend); Not specified: the color of the WA bar (trend) is not relevant when considering entries.
  • WA bar value: Not specified by default, Over Explosion and Deadzone: only enter trades when the WA bar value is over the Explosion and Deadzone lines; Not specified: the relation between the explosion/deadzone lines to the value of the WA bar will not be used to filter opening trades.
  • Sensitivity: 150 by default
  • Fast MA Type: SMA by default
  • Fast MA Length: 10 by default
  • Slow MA Type: SMA
  • Slow MA Length: 20 by default
  • Channel MA Type: EMA by default
  • BB Channel Length: 20 by default
  • BB Stdev Multiplier: 2 by default


Trend Filter:
  • Use long trend filter 1: false by default, Only enter long if price is above Long MA.
  • Show long trend filter 1: false by default, Plot the selected MA on the chart.
  • TF1 - MA Type: EMA by default
  • TF1 - MA Length: 120 by default
  • TF1 - MA Source: close by default
  • Use short trend filter 1: false by default, Only enter long if price is above Long MA.
  • Show short trend filter 1: false by default, Plot the selected MA on the chart.
  • TF2 - MA Type: EMA by default
  • TF2 - MA Length: 120 by default
  • TF2 - MA Source: close by default


Volume Filter:
  • Only enter trades where volume is higher then the volume-based MA: true by default, a set type of MA will be calculated with the volume as source, and set length
  • MA Type: RMA/SMMA by default
  • MA Length: 200 by default


Date Range Limiter:
  • Limit Between Dates: false by default
  • Start Date: Jan 01 2023 00:00:00 by default
  • End Date: Jun 24 2023 00:00:00 by default


Session Limiter:
  • Show session plots: false by default, show market sessions on chart: Sidney (red), Tokyo (orange), London (yellow), New York (green)
  • Use session limiter: false by default, if enabled, trades will only happen in the ticked sessions below.
  • Sidney session: false by default, session between: 15:00 - 00:00 (EST)
  • Tokyo session: false by default, session between: 19:00 - 04:00 (EST)
  • London session: false by default, session between: 03:00 - 11:00 (EST)
  • New York session: false by default, session between: 08:00 - 17:00 (EST)


Trading Time:
  • Limit Trading Time: true by default, tick this together with the options below to enable limiting based on day and time
  • Valid Trading Days Global: 123567 by default, if the Limit Trading Time is on, trades will only happen on days that are present in this field. If any of the not global Valid Trading Days is used, this field will be neglected. Values represent days: Sunday (1), Monday (2), ..., Friday (6), Saturday(7) To trade on all days use: 123457
  • (1) Valid Trading Days: false, 123456 by default, values represent days: Sunday (1), Monday (2), ..., Friday (6), Saturday(7) The script will trade on days that are present in this field. Please make sure that this field and also (1) Valid Trading Hours Between is checked
  • (1) Valid Trading Hours Between: false, 1800-2000 by default, hours between which the trades can happen. The time is always in the exchange's timezone
  • All other options are also disabled by default


PineConnector Automation:
  • Use PineConnector Automation: false by default, In order for the connection to MetaTrader to work, you will need do perform prerequisite steps, you can follow our full guide at our website, or refer to the official PineConnector Documentation. To set up PineConnector Automation on the TradingView side, you will need to do the following:
    1. Fill out the License ID field with your PineConnector License ID;
    2. Fill out the Risk (trading volume) with the desired volume to be traded in each trade (the meaning of this value depends on the EA settings in Metatrader. Follow the detailed guide for additional information);
    3. After filling out the fields, you need to enable the 'Use PineConnector Automation' option (check the box in the strategy settings);
    4. Check if the chart has updated and you can see the appropriate order comments on your chart;
    5. Create an alert with the strategy selected as Condition, and the Message as {{strategy.order.comment}} (should be there by default);
    6. Enable the Webhook URL in the Notifications section, set it as the official PineConnector webhook address and enjoy your connection with MetaTrader.

  • License ID: 60123456789 by default
  • Risk (trading volume): 1 by default


NOTE! Fine-tuning/re-optimization is highly recommended when using other asset/timeframe combinations.

發布通知

BUGFIX: "License ID" field would not let 13 digit integers to be added in the field due to its default maxval limit being lower. 13 digit integers can now be added.
評論
imnotjames001
Super Brilliant. Thank you for sharing your ideas. I have question, How I can get the direction? Is it strategy.direction?
{
'direction':
}
imnotjames001
@imnotjames001, I know now. I can get the direction by checking the strategy.position_size.
strategy.position_size > 0 = long entry
strategy.position_size < 0 = short entry
If you have any idea to share then that's be good also.
imnotjames001
@imnotjames001, I already solved my problem. Thanks!
Mack_Dee_Sr
@TradeSmart22 I am liking the code so far. Haven't dove into it super deep just yet but i wanted to pass on a bit of code that I use in my own strategy. Since I am trading with a prop firm on MT5 and they require a stop loss I add this to my strategy. The stops and take profits don't matter at all, they are just there to fulfill the requirement of having a stop loss. Hope that makes sense and this is useful.

LicenseID = input.int(6822396500000, 'License ID') // 1. Change to your PineConnector License ID (required)
riskvalue = input.float(0.01, 'Risk Value') // 2. Number of Contracts to Purchase
stopLoss = input.float(1000, 'Stop Loss') // 3. Stop Loss in ticks. This would equal $10.00 on MT5
trailTrig = input.float(-1, 'Trail Trigger') // 4. Negative Number to Auto-Trigger
trailDist = input.float(750, 'Trail Distance') // 5. Trail Distance in Ticks. May need to add an additional 0 on MT5, Unsure
trailStep = input.float(1, 'Trail Step') // 6. How much to change Trail Distance as it moves. This is 1 Tick.
takeProfit = input.float(3000, 'Take Profit') // 7. Take Profit Amount. This equals $30.00 on MT5

if open > close
strategy.entry('long', strategy.long) // example long entry

//MUST ADD THIS WHOLE ALERT!!!

alert(str.tostring(LicenseID)+',
buy,' + syminfo.ticker + ',
risk=' + str.tostring(riskvalue) + ',
sl=' + str.tostring(stopLoss) + ',
trailtrig=' + str.tostring(trailTrig) + ',
traildist=' + str.tostring(trailDist) + ',
trailstep=' + str.tostring(trailStep) + ',
tp=' + str.tostring(takeProfit),
alert.freq_once_per_bar_close)

if open < close
strategy.entry('short', strategy.short) // example short entry

//MUST ADD THIS WHOLE ALERT!!!

alert(str.tostring(LicenseID)+',
sell,' + syminfo.ticker + ',
risk=' + str.tostring(riskvalue) + ',
sl=' + str.tostring(stopLoss) + ',
trailtrig=' + str.tostring(trailTrig) + ',
traildist=' + str.tostring(trailDist) + ',
trailstep=' + str.tostring(trailStep) + ',
tp=' + str.tostring(takeProfit),
alert.freq_once_per_bar_close)

if open == close and strategy.position_size != 0 // example close all (i.e. to close at end of trading day)
strategy.close_all()
alert(str.tostring(LicenseID)+',
closelongshort,' + syminfo.ticker)
Rabieg
when do you plan on releasing new scripts and update pervious scripts you released
SeehraSingh
Hey Guys! Is anyone able to connect this Indicator to MT4 Via Pine Connector? I am trying all the suggested methods but nothing working... Other methods are working fine to connect Pine Connector with MT4!
FrankJohnson
@SeehraSingh, I have been trying to get any code to work w Pineconnector. I can only get Buy and Sell orders to work sometimes, but never a Take Profit. I have asked their support team about it a lot. They don't have any working examples available to share with me which sucks. Have you had any success making a script enter and exit trades when the signal comes through? I got it to connect by adding Pineconnector to the chart on MT4 and putting my user ID in the box under Pine Connector EA settings.
更多