help with mql4 files

 

I have build few codes and mql4 files for automated trading for metatrader 4 with a software. For some reason metatrader4 cant read it.

i have contact the company who has the software and said its all ok from their part.

Can anyone help me find whats the problem with the coding of the systems that i find pls? it must be something so small but i cant figure it out.

thats one for example:

// Strategy inputs

extern int NL1 = 107;

extern int NL2 = 179;

extern double XL1 = 16.0000;

extern int NS1 = 29;

extern int NS2 = 69;

extern int NS3 = 135;

extern int NS4 = 135;

extern int ShiftS1 = 20;

extern int NBarEnL1 = 199;

extern int NBarEnL2 = 198;

extern double EntFrL = 3.0756;

extern int NATRTrailL = 155;

extern double ATRFrTrailL = 0.6313;

extern double TrailPctL = 51.0000;

extern int NBarExL = 140;

extern double MMStopSzL = 594.20;

extern int NBarEnS1 = 161;

extern int NBarEnS3 = 172;

extern double EntFrS = 3.3586;

extern int NATRTrailS = 50;

extern double ATRFrTrailS = 1.7924;

extern double TrailPctS = 42.0000;

extern double MMStopSzS = 131.87;

extern int NBarExS = 178;

extern double StartEquity = 1000.00;

extern double PSParam = 100.00;

extern bool RoundPS = true;

extern int RoundTo = 1;

extern int MinSize = 1;

extern int SizeLimit = 1000;


// Global strategy variables

int MaxBarsBack = 199;

double BigPointValue = 1.000000;

int MaxSlippage = 3;

double SharesPerLot = 100000;


// Variables for entry and exit prices

double LStop = 0;

double NewLStop = 0;

bool LTrailOn = false;

double SStop = 0;

double NewSStop = 0;

bool STrailOn = false;


// Main strategy code

int start() {


if (IsTradeAllowed() && Bars >= MaxBarsBack) {


ManageOrders(Symbol(), STRATORDERID, MaxSlippage);


if (Volume[0] <= 1) {


// Average true range

double ATRTrailL = iATR(NULL, 0, NATRTrailL, 1);

double ATRTrailS = iATR(NULL, 0, NATRTrailS, 1);


// Entry prices

double EntPrL = Low[NBarEnL1 + 1] + EntFrL * (Low[NBarEnL2 + 1] - Low[1]);

double EntPrS = iMA(NULL, 0, NBarEnS1, 0, MODE_EMA, PRICE_HIGH, 1) - EntFrS * (High[1] - Open[NBarEnS3 + 1]);

EntPrL = NormalizeDouble(EntPrL, Digits);

EntPrS = NormalizeDouble(EntPrS, Digits);


// Entry and exit conditions

double VarL1 = iADX(NULL, 0, NL1, PRICE_CLOSE, MODE_PLUSDI, 1);

double VarL2 = Low[NL2 + 1];

double VarS1 = iADX(NULL, 0, NS1, PRICE_CLOSE, MODE_MINUSDI, 1);

double VarS2 = iADX(NULL, 0, NS2, PRICE_CLOSE, MODE_MINUSDI, ShiftS1 + 1);

double VarS3 = iMACD(NULL, 0, NS3, NS4, 1, PRICE_OPEN, MODE_MAIN, 1);

bool CondL2 = VarL1 >= XL1;

bool CondL3 = VarL2 >= Close[1];

bool CondS1 = VarS1 <= VarS2;

bool CondS2 = VarS3 > 0;

bool EntCondL = true;

bool EntCondS = CondS1 && CondS2;

bool ExCondL = CondL2 && CondL3;


// Position sizing calculations

double Equity = StartEquity + TotalProfit(Symbol(), STRATORDERID);

double NSharesL = (Equity * 0.01 * PSParam)/MathAbs(EntPrL * BigPointValue);

double NSharesS = (Equity * 0.01 * PSParam)/MathAbs(EntPrS * BigPointValue);


if (RoundPS && RoundTo > 0) {

NSharesL = MathFloor(NSharesL/RoundTo) * RoundTo;

NSharesS = MathFloor(NSharesS/RoundTo) * RoundTo;

}


NSharesL = MathMax(NSharesL, MinSize);

NSharesL = MathMin(NSharesL, SizeLimit);

NSharesS = MathMax(NSharesS, MinSize);

NSharesS = MathMin(NSharesS, SizeLimit);


double LotsL = NSharesL/SharesPerLot;

double LotsS = NSharesS/SharesPerLot;


// Prepare to place trading orders

int MarketPosition = CurrentPosition();

double InitialStop = 0;


// Entry orders

if (MarketPosition == 0 && EntCondL) {

EnterLongStop(Symbol(), LotsL, InitialStop, MarketPosition, EntPrL, MaxSlippage, STRATORDERID);

}


if (MarketPosition == 0 && EntCondS) {

EnterShortStop(Symbol(), LotsS, InitialStop, MarketPosition, EntPrS, MaxSlippage, STRATORDERID);

}


// Exit orders, long trades

if (MarketPosition > 0) {


if (iBarShift(NULL, 0, OpenEntryTime) - 1 == 0) {

LStop = OpenEntryPrice - MMStopSzL/BigPointValue;

LStop = NormalizeDouble(LStop, Digits);

LTrailOn = false;

}


if (Close[1] - OpenEntryPrice > ATRFrTrailL * ATRTrailL)

LTrailOn = true;


if (LTrailOn) {

NewLStop = OpenEntryPrice + TrailPctL * (Close[1] - OpenEntryPrice)/100.;

LStop = MathMax(LStop, NewLStop);

LStop = NormalizeDouble(LStop, Digits);

}


PlaceLongStop(Symbol(), LStop, MaxSlippage);


if (ExCondL || iBarShift(NULL, 0, OpenEntryTime) - 1 >= NBarExL)

ExitLongMarket(MaxSlippage);

}


// Exit orders, short trades

if (MarketPosition < 0) {


if (iBarShift(NULL, 0, OpenEntryTime) - 1 == 0) {

SStop = OpenEntryPrice + MMStopSzS/BigPointValue;

SStop = NormalizeDouble(SStop, Digits);

STrailOn = false;

}


if (OpenEntryPrice - Close[1] > ATRFrTrailS * ATRTrailS)

STrailOn = true;


if (STrailOn) {

NewSStop = OpenEntryPrice - TrailPctS * (OpenEntryPrice - Close[1])/100.;

SStop = MathMin(SStop, NewSStop);

SStop = NormalizeDouble(SStop, Digits);

}


PlaceShortStop(Symbol(), SStop, MaxSlippage);


if (iBarShift(NULL, 0, OpenEntryTime) - 1 >= NBarExS)

ExitShortMarket(MaxSlippage);

}

}

}

}

 
If you're using an ea_builder then perhaps you should look for a different one with better support.
 
parispanayi:

I have build few codes and mql4 files for automated trading for metatrader 4 with a software. For some reason metatrader4 cant read it.

i have contact the company who has the software and said its all ok from their part.

Can anyone help me find whats the problem with the coding of the systems that i find pls? it must be something so small but i cant figure it out.

<CODE REMOVED>

Please read some other posts before posting . . .

If you want help . . . edit . . . . your post . . . please use the SRC button to post code: How to use the SRC button. If it's too big to post using the SRC button attach it as a file.

Reason: