NexusFi: Find Your Edge


Home Menu

 





Need help to compile . NET for MC


Discussion in MultiCharts

Updated
    1. trending_up 1,501 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Need help to compile . NET for MC

  #1 (permalink)
 Pitrader 
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
}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

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 View Post
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
}


Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 Pitrader 
Canada
 
Posts: 12 since Feb 2011


Thank you. ABCTG

Reply With Quote




Last Updated on November 25, 2019


© 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