Yes, as the strategies are all there. Getting slippage and stop loss getting jumped over are all things that unfortunately happen. Small trades dont suffer from it, larger positions do. The on demand is useless as I can in any single night make tens thousands there. I played around with that with actual funds I have in my trading accounts and its simply not accurate. Its good to practice and getting familiar with platform. Well at least thats all I got out of it. The executions are instant zero slippage and lets not forget the emotions.Seriously? You are trading with real money using a system you don't know how to use yet and lose 2,600, and the very next day you are still trading with real money? WTF?
@mrwind425 The shaded clouds does not work on the mobile app. You will only see the lines.
# Original Code From: TD Ameritrade IP Company, Inc. (c) 2009-2020
# Original StudyName: ATRTrailingStop
# Type: Study
# blackFLAG FTS SwingArms
# StudyName: blackFLAG_Futures_SwingArm_ATRTrail
# My preferred setting is 28 / 5 FOR ALL TIMEFRAMES
# Edited by: Jose Azcarate
# blackFLAG Futures Trading - FOR EDUCATIONAL PURPOSES ONLY
# TWITTER: @blackflagfuture
# UPDATED: 5/16/2020
# MODIFIED: 6/11/20 - allows defining the period you want the swingarm to draw - This is an add-on to be used with the main SwingArm Script, all alters have been removed.
# NOTE: WHEN IMPORTING STUDY, MAKE SURE YOU UPDATE THE LOOK AND FEEL TO MATCH MY CHARTS WITHIN THE STUDY SETTINGS.
#-----------------------------------
#Modified 6/29/2020 by Henry Z Kaczmarczyk added upper fib zones, added upper clouds, fixed labels
#-----------------------------------
# BUY & SELL ALERTS ARE CREATED BY THE HULL MOVING AVERAGE TURNING POINTS STUDY AND MUST BE IN AGREEMENT WITH SWINGARM SUPPORT OR RESISTANCE ZONES TO BE VALID. (UseThinkScript.com by mashume - Upper Study). MY UPDATED CODE INCLUDES THE BUY / SELL BUBBLES. THE SETTINGS ARE: 1 MIN: 255 PERIOD; 5 MIN: 255 PERIOD; 4 HOUR 255 PERIOD.
#-----------------------------------
#-----------------------------------
input aggregationPeriod = AggregationPeriod.MIN;
input trailType = {default modified, unmodified};
input ATRPeriod = 28;
input ATRFactor = 5;
input firstTrade = {default long, short};
input averageType = AverageType.WILDERS;
Input fib0Level = 0;
Input fib1Level = 11.4;
input fib2Level = 23.6;
input fib3Level = 38.2;
Input fib4Level = 50.0;
input fib5Level = 61.8;
input fib6Level = 78.6;
input fib7Level = 88.6;
Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);
def open = Open(Period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
def close = close(period = aggregationPeriod);
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
def HRef = if low <= high[1]
then high - close[1]
else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
then close[1] - low
else (close[1] - low) - 0.5 * (low[1] - high);
def trueRange;
switch (trailType) {
case modified:
trueRange = Max(HiLo, Max(HRef, LRef));
case unmodified:
trueRange = TrueRange(high, close, low);
}
def loss = ATRFactor * MovingAverage(averageType, trueRange, ATRPeriod);
def state = {default init, long, short};
def trail;
switch (state[1]) {
case init:
if (!IsNaN(loss)) {
switch (firstTrade) {
case long:
state = state.long;
trail = close - loss;
case short:
state = state.short;
trail = close + loss;
}
} else {
state = state.init;
trail = Double.NaN;
}
case long:
if (close > trail[1]) {
state = state.long;
trail = Max(trail[1], close - loss);
} else {
state = state.short;
trail = close + loss;
}
case short:
if (close < trail[1]) {
state = state.short;
trail = Min(trail[1], close + loss);
} else {
state = state.long;
trail = close - loss;
}
}
def BuySignal = Crosses(state == state.long, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(state == state.short, 0, CrossingDirection.ABOVE);
def ex = if BuySignal then high else if SellSignal then low else if state == state.long then Max(ex[1], high) else if state == state.short then Min(ex[1], low) else ex[1];
plot TrailingStop = trail;
TrailingStop.SetPaintingStrategy(PaintingStrategy.POINTS);
TrailingStop.DefineColor("Long", Color.GREEN);
TrailingStop.DefineColor("Short", Color.RED);
TrailingStop.SetLineWeight(5);
TrailingStop.AssignValueColor(if state == state.long
then TrailingStop.Color("Long")
else TrailingStop.Color("Short"));
#TrailingStop.hide();
plot Extremum = ex;
Extremum.SetPaintingStrategy(PaintingStrategy.POINTS);
Extremum.DefineColor("HH", Color.GREEN);
Extremum.DefineColor("LL", Color.RED);
Extremum.AssignValueColor(if state == state.long
then Extremum.Color("HH")
else Extremum.Color("LL"));
Extremum.Hide();
def f0 = ex + (trail - ex) * fib0Level / 100;
def f1 = ex + (trail - ex) * fib1Level / 100;
def f2 = ex + (trail - ex) * fib2Level / 100;
def f3 = ex + (trail - ex) * fib3Level / 100;
def f4 = ex + (trail - ex) * fib4Level / 100;
def f5 = ex + (trail - ex) * fib5Level / 100;
def f6 = ex + (trail - ex) * fib6Level / 100;
def f7 = ex + (trail - ex) * fib7Level / 100;
def l100 = trail + 0;
plot Fib0 = f0;
Fib0.SetPaintingStrategy(PaintingStrategy.LINE);
Fib0.SetDefaultColor(Color.White);
Fib0.SetLineWeight(2);
plot Fib1 = f1;
Fib1.SetPaintingStrategy(PaintingStrategy.LINE);
Fib1.SetDefaultColor(Color.White);
Fib1.SetLineWeight(2);
plot Fib2 = f2;
Fib2.SetPaintingStrategy(PaintingStrategy.Line);
Fib2.SetDefaultColor(Color.White);
plot Fib3 = f3;
Fib3.SetPaintingStrategy(PaintingStrategy.Line);
Fib3.SetDefaultColor(Color.White);
Fib3.SetLineWeight(1);
plot Fib4 = f4;
Fib4.SetPaintingStrategy(PaintingStrategy.LINE);
Fib4.SetDefaultColor(Color.White);
Fib4.SetLineWeight(1);
plot Fib5 = f5;
Fib5.SetPaintingStrategy(PaintingStrategy.LINE);
Fib5.SetDefaultColor(Color.White);
Fib5.SetLineWeight(1);
plot Fib6 = f6;
Fib6.SetPaintingStrategy(PaintingStrategy.Line);
Fib6.SetDefaultColor(Color.White);
Fib6.SetLineWeight(2);
plot Fib7 = f7;
Fib7.SetPaintingStrategy(PaintingStrategy.Line);
Fib7.SetDefaultColor(Color.White);
Fib7.SetLineWeight(2);
AddCloud(f0, f1, Color.dark_Red, Color.Dark_Green, no);
AddCloud(f1, f2, Color.Red, Color.Green, no);
AddCloud(f2, f3, Color.Light_Red, Color.Light_Green, no);
AddCloud(f5, f6, Color.LIGHT_GREEN, Color.LIGHT_RED, no);
AddCloud(f6, f7, Color.GREEN, Color.RED, no);
AddCloud(f7, l100, Color.DARK_GREEN, Color.DARK_RED, no);
def l5 = state[1] == state.long and close crosses below f5[1];
def l6 = state[1] == state.long and close crosses below f6[1];
def l7 = state[1] == state.long and close crosses below f7[1];
def s5 = state[1] == state.short and close crosses above f5[1];
def s6 = state[1] == state.short and close crosses above f6[1];
def s7 = state[1] == state.short and close crosses above f7[1];
def atr = Average(TrueRange(high, close, low), 14);
plot LS1 = if l5 then low - atr else Double.NaN;
plot LS2 = if l6 then low - 1.5 * atr else Double.NaN;
plot LS3 = if l7 then low - 2 * atr else Double.NaN;
plot SS1 = if s5 then high + atr else Double.NaN;
plot SS2 = if s6 then high + 1.5 * atr else Double.NaN;
plot SS3 = if s7 then high + 2 * atr else Double.NaN;
LS1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS1.SetDefaultColor(Color.GREEN);
LS1.SetLineWeight(1);
LS1.Hide();
LS2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS2.SetDefaultColor(Color.GREEN);
LS2.SetLineWeight(1);
LS2.Hide();
LS3.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS3.SetDefaultColor(Color.GREEN);
LS3.SetLineWeight(1);
LS3.Hide();
SS1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS1.SetDefaultColor(Color.RED);
SS1.SetLineWeight(1);
SS1.Hide();
SS2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS2.SetDefaultColor(Color.RED);
SS2.SetLineWeight(1);
SS2.Hide();
SS3.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS3.SetDefaultColor(Color.RED);
SS3.SetLineWeight(1);
SS3.Hide();
#Alert(l1, "Price crossed below Fib5 level in long trend", Alert.BAR, Sound.Bell);
#Alert(l2, "Price crossed below Fib6 level in long trend", Alert.BAR, Sound.Bell);
#Alert(l3, "Price crossed below Fib7 level in long trend", Alert.BAR, Sound.Bell);
#Alert(s1, "Price crossed above Fib5 level in short trend", Alert.BAR, Sound.Bell);
#Alert(s2, "Price crossed above Fib6 level in short trend", Alert.BAR, Sound.Bell);
#Alert(s3, "Price crossed above Fib7 level in short trend", Alert.BAR, Sound.Bell);
# *******************************************************
# DAY TRADING SETTINGS USING 1 AND 5 MINUTE CHARTS
AddLabel(yes, "Alt SA Period: " + aggregationPeriod/60000 +"m",color.WHITE);
AddLabel(yes, if ohlc4 > TrailingStop then "BUY SUPPORT - BUY ZONES 2,3 or 4" else "SELL RESISTANCE - SELL ZONES 2,3 or 4", if ohlc4 > TrailingStop then Color.GREEN else Color.Red);
AddLabel(yes," SWING TRADING STRATEGY : ",color.WHITE);
AddLabel(yes, if ohlc4 > TrailingStop then "* IF * SWINGARM Is BULLISH - Wait For Entry Confirmation" else "* IF * SWINGARM - Is BEARISH - Wait For Entry Confirmation", if ohlc4 > TrailingStop then Color.GREEN else Color.RED);
# Original Code From: TD Ameritrade IP Company, Inc. (c) 2009-2020
# Original StudyName: ATRTrailingStop
# Type: Study
# blackFLAG FTS SwingArms
# StudyName: blackFLAG_Futures_SwingArm_ATRTrail
# My preferred setting is 28 / 5 FOR ALL TIMEFRAMES
# Edited by: Jose Azcarate
# blackFLAG Futures Trading - FOR EDUCATIONAL PURPOSES ONLY
# TWITTER: @blackflagfuture
# UPDATED: 5/16/2020
# NOTE: WHEN IMPORTING STUDY, MAKE SURE YOU UPDATE THE LOOK AND FEEL TO MATCH MY CHARTS WITHIN THE STUDY SETTINGS.
#-----------------------------------
#-----------------------------------
# BUY & SELL ALERTS ARE CREATED BY THE HULL MOVING AVERAGE TURNING POINTS STUDY AND MUST BE IN AGREEMENT WITH SWINGARM SUPPORT OR RESISTANCE ZONES TO BE VALID. (UseThinkScript.com by mashume - Upper Study). MY UPDATED CODE INCLUDES THE BUY / SELL BUBBLES. THE SETTINGS ARE: 1 MIN: 255 PERIOD; 5 MIN: 255 PERIOD; 4 HOUR 255 PERIOD.
#-----------------------------------
#-----------------------------------
input trailType = {default modified, unmodified};
input ATRPeriod = 28;
input ATRFactor = 5;
input firstTrade = {default long, short};
input averageType = AverageType.WILDERS;
Input fib0Level = 0;
Input fib1Level = 11.4;
input fib2Level = 23.6;
input fib3Level = 38.2;
Input fib4Level = 50.0;
input fib5Level = 61.8;
input fib6Level = 78.6;
input fib7Level = 88.6;
Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
def HRef = if low <= high[1]
then high - close[1]
else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
then close[1] - low
else (close[1] - low) - 0.5 * (low[1] - high);
def trueRange;
switch (trailType) {
case modified:
trueRange = Max(HiLo, Max(HRef, LRef));
case unmodified:
trueRange = TrueRange(high, close, low);
}
def loss = ATRFactor * MovingAverage(averageType, trueRange, ATRPeriod);
def state = {default init, long, short};
def trail;
switch (state[1]) {
case init:
if (!IsNaN(loss)) {
switch (firstTrade) {
case long:
state = state.long;
trail = close - loss;
case short:
state = state.short;
trail = close + loss;
}
} else {
state = state.init;
trail = Double.NaN;
}
case long:
if (close > trail[1]) {
state = state.long;
trail = Max(trail[1], close - loss);
} else {
state = state.short;
trail = close + loss;
}
case short:
if (close < trail[1]) {
state = state.short;
trail = Min(trail[1], close + loss);
} else {
state = state.long;
trail = close - loss;
}
}
def BuySignal = Crosses(state == state.long, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(state == state.short, 0, CrossingDirection.ABOVE);
def ex = if BuySignal then high else if SellSignal then low else if state == state.long then Max(ex[1], high) else if state == state.short then Min(ex[1], low) else ex[1];
plot TrailingStop = trail;
TrailingStop.SetPaintingStrategy(PaintingStrategy.POINTS);
TrailingStop.DefineColor("Long", Color.GREEN);
TrailingStop.DefineColor("Short", Color.RED);
TrailingStop.AssignValueColor(if state == state.long
then TrailingStop.Color("Long")
else TrailingStop.Color("Short"));
plot Extremum = ex;
Extremum.SetPaintingStrategy(PaintingStrategy.POINTS);
Extremum.DefineColor("HH", Color.GREEN);
Extremum.DefineColor("LL", Color.RED);
Extremum.AssignValueColor(if state == state.long
then Extremum.Color("HH")
else Extremum.Color("LL"));
Extremum.Hide();
def f0 = ex + (trail - ex) * fib0Level / 100;
def f1 = ex + (trail - ex) * fib1Level / 100;
def f2 = ex + (trail - ex) * fib2Level / 100;
def f3 = ex + (trail - ex) * fib3Level / 100;
def f4 = ex + (trail - ex) * fib4Level / 100;
def f5 = ex + (trail - ex) * fib5Level / 100;
def f6 = ex + (trail - ex) * fib6Level / 100;
def f7 = ex + (trail - ex) * fib7Level / 100;
def l100 = trail + 0;
plot Fib0 = f0;
Fib0.SetPaintingStrategy(PaintingStrategy.LINE);
Fib0.SetDefaultColor(Color.White);
Fib0.SetLineWeight(2);
plot Fib1 = f1;
Fib1.SetPaintingStrategy(PaintingStrategy.LINE);
Fib1.SetDefaultColor(Color.White);
Fib1.SetLineWeight(2);
plot Fib2 = f2;
Fib2.SetPaintingStrategy(PaintingStrategy.Line);
Fib2.SetDefaultColor(Color.White);
plot Fib3 = f3;
Fib3.SetPaintingStrategy(PaintingStrategy.Line);
Fib3.SetDefaultColor(Color.White);
Fib3.SetLineWeight(1);
plot Fib4 = f4;
Fib4.SetPaintingStrategy(PaintingStrategy.LINE);
Fib4.SetDefaultColor(Color.White);
Fib4.SetLineWeight(1);
plot Fib5 = f5;
Fib5.SetPaintingStrategy(PaintingStrategy.LINE);
Fib5.SetDefaultColor(Color.White);
Fib5.SetLineWeight(1);
plot Fib6 = f6;
Fib6.SetPaintingStrategy(PaintingStrategy.Line);
Fib6.SetDefaultColor(Color.White);
Fib6.SetLineWeight(2);
plot Fib7 = f7;
Fib7.SetPaintingStrategy(PaintingStrategy.Line);
Fib7.SetDefaultColor(Color.White);
Fib7.SetLineWeight(2);
AddCloud(f0, f1, Color.dark_Red, Color.Dark_Green, no);
AddCloud(f1, f2, Color.Red, Color.Green, no);
AddCloud(f2, f3, Color.Light_Red, Color.Light_Green, no);
AddCloud(f5, f6, Color.LIGHT_GREEN, Color.LIGHT_RED, no);
AddCloud(f6, f7, Color.GREEN, Color.RED, no);
AddCloud(f7, l100, Color.DARK_GREEN, Color.DARK_RED, no);
def l5 = state[1] == state.long and close crosses below f5[1];
def l6 = state[1] == state.long and close crosses below f6[1];
def l7 = state[1] == state.long and close crosses below f7[1];
def s5 = state[1] == state.short and close crosses above f5[1];
def s6 = state[1] == state.short and close crosses above f6[1];
def s7 = state[1] == state.short and close crosses above f7[1];
def atr = Average(TrueRange(high, close, low), 14);
plot LS1 = if l5 then low - atr else Double.NaN;
plot LS2 = if l6 then low - 1.5 * atr else Double.NaN;
plot LS3 = if l7 then low - 2 * atr else Double.NaN;
plot SS1 = if s5 then high + atr else Double.NaN;
plot SS2 = if s6 then high + 1.5 * atr else Double.NaN;
plot SS3 = if s7 then high + 2 * atr else Double.NaN;
LS1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS1.SetDefaultColor(Color.GREEN);
LS1.SetLineWeight(1);
LS1.Hide();
LS2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS2.SetDefaultColor(Color.GREEN);
LS2.SetLineWeight(1);
LS2.Hide();
LS3.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS3.SetDefaultColor(Color.GREEN);
LS3.SetLineWeight(1);
LS3.Hide();
SS1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS1.SetDefaultColor(Color.RED);
SS1.SetLineWeight(1);
SS1.Hide();
SS2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS2.SetDefaultColor(Color.RED);
SS2.SetLineWeight(1);
SS2.Hide();
SS3.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS3.SetDefaultColor(Color.RED);
SS3.SetLineWeight(1);
SS3.Hide();
#Alert(l1, "Price crossed below Fib5 level in long trend", Alert.BAR, Sound.Bell);
#Alert(l2, "Price crossed below Fib6 level in long trend", Alert.BAR, Sound.Bell);
#Alert(l3, "Price crossed below Fib7 level in long trend", Alert.BAR, Sound.Bell);
#Alert(s1, "Price crossed above Fib5 level in short trend", Alert.BAR, Sound.Bell);
#Alert(s2, "Price crossed above Fib6 level in short trend", Alert.BAR, Sound.Bell);
#Alert(s3, "Price crossed above Fib7 level in short trend", Alert.BAR, Sound.Bell);
# *******************************************************
# DAY TRADING SETTINGS USING 1 AND 5 MINUTE CHARTS
AddLabel(yes," DAY TRADING STRATEGY : ",color.WHITE);
AddLabel(yes, if ohlc4 > TrailingStop then "* IF * 5 Min. SWINGARM Is BULLISH - Buy 1 Min. Zone 4" else "* IF * 5 MIN. SWINGARM - Is BEARISH - Sell 1 Min Zone 4", if ohlc4 > TrailingStop then Color.GREEN else Color.Red);
AddLabel(yes, if ohlc4 > TrailingStop then "BUY SUPPORT - BUY ZONES 2,3 or 4" else "SELL RESISTANCE - SELL ZONES 2,3 or 4", if ohlc4 > TrailingStop then Color.GREEN else Color.Red);
AddLabel(yes," SWING TRADING STRATEGY : ",color.WHITE);
AddLabel(yes, if ohlc4 > TrailingStop then "* IF * SWINGARM Is BULLISH - Wait For Entry Confirmation" else "* IF * SWINGARM - Is BEARISH - Wait For Entry Confirmation", if ohlc4 > TrailingStop then Color.GREEN else Color.RED);
@BenTen Do you know who is the best to help setup on mobile? Can he send me what he has for the setup in mobile phone?
I am trying to make it look like that on "red" & "green"
@luiscervantes30 i am not able to find your previous post. Can you link it please?look at previous post I have my set up there and what im running.
Here is the modified indicator. https://tos.mx/dPB4BXN@chewie76 Very nice. Would you mind posting/sharing a link to that chart? Thanks..
# Original Code From: TD Ameritrade IP Company, Inc. (c) 2009-2020
# Original StudyName: ATRTrailingStop
# Type: Study
# blackFLAG FTS SwingArms
# StudyName: blackFLAG_Futures_SwingArm_ATRTrail
# My preferred setting is 28 / 5 FOR ALL TIMEFRAMES
# Edited by: Jose Azcarate
# blackFLAG Futures Trading - FOR EDUCATIONAL PURPOSES ONLY
# TWITTER: @blackflagfuture
# UPDATED: 5/27/2020
# Top Left Labels Wording for DayTrading
# NOTE: WHEN IMPORTING STUDY, MAKE SURE YOU UPDATE THE LOOK AND FEEL TO MATCH MY CHARTS WITHIN THE STUDY SETTINGS.
#-----------------------------------
#-----------------------------------
# BUY & SELL CONFIRMATION LABELS ARE CREATED BY THE HULL MOVING AVERAGE TURNING POINTS STUDY AND MUST BE IN AGREEMENT WITH SWINGARM SUPPORT OR RESISTANCE ZONES TO BE VALID. (UseThinkScript.com by mashume - Upper Study). MY UPDATED CODE INCLUDES THE BUY / SELL BUBBLES. THE SETTINGS ARE: 1 MIN: 255 PERIOD; 5 MIN: 255 PERIOD; 4 HOUR 255 PERIOD, DAILY 75 PERIOD. "This settings are for futures"
#-----------------------------------
#-----------------------------------
input trailType = {default modified, unmodified};
input ATRPeriod = 28;
input ATRFactor = 5;
input firstTrade = {default long, short};
input averageType = AverageType.WILDERS;
input fib1Level = 61.8;
input fib2Level = 78.6;
input fib3Level = 88.6;
Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
def HRef = if low <= high[1]
then high - close[1]
else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
then close[1] - low
else (close[1] - low) - 0.5 * (low[1] - high);
def trueRange;
switch (trailType) {
case modified:
trueRange = Max(HiLo, Max(HRef, LRef));
case unmodified:
trueRange = TrueRange(high, close, low);
}
def loss = ATRFactor * MovingAverage(averageType, trueRange, ATRPeriod);
def state = {default init, long, short};
def trail;
switch (state[1]) {
case init:
if (!IsNaN(loss)) {
switch (firstTrade) {
case long:
state = state.long;
trail = close - loss;
case short:
state = state.short;
trail = close + loss;
}
} else {
state = state.init;
trail = Double.NaN;
}
case long:
if (close > trail[1]) {
state = state.long;
trail = Max(trail[1], close - loss);
} else {
state = state.short;
trail = close + loss;
}
case short:
if (close < trail[1]) {
state = state.short;
trail = Min(trail[1], close + loss);
} else {
state = state.long;
trail = close - loss;
}
}
def BuySignal = Crosses(state == state.long, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(state == state.short, 0, CrossingDirection.ABOVE);
def ex = if BuySignal then high else if SellSignal then low else if state == state.long then Max(ex[1], high) else if state == state.short then Min(ex[1], low) else ex[1];
plot TrailingStop = trail;
TrailingStop.SetPaintingStrategy(PaintingStrategy.POINTS);
TrailingStop.DefineColor("Long", Color.GREEN);
TrailingStop.DefineColor("Short", Color.RED);
TrailingStop.AssignValueColor(if state == state.long
then TrailingStop.Color("Long")
else TrailingStop.Color("Short"));
plot Extremum = ex;
Extremum.SetPaintingStrategy(PaintingStrategy.POINTS);
Extremum.DefineColor("HH", Color.GREEN);
Extremum.DefineColor("LL", Color.RED);
Extremum.AssignValueColor(if state == state.long
then Extremum.Color("HH")
else Extremum.Color("LL"));
Extremum.Hide();
def f1 = ex + (trail - ex) * fib1Level / 100;
def f2 = ex + (trail - ex) * fib2Level / 100;
def f3 = ex + (trail - ex) * fib3Level / 100;
def l100 = trail + 0;
plot Fib1 = f1;
Fib1.SetPaintingStrategy(PaintingStrategy.POINTS);
Fib1.SetDefaultColor(Color.BLACK);
Fib1.Hide();
plot Fib2 = f2;
Fib2.SetPaintingStrategy(PaintingStrategy.POINTS);
Fib2.SetDefaultColor(Color.BLACK);
Fib2.Hide();
plot Fib3 = f3;
Fib3.SetPaintingStrategy(PaintingStrategy.POINTS);
Fib3.SetDefaultColor(Color.BLACK);
Fib3.Hide();
AddCloud(f1, f2, Color.LIGHT_GREEN, Color.LIGHT_RED, no);
AddCloud(f2, f3, Color.GREEN, Color.RED, no);
AddCloud(f3, l100, Color.DARK_GREEN, Color.DARK_RED, no);
def l1 = state[1] == state.long and close crosses below f1[1];
def l2 = state[1] == state.long and close crosses below f2[1];
def l3 = state[1] == state.long and close crosses below f3[1];
def s1 = state[1] == state.short and close crosses above f1[1];
def s2 = state[1] == state.short and close crosses above f2[1];
def s3 = state[1] == state.short and close crosses above f3[1];
def atr = Average(TrueRange(high, close, low), 14);
plot LS1 = if l1 then low - atr else Double.NaN;
plot LS2 = if l2 then low - 1.5 * atr else Double.NaN;
plot LS3 = if l3 then low - 2 * atr else Double.NaN;
plot SS1 = if s1 then high + atr else Double.NaN;
plot SS2 = if s2 then high + 1.5 * atr else Double.NaN;
plot SS3 = if s3 then high + 2 * atr else Double.NaN;
LS1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS1.SetDefaultColor(Color.GREEN);
LS1.SetLineWeight(1);
LS1.Hide();
LS2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS2.SetDefaultColor(Color.GREEN);
LS2.SetLineWeight(1);
LS2.Hide();
LS3.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LS3.SetDefaultColor(Color.GREEN);
LS3.SetLineWeight(1);
LS3.Hide();
SS1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS1.SetDefaultColor(Color.RED);
SS1.SetLineWeight(1);
SS1.Hide();
SS2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS2.SetDefaultColor(Color.RED);
SS2.SetLineWeight(1);
SS2.Hide();
SS3.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SS3.SetDefaultColor(Color.RED);
SS3.SetLineWeight(1);
SS3.Hide();
Alert(l1, "Price crossed below Fib1 level in long trend", Alert.BAR, Sound.Ring);
Alert(l2, "Price crossed below Fib2 level in long trend", Alert.BAR, Sound.Ring);
Alert(l3, "Price crossed below Fib3 level in long trend", Alert.BAR, Sound.Ring);
Alert(s1, "Price crossed above Fib1 level in short trend", Alert.BAR, Sound.Ring);
Alert(s2, "Price crossed above Fib2 level in short trend", Alert.BAR, Sound.Ring);
Alert(s3, "Price crossed above Fib3 level in short trend", Alert.BAR, Sound.Ring);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.