NexusFi: Find Your Edge


Home Menu

 





EasyLanguage Programmers! I need your HELP!


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one sixhundread with 8 posts (0 thanks)
    2. looks_two artisanpro with 5 posts (2 thanks)
    3. looks_3 ShadowFox with 4 posts (5 thanks)
    4. looks_4 SunTrader with 1 posts (2 thanks)
      Best Posters
    1. looks_one SunTrader with 2 thanks per post
    2. looks_two AlgOz with 2 thanks per post
    3. looks_3 ShadowFox with 1.3 thanks per post
    4. looks_4 artisanpro with 0.4 thanks per post
    1. trending_up 6,150 views
    2. thumb_up 11 thanks given
    3. group 6 followers
    1. forum 19 posts
    2. attach_file 4 attachments




 
Search this Thread

EasyLanguage Programmers! I need your HELP!

  #11 (permalink)
artisanpro
montreal, qc, canada
 
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18

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

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #12 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7


artisanpro View Post
Yes, it is correct - it compiles and makes money as seen on the attachment showing the last 500 days of USDCAD

NOTE: see caveat on next post

USDCAD 500 days 2021-07-19_1523

but i think it has a mistake.

for "sell " and" buy to cover" there should be a "or" instead of a "and".

am I right?

Reply With Quote
  #13 (permalink)
artisanpro
montreal, qc, canada
 
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18


Your suggestion of "or" will work as well but will give a different result


inputs:
length(13);

vars:
MyEMA(0),
MyMACD(0),
MACDHist(0);

MyEMA = XAverage(close,length);
MyMACD = XAverage(close,12) - XAverage(close,26);
MACDHist = MyMACD - XAverage(MyMACD,9);

{ 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;

Reply With Quote
  #14 (permalink)
 
ShadowFox's Avatar
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
Posts: 129 since Jun 2020
Thanks Given: 70
Thanks Received: 157

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.

 
Code
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);

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #15 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7


artisanpro View Post
Your suggestion of "or" will work as well but will give a different result


inputs:
length(13);

vars:
MyEMA(0),
MyMACD(0),
MACDHist(0);

MyEMA = XAverage(close,length);
MyMACD = XAverage(close,12) - XAverage(close,26);
MACDHist = MyMACD - XAverage(MyMACD,9);

{ 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 1 contract 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;




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!


lg

Reply With Quote
  #16 (permalink)
artisanpro
montreal, qc, canada
 
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18

This link will provide you with many Elders system in Easy Language / Power Language:
https://www.multicharts.com/discussion/viewtopic.php?t=2679

Reply With Quote
  #17 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7


ShadowFox View Post
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.

 
Code
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);


yes

Reply With Quote
  #18 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7


ShadowFox View Post
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.

 
Code
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?

Reply With Quote
  #19 (permalink)
 
ShadowFox's Avatar
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
Posts: 129 since Jun 2020
Thanks Given: 70
Thanks Received: 157


sixhundread View Post
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.

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #20 (permalink)
esftrader
Kansas City, MO
 
Posts: 1 since Sep 2021
Thanks Given: 0
Thanks Received: 0


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.

 
Code
#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;

Reply With Quote




Last Updated on September 2, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts