Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Here are the settings : don't ask why the initial cap was set at 88$ I don't know but I will redo it with 5,000$ in the next few minutes.
NOTE: Something weird going at my end - results are the same with changes in settings So, someone should redo the performance report to have a better view of profitability.
USDCAD 500 days settings 2021-07-19_1531
Can you help answer these questions from other members on NexusFi?
{ these 2 lines are not used
Value1 = High;
Value2 = Low;
}
{
// initial code by
if marketPosition = 0 and MyEMA > MyEMA[1] and MACDHist > MACDHist[1] Then
Buy next bar at Open;
if marketposition = 1 and MyEMA < MyEMA[1] and MACDHist < MACDHist[1] then
Sell next bar at Open;
if Marketposition = 0 and MyEMA < MyEMA[1] and MACDHist < MACDHist[1] then
Sellshort next bar at open;
if Marketposition = -1 and MyEMA < MyEMA[1] and MACDHist < MACDHist[1] then Buy to Cover next bar at Open;
}
// is this what you mean with the "OR"
// well, that would work as well but will give a different result
// which I can't test reliably for now
if marketPosition = 0 and MyEMA > MyEMA[1] and MACDHist > MACDHist[1] Then
Buy 1 contract next bar at Open;
if marketposition = 1 and MyEMA < MyEMA[1] OR MACDHist < MACDHist[1] then
Sell 1 contract next bar at Open;
if Marketposition = 0 and MyEMA < MyEMA[1] and MACDHist < MACDHist[1] then
Sellshort 1 contract next bar at open;
if Marketposition = -1 and MyEMA < MyEMA[1] OR MACDHist < MACDHist[1] then
Buy to Cover 1 contract next bar at Open;
There is no need to sell and sell short with the same conditions. If you sell short and you are long, tradestation will close the long and sell short (reverse the position). You just need to sell short or buy to change directions.
Here is an example
Disclaimer: I would not trade this system. This is purely hypothetical to show EasyLanguage code. I am in no way saying this is profitable or not.
yes thats what i mean. i think the elder empulse system works like this. it should exit the position even when one of the 2 signals are not true anymore!
There is no need to sell and sell short with the same conditions. If you sell short and you are long, tradestation will close the long and sell short (reverse the position). You just need to sell short or buy to change directions.
Here is an example
Disclaimer: I would not trade this system. This is purely hypothetical to show EasyLanguage code. I am in no way saying this is profitable or not.
inputs:
length(13),
ContractsTraded(1),
SL(900)//amount of SL
;
vars:
MyEMA(0),
MyMACD(0),
MACDHist(0);
MyEMA = XAverage(close,length);
MyMACD = XAverage(close,12) - XAverage(close,26);
MACDHist = MyMACD - XAverage(MyMACD,9);
if MyEMA > MyEMA[1] and MACDHist > MACDHist[1] then begin
Buy("LE") Next Bar ContractsTraded contracts at Market;
end
else if MyEMA < MyEMA[1] and MACDHist < MACDHist[1] then begin
sell short("SE") Next Bar ContractsTraded Contracts at Market;
end ;
SetStopContract(); //sets the stop loss per contract, alternatively you could use SetStopPosition() to set for the whole position
SetStopLoss(SL);
if you would not trade this system, what system would you trade?
if you would not trade this system, what system would you trade?
I just don't know anything about it. I have not researched it, studied it, backtested it, forward tested it, watched it live, and I don't plan to. Not saying it might not work, just I know it will not work for me because I have worked with EMA, MACD, etc. I was just helping you get the code going.
If you want to find out what works, I suggest you get really good at coding so you can test all your idea's. You may need to test 10,000 different ideas before finding the one that is right for you.
Could anyone help me convert the following thinkScript code to EL? The script is for an indicator called 'Swing Arm'. Can't seem to find a solution anywhere for this.
#Swing Arm
input trailType = {default modified, unmodified};
input ATRPeriod = 28;
input ATRFactor = 5;
input firstTrade = {default long, short};
def 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.LINE);
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.DASHES);
Extremum.DefineColor("HH", CreateColor(0, 50, 0));
Extremum.DefineColor("LL", CreateColor(50, 0, 0));
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();
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;