Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
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)
Need help to compile . NET for MC
Updated November 25, 2019
trending_up
1,491 views
thumb_up
2 thanks given
group
2 followers
forum
2 posts
attach_file
0 attachments
Need help to compile . NET for MC
November 23rd, 2019, 10:54 AM
Canada
Posts: 12 since Feb 2011
I had an ELD indicator translated into C# so I could run it in MC .NET. I am not a coder so I had the translation done by mpsinc. I tried to compile it through the MC .NET Power Editor and everything went fine up until the last line of code where I got an error saying " Type or namespace definition, or end-of-file expected." Also I do not see any inputs that are in the ELD code. I'm hoping that someone on this forum can help. I have the C# code below.
Code
/* Module Name: D:\avi\EasyLanguage\TestData\pitrader\indicator3\indicator3.txt */
/*Translated by Easy Language to C# Translator Ver 3.3 R 46 for windows(32 bit)*/
/*(c) 1992-2018 Micro Processor Services Date:11/19/19 Time:12:54:15 */
/* Translator Option List (1=ON,0=OFF) :
output style - 1 include format - 0 temp_drv_valid - 0
include select - 0 index increment - 0 move nested function - 1
complete struct member - 1 comment trans stop- 0 error by pass - 0
indent # of spaces - 4 include file name -'' include file ext -'HH'
output select - 3 append include -'0' not used -'0'
*/
using System;
using System.IO;
namespace System.indicator3
{
class indicator3
{
#region Varaibles
int debug = { FALSE};
int startswitch = { FALSE};
int secondswitch = { FALSE};
int thirdswitch = { FALSE};
int originalhigh = { 0};
int counter = { 0};
int barsback_pt1 = { 4};
int projection1 = { 0};
int projection2 = { 0};
int keltnermidline = { 0};
int keltneratr = { 0};
int upperkeltnerband = { 0};
int fastaverage = { 0};
static int tlforecast = { 0};
int tlcounter1 = { 0};
int tlcounter2 = { 0};
int tlcounter3 = { 0};
String dictkey = { ""};
int highbar = { 99999999};
double displace = { 0};
#endregion
protected override void Initialize()
{
}
protected override void OnBarUpdate()
{
keltnermidline = averagefc(keltnerprice, keltnerlength);
keltneratr = keltnernumatrs * avgtruerange(keltnerlength);
upperkeltnerband = keltnermidline - keltneratr;
fastaverage = Average(fastavgprice, fastavglength);
counter += 1;
if (Date != Date[1]) /* {reset conditions on start of day
*/
{
startswitch = FALSE;
secondswitch = FALSE;
}
if (keltnerdisplace >= (0 || CurrentBar) > absvalue(keltnerdisplace)) /* {Only plots when displacment value is positive
*/
/* {==================================
*/
/* { Plot and TL projection calcs
*/
/* {==================================
*/
{
plot1(upperkeltnerband, "UpperBand");
plot2(fastaverage, "FastAverage");
if (Barnumber > keltnerdisplace) {
finaltl1 = trendline.create(dtpoint.create(bardatetime[keltnerdisplace], plot1[keltnerdisplace]), dtpoint.create(bardatetime[(keltnerdisplace + 1)], plot1[(keltnerdisplace + 1)]));
drawingobjects.add(finaltl1);
finaltl1.color = color.fromargb(0, 102, 0);
/* {dark green
*/
finaltl1.extright = FALSE;
finaltl1.weight = 0;
finaltl1.style = 0;
finaltl1.persist = TRUE;
tlforecast = finaltl1.getvalue(bardatetime[0]);
if (pz_lastbaronchart) {
finaltl1.setstartpoint(dtpoint.create(bardatetime[keltnerdisplace], plot1[keltnerdisplace]));
finaltl1.setendpoint(dtpoint.create(bardatetime[(keltnerdisplace + 1)], plot1[(keltnerdisplace + 1)]));
finaltl1.extright = TRUE;
if (barstatus(1) == 2) finaltl1.extright = FALSE;
}
if (showextensionhistory) plot3(tlforecast, "HistUpBand");
}
if (fastaverage[keltnerdisplace] > fastaverage[(keltnerdisplace + 1)] - (.01 && fastaverage[keltnerdisplace]) < upperkeltnerband) /* {==================================
*/
/* { Line Extension calcs
*/
/* {==================================
*/
{
highbar = highest(h, keltnerdisplace + 1 + barsback_pt1);
/* {Defines new highs
*/
startswitch = TRUE;
secondswitch = FALSE;
if (debug) {
textid1 = textlabel.create(dtpoint.create(bardatetime[keltnerdisplace], h[keltnerdisplace]), "START");
drawingobjects.add(textid1);
}
}
if (h > highbar) highbar = h;
if (startswitch == TRUE && fastaverage < fastaverage[1] + .01) {
secondswitch = TRUE;
if (debug) {
textid1 = textlabel.create(dtpoint.create(bardatetime[0], l[0]), "2nd");
drawingobjects.add(textid1);
}
}
if (highbar > 0) {
projection1 = roundinst(highbar - absvalue(tlforecast - highbar) * extension1_percent * .01);
projection2 = roundinst(highbar - absvalue(tlforecast - highbar) * extension2_percent * .01);
}
if (secondswitch) /* {==== plots initial lines when fast MA crosses forecast tl ====
*/
/* {and barstatus(1) = 2} */
{
if (h < (h[6] && l) < l[6] && fastaverage > (tlforecast || fastaverage[1]) > (tlforecast || fastaverage[2]) > tlforecast) {
thirdswitch = TRUE;
plot10(highbar, "HighMarker");
/* {plots 10 - 12 used to adjust scaling
*/
finaltl2 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace * 2 + 3, projection1), bnpoint.create(Barnumber + keltnerdisplace * 2 + 3 + linelength_bars, projection1));
drawingobjects.add(finaltl2);
finaltl2.color = color.fromargb(255, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl2.extright = FALSE;
finaltl2.weight = 1;
finaltl2.style = 0;
finaltl3 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace * 2 + 3, projection2), bnpoint.create(Barnumber + keltnerdisplace * 2 + 3 + linelength_bars, projection2));
drawingobjects.add(finaltl3);
finaltl3.color = color.fromargb(255, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl3.extright = FALSE;
finaltl3.weight = 1;
finaltl3.style = 0;
plot11(projection1, "Projection1", getbackgroundcolor);
plot12(projection2, "Projection2", getbackgroundcolor);
counter = 0;
originalhigh = highbar;
highbar = 0;
startswitch = FALSE;
secondswitch = FALSE;
}
else if (Close[keltnerdisplace] < (fastaverage[keltnerdisplace] && fastaverage[keltnerdisplace]) > (upperkeltnerband && fastaverage[keltnerdisplace]) < fastaverage[(keltnerdisplace + 1)] + .01) {
thirdswitch = TRUE;
finaltl2 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace + 1, projection1[keltnerdisplace]), bnpoint.create(Barnumber + keltnerdisplace + linelength_bars + 1, projection1[keltnerdisplace]));
drawingobjects.add(finaltl2);
finaltl2.color = color.fromargb(0, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl2.extright = FALSE;
finaltl2.weight = 0;
finaltl2.style = 2;
finaltl3 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace + 1, projection2[keltnerdisplace]), bnpoint.create(Barnumber + keltnerdisplace + linelength_bars + 1, projection2[keltnerdisplace]));
drawingobjects.add(finaltl3);
finaltl3.color = color.fromargb(0, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl3.extright = FALSE;
finaltl3.weight = 0;
finaltl3.style = 2;
/* {plot11[KeltnerDisplace](Projection1[KeltnerDisplace], "Projection1", getbackgroundcolor);
plot12[KeltnerDisplace](Projection2[KeltnerDisplace], "Projection2", getbackgroundcolor);} */
counter = 0;
originalhigh = highbar;
highbar = 0;
startswitch = FALSE;
secondswitch = FALSE;
thirdswitch = FALSE;
}
}
if (thirdswitch && counter >= 3 && Close[keltnerdisplace] < (fastaverage[keltnerdisplace] && fastaverage[keltnerdisplace]) > upperkeltnerband) /* {==== moves lines when confirmed MA cross ====
*/
/* {and barstatus(1) = 2} */
/* {and value1 > 0 and value2 > 0} */
{
projection1 = roundinst(originalhigh - absvalue(upperkeltnerband - originalhigh) * extension1_percent * .01);
projection2 = roundinst(originalhigh - absvalue(upperkeltnerband - originalhigh) * extension2_percent * .01);
if (debug) {
textid1 = textlabel.create(dtpoint.create(bardatetime[0], h[0]), numtostr(originalhigh, 2) + " : " + numtostr(upperkeltnerband, 2) + " : " + numtostr(projection1, 2));
drawingobjects.add(textid1);
}
displace = maxbarsback - keltnerdisplace + 4 - 1;
finaltl2.setstartpoint(bnpoint.create(Barnumber + keltnerdisplace + 4, projection1));
finaltl2.setendpoint(bnpoint.create(Barnumber + keltnerdisplace + 4 + linelength_bars, projection1));
finaltl2.color = color.fromargb(255, getrvalue(extensioncolormove), getgvalue(extensioncolormove), getbvalue(extensioncolormove));
finaltl2.weight = 1;
finaltl2.style = 0;
finaltl3.setstartpoint(bnpoint.create(Barnumber + keltnerdisplace + 4, projection2));
finaltl3.setendpoint(bnpoint.create(Barnumber + keltnerdisplace + 4 + linelength_bars, projection2));
finaltl3.color = color.fromargb(255, getrvalue(extensioncolormove), getgvalue(extensioncolormove), getbvalue(extensioncolormove));
finaltl3.weight = 1;
finaltl3.style = 0;
plot10(originalhigh, "HighMarker");
/* {plots 10 - 12 used to adjust scaling
*/
plot11(projection1, "Projection1", getbackgroundcolor);
plot12(projection2, "Projection2", getbackgroundcolor);
startswitch = FALSE;
secondswitch = FALSE;
thirdswitch = FALSE;
}
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Displace
{
get { return displace; }
set { displace = Math.Max(1,Value);}
}
}
}
#endregion
}
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
November 25th, 2019, 04:03 AM
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623
Pitrader,
this appears to be Ninjatrader code and it won't work without rewriting it within MC.NET. Although both platforms use C# as programming language for the studies the code and structures that drive the platform functionality are different.
Regards,
ABCTG
Pitrader
I had an ELD indicator translated into C# so I could run it in MC .NET. I am not a coder so I had the translation done by mpsinc. I tried to compile it through the MC .NET Power Editor and everything went fine up until the last line of code where I got an error saying " Type or namespace definition, or end-of-file expected." Also I do not see any inputs that are in the ELD code. I'm hoping that someone on this forum can help. I have the C# code below.
Code
/* Module Name: D:\avi\EasyLanguage\TestData\pitrader\indicator3\indicator3.txt */
/*Translated by Easy Language to C# Translator Ver 3.3 R 46 for windows(32 bit)*/
/*(c) 1992-2018 Micro Processor Services Date:11/19/19 Time:12:54:15 */
/* Translator Option List (1=ON,0=OFF) :
output style - 1 include format - 0 temp_drv_valid - 0
include select - 0 index increment - 0 move nested function - 1
complete struct member - 1 comment trans stop- 0 error by pass - 0
indent # of spaces - 4 include file name -'' include file ext -'HH'
output select - 3 append include -'0' not used -'0'
*/
using System;
using System.IO;
namespace System.indicator3
{
class indicator3
{
#region Varaibles
int debug = { FALSE};
int startswitch = { FALSE};
int secondswitch = { FALSE};
int thirdswitch = { FALSE};
int originalhigh = { 0};
int counter = { 0};
int barsback_pt1 = { 4};
int projection1 = { 0};
int projection2 = { 0};
int keltnermidline = { 0};
int keltneratr = { 0};
int upperkeltnerband = { 0};
int fastaverage = { 0};
static int tlforecast = { 0};
int tlcounter1 = { 0};
int tlcounter2 = { 0};
int tlcounter3 = { 0};
String dictkey = { ""};
int highbar = { 99999999};
double displace = { 0};
#endregion
protected override void Initialize()
{
}
protected override void OnBarUpdate()
{
keltnermidline = averagefc(keltnerprice, keltnerlength);
keltneratr = keltnernumatrs * avgtruerange(keltnerlength);
upperkeltnerband = keltnermidline - keltneratr;
fastaverage = Average(fastavgprice, fastavglength);
counter += 1;
if (Date != Date[1]) /* {reset conditions on start of day
*/
{
startswitch = FALSE;
secondswitch = FALSE;
}
if (keltnerdisplace >= (0 || CurrentBar) > absvalue(keltnerdisplace)) /* {Only plots when displacment value is positive
*/
/* {==================================
*/
/* { Plot and TL projection calcs
*/
/* {==================================
*/
{
plot1(upperkeltnerband, "UpperBand");
plot2(fastaverage, "FastAverage");
if (Barnumber > keltnerdisplace) {
finaltl1 = trendline.create(dtpoint.create(bardatetime[keltnerdisplace], plot1[keltnerdisplace]), dtpoint.create(bardatetime[(keltnerdisplace + 1)], plot1[(keltnerdisplace + 1)]));
drawingobjects.add(finaltl1);
finaltl1.color = color.fromargb(0, 102, 0);
/* {dark green
*/
finaltl1.extright = FALSE;
finaltl1.weight = 0;
finaltl1.style = 0;
finaltl1.persist = TRUE;
tlforecast = finaltl1.getvalue(bardatetime[0]);
if (pz_lastbaronchart) {
finaltl1.setstartpoint(dtpoint.create(bardatetime[keltnerdisplace], plot1[keltnerdisplace]));
finaltl1.setendpoint(dtpoint.create(bardatetime[(keltnerdisplace + 1)], plot1[(keltnerdisplace + 1)]));
finaltl1.extright = TRUE;
if (barstatus(1) == 2) finaltl1.extright = FALSE;
}
if (showextensionhistory) plot3(tlforecast, "HistUpBand");
}
if (fastaverage[keltnerdisplace] > fastaverage[(keltnerdisplace + 1)] - (.01 && fastaverage[keltnerdisplace]) < upperkeltnerband) /* {==================================
*/
/* { Line Extension calcs
*/
/* {==================================
*/
{
highbar = highest(h, keltnerdisplace + 1 + barsback_pt1);
/* {Defines new highs
*/
startswitch = TRUE;
secondswitch = FALSE;
if (debug) {
textid1 = textlabel.create(dtpoint.create(bardatetime[keltnerdisplace], h[keltnerdisplace]), "START");
drawingobjects.add(textid1);
}
}
if (h > highbar) highbar = h;
if (startswitch == TRUE && fastaverage < fastaverage[1] + .01) {
secondswitch = TRUE;
if (debug) {
textid1 = textlabel.create(dtpoint.create(bardatetime[0], l[0]), "2nd");
drawingobjects.add(textid1);
}
}
if (highbar > 0) {
projection1 = roundinst(highbar - absvalue(tlforecast - highbar) * extension1_percent * .01);
projection2 = roundinst(highbar - absvalue(tlforecast - highbar) * extension2_percent * .01);
}
if (secondswitch) /* {==== plots initial lines when fast MA crosses forecast tl ====
*/
/* {and barstatus(1) = 2} */
{
if (h < (h[6] && l) < l[6] && fastaverage > (tlforecast || fastaverage[1]) > (tlforecast || fastaverage[2]) > tlforecast) {
thirdswitch = TRUE;
plot10(highbar, "HighMarker");
/* {plots 10 - 12 used to adjust scaling
*/
finaltl2 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace * 2 + 3, projection1), bnpoint.create(Barnumber + keltnerdisplace * 2 + 3 + linelength_bars, projection1));
drawingobjects.add(finaltl2);
finaltl2.color = color.fromargb(255, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl2.extright = FALSE;
finaltl2.weight = 1;
finaltl2.style = 0;
finaltl3 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace * 2 + 3, projection2), bnpoint.create(Barnumber + keltnerdisplace * 2 + 3 + linelength_bars, projection2));
drawingobjects.add(finaltl3);
finaltl3.color = color.fromargb(255, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl3.extright = FALSE;
finaltl3.weight = 1;
finaltl3.style = 0;
plot11(projection1, "Projection1", getbackgroundcolor);
plot12(projection2, "Projection2", getbackgroundcolor);
counter = 0;
originalhigh = highbar;
highbar = 0;
startswitch = FALSE;
secondswitch = FALSE;
}
else if (Close[keltnerdisplace] < (fastaverage[keltnerdisplace] && fastaverage[keltnerdisplace]) > (upperkeltnerband && fastaverage[keltnerdisplace]) < fastaverage[(keltnerdisplace + 1)] + .01) {
thirdswitch = TRUE;
finaltl2 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace + 1, projection1[keltnerdisplace]), bnpoint.create(Barnumber + keltnerdisplace + linelength_bars + 1, projection1[keltnerdisplace]));
drawingobjects.add(finaltl2);
finaltl2.color = color.fromargb(0, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl2.extright = FALSE;
finaltl2.weight = 0;
finaltl2.style = 2;
finaltl3 = trendline.create(bnpoint.create(Barnumber + keltnerdisplace + 1, projection2[keltnerdisplace]), bnpoint.create(Barnumber + keltnerdisplace + linelength_bars + 1, projection2[keltnerdisplace]));
drawingobjects.add(finaltl3);
finaltl3.color = color.fromargb(0, getrvalue(extensioncolor), getgvalue(extensioncolor), getbvalue(extensioncolor));
finaltl3.extright = FALSE;
finaltl3.weight = 0;
finaltl3.style = 2;
/* {plot11[KeltnerDisplace](Projection1[KeltnerDisplace], "Projection1", getbackgroundcolor);
plot12[KeltnerDisplace](Projection2[KeltnerDisplace], "Projection2", getbackgroundcolor);} */
counter = 0;
originalhigh = highbar;
highbar = 0;
startswitch = FALSE;
secondswitch = FALSE;
thirdswitch = FALSE;
}
}
if (thirdswitch && counter >= 3 && Close[keltnerdisplace] < (fastaverage[keltnerdisplace] && fastaverage[keltnerdisplace]) > upperkeltnerband) /* {==== moves lines when confirmed MA cross ====
*/
/* {and barstatus(1) = 2} */
/* {and value1 > 0 and value2 > 0} */
{
projection1 = roundinst(originalhigh - absvalue(upperkeltnerband - originalhigh) * extension1_percent * .01);
projection2 = roundinst(originalhigh - absvalue(upperkeltnerband - originalhigh) * extension2_percent * .01);
if (debug) {
textid1 = textlabel.create(dtpoint.create(bardatetime[0], h[0]), numtostr(originalhigh, 2) + " : " + numtostr(upperkeltnerband, 2) + " : " + numtostr(projection1, 2));
drawingobjects.add(textid1);
}
displace = maxbarsback - keltnerdisplace + 4 - 1;
finaltl2.setstartpoint(bnpoint.create(Barnumber + keltnerdisplace + 4, projection1));
finaltl2.setendpoint(bnpoint.create(Barnumber + keltnerdisplace + 4 + linelength_bars, projection1));
finaltl2.color = color.fromargb(255, getrvalue(extensioncolormove), getgvalue(extensioncolormove), getbvalue(extensioncolormove));
finaltl2.weight = 1;
finaltl2.style = 0;
finaltl3.setstartpoint(bnpoint.create(Barnumber + keltnerdisplace + 4, projection2));
finaltl3.setendpoint(bnpoint.create(Barnumber + keltnerdisplace + 4 + linelength_bars, projection2));
finaltl3.color = color.fromargb(255, getrvalue(extensioncolormove), getgvalue(extensioncolormove), getbvalue(extensioncolormove));
finaltl3.weight = 1;
finaltl3.style = 0;
plot10(originalhigh, "HighMarker");
/* {plots 10 - 12 used to adjust scaling
*/
plot11(projection1, "Projection1", getbackgroundcolor);
plot12(projection2, "Projection2", getbackgroundcolor);
startswitch = FALSE;
secondswitch = FALSE;
thirdswitch = FALSE;
}
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Displace
{
get { return displace; }
set { displace = Math.Max(1,Value);}
}
}
}
#endregion
}
November 25th, 2019, 09:34 AM
Canada
Posts: 12 since Feb 2011
Last Updated on November 25, 2019