Closed

Hi I'm looking for a study to be written on pine script with a few variables, long alert, short alert, and adjustable take profit percentage

I have already got my basic strategy I just wanted a variable take profit alert

So if its a buy signal the TP will be.. close[1]- open[1]/100*to inputval

But if it a short signal TP will be for short signal only

I have some of the code written my self I just a bit stuck with my take profit alert

//@version=4

study("PixMix", overlay=true)

//////////////////////////////////////

// Example buy and sell strategy

//////////////////////////////////////

source = input(close)

slowLength = input(20, "fast", minval=2,step=1)

fastLength = input(50, "slow", minval=2,step=1)

// Calculate moving averages

fastSMA = sma(source, slowLength)

slowSMA = sma(source, fastLength)

// Calculate trading conditions

buy = close<open

sell = close>open

plotshape(buy, "buy", [login to view URL], [login to view URL], [login to view URL], text="buy", textcolor=[login to view URL], editable=false)

plotshape(sell, "sell", [login to view URL], [login to view URL], [login to view URL], text="sell", textcolor=[login to view URL], editable=false)

//////////////////////////////////////

// Take profit

//////////////////////////////////////

use_tp = input(true, "Take Profit?")

tp_trigger = input(25, "Take profit %", minval=0, step=0.1, type=[login to view URL]) * 0.01

ttp_trigger = input(2, "Trailing Take Profit %", minval=0, step=0.1, type=[login to view URL]) * 0.01

// trend states

since_buy = barssince(buy)

since_sell = barssince(sell)

buy_trend = since_sell > since_buy

sell_trend = since_sell < since_buy

change_trend = (buy_trend and sell_trend[1]) or (sell_trend and buy_trend[1])

// get the entry price

entry_price = valuewhen(buy or sell, source, 0)

// is take profit triggered?

var tp_price_trigger = -0.0

var is_tp_trigger_hit = false

var tp_trail = 0.0

tp_close_long = false

tp_close_short = false

if use_tp

// If the trend changed, then reset the trigger

if change_trend

// calculate take profit trigger value

tp_price_trigger := close[1]-open[1]/100*tp_trigger

is_tp_trigger_hit := false

// tp_close_long := false

// tp_close_short := false

if buy[1]

// Is the take profit long price trigger hit?

is_tp_trigger_hit := (high >= tp_price_trigger) or (not change_trend and is_tp_trigger_hit[1])

// calculate take profit long trail

tp_trail := max(high, change_trend ? tp_price_trigger : tp_trail[1])

tp_close_long := (is_tp_trigger_hit and (high <= tp_trail * (1.0 - ttp_trigger))) or (not change_trend and tp_close_long[1])

else if sell[1]

// Is the take profit short price trigger hit?

is_tp_trigger_hit := (low >= tp_price_trigger) or (not change_trend and is_tp_trigger_hit[1])

// calculate take profit short trail

tp_trail := min(low, change_trend ? tp_price_trigger : tp_trail[1])

tp_close_short := (is_tp_trigger_hit and (low >= tp_trail * (1.0 + ttp_trigger))) or (not change_trend and tp_close_short[1])

/ display take profit trigger

plot(use_tp and tp_price_trigger != -1.0 ? tp_price_trigger : na,

title='Take Profit Price Trigger', color=[login to view URL],

style=plot.style_cross, linewidth=3)

plotshape(tp_close_long and not tp_close_long[1], "L/EX", [login to view URL],

[login to view URL], [login to view URL], text="L/EX", textcolor=[login to view URL], editable=true)

plotshape(tp_close_short and not tp_close_short[1], "S/EX", [login to view URL],

[login to view URL], [login to view URL], text="S/EX", textcolor=[login to view URL], editable=true)

alertcondition(condition = close<open, title = 'buy', message = ' - long')

alertcondition(condition = close>open, title = 'sell', message = ' - sell')

//take profit allert

alertcondition(condition = close[1]-open[1]/100*tp_trigger, title = 'Take profit buy', message = ' - take profitbuy')

Skills: Metatrader, JavaScript, Software Architecture, Trading, MQL4

See more: i`m looking designer, i`m looking php script rent villa, hi i am looking for someone to craft our pdf documents in word we will send you 200 k version of documents hi i am looking for s, i m looking for a artist, i m looking for a bookkeeper for my small company, i m looking for a cloud software developer, i m looking for a computer coder, i m looking for a content editor, i m looking for a developer startup, i m looking for a dress designers list, i m looking for a excel teacher, i m looking for a gasmask designer, i m looking for a good autocad student, i m looking for a grant writer in nj, i m looking for a graphic designer in the inland empire, i m looking for a graphic designer, i m looking for a manufacturing technician, Hi! I\ m looking someone who can gather inf, Hi, I\ m looking for someone who can draw something similar to the image attached. In the image there\ s an astronaut drawn o

About the Employer:
( 0 reviews ) Lagos, Nigeria

Project ID: #31759713

2 freelancers are bidding on average $83 for this job

phils2900

i am interested in your MetaTrader , Tradingview project and i have read the project details. I am an experienced financial software developer that help you resolve your problem. Lets discuss more on details. Your p More

$155 USD in 1 day
(4 Reviews)
2.4
yashkumar2104

If you are looking to develop website with a captivating design to strengthen your business or to enlarge your market through web server then you are on the right place. I give webpage design and development administr More

$10 USD in 1 day
(3 Reviews)
1.4