I have been working on this for days, I keep trying to adjust this but cant figure it out.
I love this study but would like to base entry on ema crossing and the stop and take profit on actual movement of the stock price.
Stop at -1 points from purchase and close at +2 points, something like that.
My strategy is simple, 5 crosses 50 ema, after candle close, trade box appears with my stop and my target. I close all but small amount at +10% or +20% but its options so I calculate how far it moves based on delta to come up with stock movement to = the %. I use this to help review trades and good visual when in a trade.
this script works perfect but I cant figure out how to get rid of ATR and just use actual stop loss based on the same price movement each time that I set.
here is a picture and script im' currently using that I would like to remove the ATR part.
Thank you for looking at it, hopefully its a easy fix.
#
# Trade Lines
# v1.0 by @mark.917
#
# Trade Lines will plot lines with and optional cloud showing where you entered your
# position and the location of your stop loss and profit target.
#
# To use, your code will need to set "your_buy_signal" or "your_sell_signal" to true.
# The profit target and stop loss are based on an ATR multplier. You may modify this
# to be whatever you would like.
declare upper;
#######################
# YOUR CODE STARTS HERE
#######################
# sample using moving average crossover for signals
plot FastMA = MovingAverage(AverageType.EXPONENTIAL, close, 5);
plot SlowMA = MovingAverage(AverageType.EXPONENTIAL, close, 50);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));
def buy_signal = FastMA crosses above SlowMA;
def sell_signal = FastMA crosses below SlowMA;
###################
# BEGIN TRADE LINES
###################
input show_trade_zone = yes;
input calc_mode = {default atr, fixed}; #hint mode: Select fixed values or atr values for target and stop levels.
input ATRTargetMultiple = 2.5;
input ATRStopMultiple = 1.5;
input FixedTarget = 1.50;
input FixedStop = .75;
def atr = ATR(14, averageType.EXPONENTIAL);
def long_signal = if buy_signal then 1 else 0;
def long_target = if long_signal == 1 then atr * ATRTargetMultiple else long_target[1];
def long_stop = if long_signal == 1 then atr * ATRStopMultiple else long_stop[1];
def long_entry = if long_signal == 1 then open else if (high[1] > long_entry[1] + long_target or low[1] < long_entry[1] - long_stop) then Double.NaN else long_entry[1];
def long_exit = if long_entry > 0 then 0 else 1;
plot long_pt = if show_trade_zone and !long_exit then long_entry + long_target else Double.NaN;
long_pt.SetDefaultColor(Color.GREEN);
plot long_ep = if show_trade_zone and !long_exit then long_entry else Double.NaN;
long_ep.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
long_ep.SetPaintingStrategy(PaintingStrategy.DASHES);
long_ep.SetDefaultColor(Color.WHITE);
plot long_sl = if show_trade_zone and !long_exit then long_ep - long_stop else Double.NaN;
long_sl.SetDefaultColor(Color.RED);
AddCloud(if show_trade_zone then long_pt else Double.NaN, long_ep, Color.GREEN);
AddCloud(if show_trade_zone then long_sl else Double.NaN, long_ep, Color.RED);
def short_signal = if sell_signal then 1 else 0;
def short_target = if short_signal == 1 then atr * ATRTargetMultiple else short_target[1];
def short_stop = if short_signal == 1 then atr * ATRStopMultiple else short_stop[1];
def short_entry = if short_signal == 1 then open else if (low[1] < short_entry[1] - short_target or high[1] > short_entry[1] + short_stop) then Double.NaN else short_entry[1];
def short_exit = if short_entry > 0 then 0 else 1;
plot short_pt = if show_trade_zone and !short_exit then short_entry - short_target else Double.NaN;
short_pt.SetDefaultColor(Color.GREEN);
plot short_ep = if show_trade_zone and !short_exit then short_entry else Double.NaN;
short_ep.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
short_ep.SetPaintingStrategy(PaintingStrategy.DASHES);
short_ep.SetDefaultColor(Color.WHITE);
plot short_sl = if show_trade_zone and !short_exit then short_ep + short_stop else Double.NaN;
short_sl.SetDefaultColor(Color.RED);
AddCloud(if show_trade_zone then short_ep else Double.NaN, short_pt, Color.GREEN);
AddCloud(if show_trade_zone then short_sl else Double.NaN, short_ep, Color.RED);
#################
# END TRADE LINES
#################
AddOrder(OrderType.BUY_AUTO, fastMA crosses above slowMA[1]);
AddOrder(OrderType.Sell_AUTO, fastMA crosses below slowMA[1]);
I love this study but would like to base entry on ema crossing and the stop and take profit on actual movement of the stock price.
Stop at -1 points from purchase and close at +2 points, something like that.
My strategy is simple, 5 crosses 50 ema, after candle close, trade box appears with my stop and my target. I close all but small amount at +10% or +20% but its options so I calculate how far it moves based on delta to come up with stock movement to = the %. I use this to help review trades and good visual when in a trade.
this script works perfect but I cant figure out how to get rid of ATR and just use actual stop loss based on the same price movement each time that I set.
here is a picture and script im' currently using that I would like to remove the ATR part.
Thank you for looking at it, hopefully its a easy fix.
#
# Trade Lines
# v1.0 by @mark.917
#
# Trade Lines will plot lines with and optional cloud showing where you entered your
# position and the location of your stop loss and profit target.
#
# To use, your code will need to set "your_buy_signal" or "your_sell_signal" to true.
# The profit target and stop loss are based on an ATR multplier. You may modify this
# to be whatever you would like.
declare upper;
#######################
# YOUR CODE STARTS HERE
#######################
# sample using moving average crossover for signals
plot FastMA = MovingAverage(AverageType.EXPONENTIAL, close, 5);
plot SlowMA = MovingAverage(AverageType.EXPONENTIAL, close, 50);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));
def buy_signal = FastMA crosses above SlowMA;
def sell_signal = FastMA crosses below SlowMA;
###################
# BEGIN TRADE LINES
###################
input show_trade_zone = yes;
input calc_mode = {default atr, fixed}; #hint mode: Select fixed values or atr values for target and stop levels.
input ATRTargetMultiple = 2.5;
input ATRStopMultiple = 1.5;
input FixedTarget = 1.50;
input FixedStop = .75;
def atr = ATR(14, averageType.EXPONENTIAL);
def long_signal = if buy_signal then 1 else 0;
def long_target = if long_signal == 1 then atr * ATRTargetMultiple else long_target[1];
def long_stop = if long_signal == 1 then atr * ATRStopMultiple else long_stop[1];
def long_entry = if long_signal == 1 then open else if (high[1] > long_entry[1] + long_target or low[1] < long_entry[1] - long_stop) then Double.NaN else long_entry[1];
def long_exit = if long_entry > 0 then 0 else 1;
plot long_pt = if show_trade_zone and !long_exit then long_entry + long_target else Double.NaN;
long_pt.SetDefaultColor(Color.GREEN);
plot long_ep = if show_trade_zone and !long_exit then long_entry else Double.NaN;
long_ep.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
long_ep.SetPaintingStrategy(PaintingStrategy.DASHES);
long_ep.SetDefaultColor(Color.WHITE);
plot long_sl = if show_trade_zone and !long_exit then long_ep - long_stop else Double.NaN;
long_sl.SetDefaultColor(Color.RED);
AddCloud(if show_trade_zone then long_pt else Double.NaN, long_ep, Color.GREEN);
AddCloud(if show_trade_zone then long_sl else Double.NaN, long_ep, Color.RED);
def short_signal = if sell_signal then 1 else 0;
def short_target = if short_signal == 1 then atr * ATRTargetMultiple else short_target[1];
def short_stop = if short_signal == 1 then atr * ATRStopMultiple else short_stop[1];
def short_entry = if short_signal == 1 then open else if (low[1] < short_entry[1] - short_target or high[1] > short_entry[1] + short_stop) then Double.NaN else short_entry[1];
def short_exit = if short_entry > 0 then 0 else 1;
plot short_pt = if show_trade_zone and !short_exit then short_entry - short_target else Double.NaN;
short_pt.SetDefaultColor(Color.GREEN);
plot short_ep = if show_trade_zone and !short_exit then short_entry else Double.NaN;
short_ep.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
short_ep.SetPaintingStrategy(PaintingStrategy.DASHES);
short_ep.SetDefaultColor(Color.WHITE);
plot short_sl = if show_trade_zone and !short_exit then short_ep + short_stop else Double.NaN;
short_sl.SetDefaultColor(Color.RED);
AddCloud(if show_trade_zone then short_ep else Double.NaN, short_pt, Color.GREEN);
AddCloud(if show_trade_zone then short_sl else Double.NaN, short_ep, Color.RED);
#################
# END TRADE LINES
#################
AddOrder(OrderType.BUY_AUTO, fastMA crosses above slowMA[1]);
AddOrder(OrderType.Sell_AUTO, fastMA crosses below slowMA[1]);