For Gold 3-15 min

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © QueenCryptoSignal

//@version=5
strategy('FOREX XAUUSD 3m | 400 - 3.3', overlay=true)
src = input(close, title='Source')

// SETTING TRADEPLAN //
lowentry = input.float(2.68, "LOW (PIPS)", group="Entry Settings")
tp1 = input.float(5.36, "TP1 (PIPS)", group="TP/SL Settings")
tp2 = input.float(8.04, "TP2 (PIPS)", group="TP/SL Settings")
tp3 = input.float(10.72, "TP3 (PIPS)", group="TP/SL Settings")
tp4 = input.float(13.4, "TP4 (PIPS)", group="TP/SL Settings")
tp5 = input.float(16.08, "TP5 (PIPS)", group="TP/SL Settings")
tp6 = input.float(21.44, "TP6 (PIPS)", group="TP/SL Settings")
tp7 = input.float(26.8, "TP7 (PIPS)", group="TP/SL Settings")
tp8 = input.float(32.16, "TP8 (PIPS)", group="TP/SL Settings")
tp9 = input.float(37.52, "TP9 (PIPS)", group="TP/SL Settings")
tp10 = input.float(42.88, "TP10 (PIPS)", group="TP/SL Settings")
sl = input.float(5.36, "Stoploss (PIPS)", group="TP/SL Settings")

Periods = input.int(400, title='ATR Length')


Multiplier = input.float(3.3, title='ATR Multiplier', step=0.1)
mav = input.string('EMA', title='Moving Average Type', options=['SMA', 'EMA',
'WMA', 'TMA', 'VAR', 'WWMA', 'ZLEMA', 'TSF'])
length = input.int(10, title='Moving Average Length', minval=1)
changeATR = input.bool(true, title='Change ATR Calculation Method?')
showsupport = input.bool(true, title='Show Moving Average?')
showsignalsk = input.bool(true, title='Show Crossing Signals?')
showsignalsc = input.bool(false, title='Show Price/Pmax Crossing Signals?')
highlighting = input.bool(true, title='Highlighter On/Off?')

atr2 = ta.sma(ta.tr, Periods)


atr = changeATR ? ta.atr(Periods) : atr2

var_func(src, length) =>


valpha = 2 / (length + 1)
vud1 = src > src[1] ? src - src[1] : 0
vdd1 = src < src[1] ? src[1] - src : 0
vUD = math.sum(vud1, 9)
vDD = math.sum(vdd1, 9)
vCMO = nz((vUD - vDD) / (vUD + vDD))
VAR = 0.0
VAR := nz(valpha * math.abs(vCMO) * src) + (1 - valpha * math.abs(vCMO)) *
nz(VAR[1])
VAR

wwma_func(src, length) =>


wwalpha = 1 / length
WWMA = 0.0
WWMA := wwalpha * src + (1 - wwalpha) * nz(WWMA[1])
WWMA

zlema_func(src, length) =>


zxLag = length / 2 == math.round(length / 2) ? length / 2 : (length - 1) / 2
zxEMAData = src + src - src[zxLag]
ZLEMA = ta.ema(zxEMAData, length)
ZLEMA
tsf_func(src, length) =>
lrc = ta.linreg(src, length, 0)
lrc1 = ta.linreg(src, length, 1)
lrs = lrc - lrc1
TSF = ta.linreg(src, length, 0) + lrs
TSF

VAR = var_func(src, length)


WWMA = wwma_func(src, length)
ZLEMA = zlema_func(src, length)
TSF = tsf_func(src, length)

get_ma(src, length) =>


ma = 0.0
if mav == 'SMA'
ma := ta.sma(src, length)
if mav == 'EMA'
ma := ta.ema(src, length)
if mav == 'WMA'
ma := ta.wma(src, length)
if mav == 'TMA'
ma := ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) +
1)
if mav == 'VAR'
ma := VAR
if mav == 'WWMA'
ma := WWMA
if mav == 'ZLEMA'
ma := ZLEMA
if mav == 'TSF'
ma := TSF
ma

MAvg = get_ma(src, length)

pmax_func(src, length) =>


longStop = MAvg - Multiplier * atr
longStopPrev = nz(longStop[1], longStop)
longStop := MAvg > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = MAvg + Multiplier * atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := MAvg < shortStopPrev ? math.min(shortStop, shortStopPrev) :
shortStop
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg <
longStopPrev ? -1 : dir
PMax = dir == 1 ? longStop : shortStop
PMax

PMax = pmax_func(src, length)

plot(showsupport ? MAvg : na, color=color.new(#0585E1, 0), linewidth=2,


title='Moving Avg Line')
pALL = plot(PMax, color=color.new(color.red, 0), linewidth=2, title='PMax')

alertcondition(ta.cross(MAvg, PMax), title='Cross Alert', message='PMax - Moving


Avg Crossing!')
alertcondition(ta.crossover(MAvg, PMax), title='Crossover Alarm', message='Moving
Avg BUY SIGNAL!')
alertcondition(ta.crossunder(MAvg, PMax), title='Crossunder Alarm', message='Moving
Avg SELL SIGNAL!')
alertcondition(ta.cross(src, PMax), title='Price Cross Alert', message='PMax -
Price Crossing!')
alertcondition(ta.crossover(src, PMax), title='Price Crossover Alarm',
message='PRICE OVER PMax - BUY SIGNAL!')
alertcondition(ta.crossunder(src, PMax), title='Price Crossunder Alarm',
message='PRICE UNDER PMax - SELL SIGNAL!')

buySignalk = ta.crossover(MAvg, PMax)


plotshape(buySignalk and showsignalsk ? PMax * 0.995 : na, title='Buy', text='Buy',
location=location.absolute, style=shape.labelup, size=size.tiny,
color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
sellSignallk = ta.crossunder(MAvg, PMax)
plotshape(sellSignallk and showsignalsk ? PMax * 1.005 : na, title='Sell',
text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny,
color=color.new(color.red, 0), textcolor=color.new(color.white, 0))
buySignalc = ta.crossover(src, PMax)
plotshape(buySignalc and showsignalsc ? PMax * 0.995 : na, title='Buy', text='Buy',
location=location.absolute, style=shape.labelup, size=size.tiny,
color=color.new(#0F18BF, 0), textcolor=color.new(color.white, 0))
sellSignallc = ta.crossunder(src, PMax)
plotshape(sellSignallc and showsignalsc ? PMax * 1.005 : na, title='Sell',
text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny,
color=color.new(#0F18BF, 0), textcolor=color.new(color.white, 0))

mPlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0,


display=display.none)
longFillColor = highlighting ? (MAvg > PMax ? color.new(color.green, 90) : na) : na
shortFillColor = highlighting ? (MAvg < PMax ? color.new(color.red, 90) : na) : na
fill(mPlot, pALL, title='UpTrend Highlighter', color=longFillColor)
fill(mPlot, pALL, title='DownTrend Highlighter', color=shortFillColor)

// Screener label settings


showscr = input(true, title='Show Screener Label')
posX_scr = input(20, title='Pos. Label x-axis')
posY_scr = input(1, title='Pos. Size Label y-axis')
colinput = input.string(title='Label Color', defval='Blue', options=['White',
'Black', 'Red', 'Green', 'Yellow', 'Blue'])
col = colinput == 'White' ? color.white : colinput == 'Black' ? color.black :
colinput == 'Red' ? color.red : colinput == 'Green' ? color.green : colinput ==
'Yellow' ? color.yellow : color.blue

open_price = math.round_to_mintick(open)
close_price = math.round_to_mintick(close)

lowentry_l = math.round_to_mintick(close_price - lowentry)


tp1_l = math.round_to_mintick(close_price + tp1)
tp2_l = math.round_to_mintick(close_price + tp2)
tp3_l = math.round_to_mintick(close_price + tp3)
tp4_l = math.round_to_mintick(close_price + tp4)
tp5_l = math.round_to_mintick(close_price + tp5)
tp6_l = math.round_to_mintick(close_price + tp6)
tp7_l = math.round_to_mintick(close_price + tp7)
tp8_l = math.round_to_mintick(close_price + tp8)
tp9_l = math.round_to_mintick(close_price + tp9)
tp10_l = math.round_to_mintick(close_price + tp10)
sl_l = math.round_to_mintick(close_price - sl)
target_long_comment = str.tostring(tp1_l) + " - " + str.tostring(tp2_l) + " - " +
str.tostring(tp3_l) + " - " + str.tostring(tp4_l) + " - " + str.tostring(tp5_l) +
" - " + str.tostring(tp6_l) + " - " + str.tostring(tp7_l) + " - " +
str.tostring(tp8_l) + " - " + str.tostring(tp9_l) + " - " + str.tostring(tp10_l)
+ "\n\nSL: wait for opposite signal "

lowentry_s = math.round_to_mintick(close_price + lowentry)


tp1_s = math.round_to_mintick(close_price - tp1)
tp2_s = math.round_to_mintick(close_price - tp2)
tp3_s = math.round_to_mintick(close_price - tp3)
tp4_s = math.round_to_mintick(close_price - tp4)
tp5_s = math.round_to_mintick(close_price - tp5)
tp6_s = math.round_to_mintick(close_price - tp6)
tp7_s = math.round_to_mintick(close_price - tp7)
tp8_s = math.round_to_mintick(close_price - tp8)
tp9_s = math.round_to_mintick(close_price - tp9)
tp10_s = math.round_to_mintick(close_price - tp10)
sl_s = math.round_to_mintick(close_price + sl)
target_short_comment = str.tostring(tp1_s) + " - " + str.tostring(tp2_s) + " - " +
str.tostring(tp3_s) + " - " + str.tostring(tp4_s) + " - " + str.tostring(tp5_s) +
" - " + str.tostring(tp6_s) + " - " + str.tostring(tp7_s) + " - " +
str.tostring(tp8_s) + " - " + str.tostring(tp9_s) + " - " + str.tostring(tp10_s)
+ "\n\nSL: wait for opposite signal "

buy_comment = "Buy Zone: " + str.tostring(close_price) + " - " +


str.tostring(lowentry_l) + "\n\nTarget: " + target_long_comment
sell_comment = "Sell Zone: " + str.tostring(close_price) + " - " +
str.tostring(lowentry_s) + "\n\nTarget: " + target_short_comment

indL = "#XAUSCALP\nScalp Long 🟢\n➖➖➖➖➖\n#FOREX • Crypto Queen 👑\nTimeframe " +


timeframe.period + "\nLot 0.01\n➖➖➖➖➖"
indS = "#XAUSCALP\nScalp Short 🔴\n➖➖➖➖➖\n#FOREX • Crypto Queen 👑\nTimeframe " +
timeframe.period + "\nLot 0.01\n➖➖➖➖➖"

if buySignalk
label.new(bar_index, low, text=indL+"\n"+buy_comment, yloc=yloc.belowbar,
color=color.green, style=label.style_label_up, size=size.small,
textcolor=color.white, textalign=text.align_left)
alert(indL+"\n"+buy_comment, alert.freq_once_per_bar_close)
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit 1", from_entry="Buy", limit=tp1_l, stop=sl_l)
strategy.exit("Take Profit 2", from_entry="Buy", limit=tp2_l, stop=sl_l)
strategy.exit("Take Profit 3", from_entry="Buy", limit=tp3_l, stop=sl_l)
strategy.exit("Take Profit 4", from_entry="Buy", limit=tp4_l, stop=sl_l)
strategy.exit("Take Profit 5", from_entry="Buy", limit=tp5_l, stop=sl_l)
strategy.exit("Take Profit 6", from_entry="Buy", limit=tp6_l, stop=sl_l)
strategy.exit("Take Profit 7", from_entry="Buy", limit=tp7_l, stop=sl_l)
strategy.exit("Take Profit 8", from_entry="Buy", limit=tp8_l, stop=sl_l)
strategy.exit("Take Profit 9", from_entry="Buy", limit=tp9_l, stop=sl_l)
strategy.exit("Take Profit 10", from_entry="Buy", limit=tp10_l, stop=sl_l)

if sellSignallk
label.new(bar_index, high, text=indS+"\n"+sell_comment, yloc=yloc.abovebar,
color=color.red, style=label.style_label_down, size=size.small,
textcolor=color.white, textalign=text.align_left)
alert(indS+"\n"+sell_comment, alert.freq_once_per_bar_close)
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit 1", from_entry="Sell", limit=tp1_s, stop=sl_s)
strategy.exit("Take Profit 2", from_entry="Sell", limit=tp2_s, stop=sl_s)
strategy.exit("Take Profit 3", from_entry="Sell", limit=tp3_s, stop=sl_s)
strategy.exit("Take Profit 4", from_entry="Sell", limit=tp4_s, stop=sl_s)
strategy.exit("Take Profit 5", from_entry="Sell", limit=tp5_s, stop=sl_s)
strategy.exit("Take Profit 6", from_entry="Sell", limit=tp6_s, stop=sl_s)
strategy.exit("Take Profit 7", from_entry="Sell", limit=tp7_s, stop=sl_s)
strategy.exit("Take Profit 8", from_entry="Sell", limit=tp8_s, stop=sl_s)
strategy.exit("Take Profit 9", from_entry="Sell", limit=tp9_s, stop=sl_s)
strategy.exit("Take Profit 10", from_entry="Sell", limit=tp10_s, stop=sl_s)

// Alert conditions for each TP hit using closed trades


var float exit_price = na
if (strategy.closedtrades > 0)
exit_price := strategy.closedtrades.exit_price(strategy.closedtrades - 1)
if (exit_price == tp1_l or exit_price == tp2_l or exit_price == tp3_l or
exit_price == tp4_l or exit_price == tp5_l or exit_price == tp6_l or exit_price ==
tp7_l or exit_price == tp8_l or exit_price == tp9_l or exit_price == tp10_l)
alert("Take Profit level hit: " + str.tostring(exit_price),
alert.freq_once_per_bar)
if (exit_price == tp1_s or exit_price == tp2_s or exit_price == tp3_s or
exit_price == tp4_s or exit_price == tp5_s or exit_price == tp6_s or exit_price ==
tp7_s or exit_price == tp8_s or exit_price == tp9_s or exit_price == tp10_s)
alert("Take Profit level hit: " + str.tostring(exit_price),
alert.freq_once_per_bar)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy