Mascapitalllctrader
New member
Here is my code currently when long or short entry im having to wait for exit or stop to plot once either is hit. Is there a way to plot points as soon as entryt is taken to see where the proit target is and the stop target is. Thank in advance.
Plot user input target lines.
Code:
# Long
AddOrder(tickcolor = Color.GREEN, arrowcolor = Color.RED, name = "long", tradeSize = contracts, condition = condition, type = OrderType.BUY_to_open);
# Profit
def target = EntryPrice() + ATR() * profit_mult;
AddOrder(type = OrderType.SELL_to_close, high[-1] >= target, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Target", price = target);
# Trailing stop
def stop = EntryPrice() - ATR() * stop_mult;
AddOrder(OrderType.SELL_to_close, low[-1] <= stop, tickcolor = Color.GRAY, arrowcolor = Color.GRAY, name = "Stop", tradeSize = contracts, price = stop);
Plot user input target lines.
Code:
# TARGETS
# DREWGRIFFITH15 (C) 2015
INPUT AGGREGATIONPERIOD = AGGREGATIONPERIOD.DAY;
INPUT TARGET_ONE = 250;
INPUT TARGET_TWO = 20;
INPUT TARGET_THR = 252;
INPUT DISPLACE = -1;
INPUT SHOWONLYLASTPERIOD = YES;
# PLOT HIGH TARGETS
PLOT HIGH_ONE;
IF SHOWONLYLASTPERIOD AND !ISNAN(HIGH(PERIOD = AGGREGATIONPERIOD)[-1]) { HIGH_ONE = DOUBLE.NAN;
} ELSE { HIGH_ONE = HIGHEST(HIGH(PERIOD = AGGREGATIONPERIOD)[-DISPLACE], TARGET_ONE);
}
PLOT HIGH_TWO;
IF SHOWONLYLASTPERIOD AND !ISNAN(HIGH(PERIOD = AGGREGATIONPERIOD)[-1]) { HIGH_TWO = DOUBLE.NAN;
} ELSE { HIGH_TWO = HIGHEST(HIGH(PERIOD = AGGREGATIONPERIOD)[-DISPLACE], TARGET_TWO);
}
PLOT HIGH_THR;
IF SHOWONLYLASTPERIOD AND !ISNAN(HIGH(PERIOD = AGGREGATIONPERIOD)[-1]) { HIGH_THR = DOUBLE.NAN;
} ELSE { HIGH_THR = HIGHEST(HIGH(PERIOD = AGGREGATIONPERIOD)[-DISPLACE], TARGET_THR);
}
# PLOT LOW TARGETS
PLOT LOW_ONE;
IF SHOWONLYLASTPERIOD AND !ISNAN(LOW(PERIOD = AGGREGATIONPERIOD)[-1]) { LOW_ONE = DOUBLE.NAN;
} ELSE { LOW_ONE = LOWEST(LOW(PERIOD = AGGREGATIONPERIOD)[-DISPLACE], TARGET_ONE);
}
PLOT LOW_TWO;
IF SHOWONLYLASTPERIOD AND !ISNAN(LOW(PERIOD = AGGREGATIONPERIOD)[-1]) { LOW_TWO = DOUBLE.NAN;
} ELSE { LOW_TWO = LOWEST(LOW(PERIOD = AGGREGATIONPERIOD)[-DISPLACE], TARGET_TWO);
}
PLOT LOW_THR;
IF SHOWONLYLASTPERIOD AND !ISNAN(LOW(PERIOD = AGGREGATIONPERIOD)[-1]) { LOW_THR = DOUBLE.NAN;
} ELSE { LOW_THR = LOWEST(LOW(PERIOD = AGGREGATIONPERIOD)[-DISPLACE], TARGET_THR);
}
HIGH_ONE.SETDEFAULTCOLOR(CREATECOLOR(255, 0, 0));
HIGH_ONE.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.POINTS);
HIGH_TWO.SETDEFAULTCOLOR(CREATECOLOR(255, 255, 0));
HIGH_TWO.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.POINTS);
HIGH_THR.SETDEFAULTCOLOR(CREATECOLOR(255, 255, 255));
HIGH_THR.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.POINTS);
LOW_ONE.SETDEFAULTCOLOR(CREATECOLOR(0, 255, 0));
LOW_ONE.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.POINTS);
LOW_TWO.SETDEFAULTCOLOR(CREATECOLOR(255, 255, 0));
LOW_TWO.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.POINTS);
LOW_THR.SETDEFAULTCOLOR(CREATECOLOR(255, 255, 255));
LOW_THR.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.POINTS);
##############################################
Last edited by a moderator: