PDA

View Full Version : How to convert EA mtl4 to VTL

bharat.ecb
12-09-2013, 07:10 PM
Hi,

I want your Help to create VTLEA.

Thank you

Hassan-HS
12-10-2013, 06:23 AM
Hello Bharat,

If you think that creating scripts is too complicated or beyond your capacity, don't worry, this course (http://www.hybrid-solutions.com/VTL%20Course.pdf) is intended for those of us who are just starting out in programming, so it starts from zero.

These lessons have lots of examples, and we've simplified them as much as possible so that it's easy to learn VTL.

bharat.ecb
12-10-2013, 06:40 AM
extern double start_lot=0.01; //order lot size
extern int TAKEPROFITPIPS=99; /// take profit in pips
extern int STOPLOSSPIPS=99; // stop loss in pips
extern int MAX_ACCOUNT_RISK=25; //in percent,closes all losing trades if AccountEquity goes below AccountBalance by this amount
extern string X________________1="------MARTINGALE------";
extern bool MARTINGALE_ACTIVATOR=false; /// wanna use martingale system?
extern int MARTINGALE_LEVELS=5; // what levels to go,ex level 5= 2^5 multiplicator for lot
extern string X________________2="------ORDER SETTINGS------";
extern int TOTAL_SELL_ORDERS=1; //how many sell orders to place,maximum
extern int MAX_SLIPPAGE=3; //for placing orders only
extern string X________________3="------MACD SETTINGS------";
extern int FAST_MACD_P=5;
extern int SLOW_MACD_P=35;
extern int SIGNAL_PERIOD=5;
extern string X________________4="------TREND FILTER SETTINGS------";
//extern int ATR_SLOW_PERIOD=24;
//extern int ATR_QUICK_PERIOD=5;

/////////////////////////OPTIMALIZED////////////----------------------------------<<<<<

///////////////////////////////////-----------------------END EXTERNAL VARIABLES----------------//////////////////
////////////////////////////----------------INIT VARIABLES-------------////////////////////////////////////////////
int ticket=0;
int i=1;
string via="X";
string viaID="X";
int LEVEL=1;
int magic=666; ///magic number
double martingale_lot=0.01;
///correction
int PositionIndex;
int TotalNumberOfOrders;
int slippagex;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
martingale_lot=start_lot;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{

/////////////////////////////////////////-----------START SIGNALS-------/////////////////////////////////////////////////////////
//////////////////////\$ nr 1 the moving average rainbow detector

double FMA1=iMA(Symbol(),0,2,0,MODE_EMA,PRICE_CLOSE,0);
double FMA2=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,0);
double FMA3=iMA(Symbol(),0,5,0,MODE_EMA,PRICE_CLOSE,0);
double FMA4=iMA(Symbol(),0,8,0,MODE_EMA,PRICE_CLOSE,0);
double FMA5=iMA(Symbol(),0,13,0,MODE_EMA,PRICE_CLOSE,0);
double FMA6=iMA(Symbol(),0,21,0,MODE_EMA,PRICE_CLOSE,0);
double FMA7=iMA(Symbol(),0,34,0,MODE_EMA,PRICE_CLOSE,0);
double FMA8=iMA(Symbol(),0,55,0,MODE_EMA,PRICE_CLOSE,0);
double FMA9=iMA(Symbol(),0,89,0,MODE_EMA,PRICE_CLOSE,0);
double FMA10=iMA(Symbol(),0,144,0,MODE_EMA,PRICE_CLOSE,0) ;
double FMA11=iMA(Symbol(),0,233,0,MODE_EMA,PRICE_CLOSE,0) ;
//slope
double MACD = iMACD(Symbol(),0, FAST_MACD_P, SLOW_MACD_P, SIGNAL_PERIOD, PRICE_CLOSE, MODE_SIGNAL, 0);
//double ATRSLOW = iATR(Symbol(),0,ATR_SLOW_PERIOD,0);
//double ATRQUICK = iATR(Symbol(),0,ATR_QUICK_PERIOD,0);

///////////////////////////////////////////////HOLY SIGNAL/////////////////////////
//here it goes baby
//HALT
if(MACD>0)
{
viaID="NS";
if(FMA1>FMA2 && FMA2>FMA3 && FMA3>FMA4 && FMA4>FMA5 && FMA5>FMA6 && FMA6>FMA7 && FMA7>FMA8 && FMA8>FMA9 && FMA9>FMA10 && FMA10>FMA11 && ADXTREND>ADX_LIMIT_TRIGGER)
{via="B";}
//else viaID="NB";
}

//sell
if(MACD<0)
{
viaID="NB";
if(FMA1<FMA2 && FMA2<FMA3 && FMA3<FMA4 && FMA4<FMA5 && FMA5<FMA6 && FMA6<FMA7 && FMA7<FMA8 && FMA8<FMA9 && FMA9<FMA10 && FMA10<FMA11 && ADXTREND>ADX_LIMIT_TRIGGER)
{via="S";}
//else viaID="NS";
}

Print("-------DECISION?: ", viaID);

/////////------------------------------------------------------------------------------------------------//

if(via=="B" || viaID=="NS" || (((AccountBalance()-AccountEquity())*100/AccountBalance())>MAX_ACCOUNT_RISK))
{

TotalNumberOfOrders = OrdersTotal();
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --) // <-- for loop to loop through all Orders . . COUNT DOWN TO ZERO !
{
if( ! OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue; // <-- if the OrderSelect fails advance the loop to the next PositionIndex

if( OrderMagicNumber() == magic // <-- does the Order's Magic Number match our EA's magic number ?
&& OrderSymbol() == Symbol() // <-- does the Order's Symbol match the Symbol our EA is working on ?
&& ( OrderType() == OP_SELL )) // <-- is the Order a SELL Order ?
// <-- PROFITABLE OR NOT NO NEED ?
{
slippagex=MathAbs(Bid-OrderStopLoss())/Point;
Print("this is the slippage: ",slippagex);
if ( ! OrderClose( OrderTicket(), OrderLots(), Bid,slippagex ) ) // <-- try to close the order
Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() ); // <-- if the Order Close failed print some helpful information
}
} // end of For loop

}
/////---------------------------------------------------------------------------------------------///

/////sell signal
if(via=="S" || viaID=="NB" || (((AccountBalance()-AccountEquity())*100/AccountBalance())>MAX_ACCOUNT_RISK))
{

TotalNumberOfOrders = OrdersTotal();
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --) // <-- for loop to loop through all Orders . . COUNT DOWN TO ZERO !
{
if( ! OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue; // <-- if the OrderSelect fails advance the loop to the next PositionIndex

if( OrderMagicNumber() == magic // <-- does the Order's Magic Number match our EA's magic number ?
&& OrderSymbol() == Symbol() // <-- does the Order's Symbol match the Symbol our EA is working on ?
&& ( OrderType() == OP_BUY )) // <-- is the Order a Buy Order ?
// <-- PROFITABLE O NOT NO NEED?
{
Print("this is the slippage: ",slippagex);
if ( ! OrderClose( OrderTicket(), OrderLots(), Ask,slippagex ) ) // <-- try to close the order
Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() ); // <-- if the Order Close failed print some helpful information
}
} // end of For loop

}

//////////////////////////////MARTINGALE SYSTEM//////////////////////////////////////////////////

//--------------------------------//
if(MARTINGALE_ACTIVATOR){ /////////////////
static datetime lastClose; datetime lastClosePrev = lastClose;
for(i=0; i < OrdersHistoryTotal(); i++) {///////////////////////////////////////////////

OrderSelect(i, SELECT_BY_POS, MODE_HISTORY); // Only orders w/
if( OrderMagicNumber() == magic // <-- does the Order's Magic Number match our EA's magic number ?
&& OrderCloseTime() > lastClosePrev
&& OrderSymbol() == Symbol() // <-- does the Order's Symbol match the Symbol our EA is working on ?
&& (OrderType() == OP_BUY // <-- is the Order a Buy Order ?
||OrderType() == OP_SELL ) ) // <-- PROFITABLE O NOT ?
{ /////////// /////////////////////////////////////////////////////////////////////////////////////////////

lastClose = OrderCloseTime();

////////////////////////////////////////////////////
if(MARTINGALE_PROGRESSION==false){
if(OrderProfit()<=0) LEVEL++; //LOSS
if(OrderProfit()>0) LEVEL=0; //PROFIT CANCEL OUT
if(LEVEL>MARTINGALE_LEVELS) LEVEL=0;
start_lot=martingale_lot*MathPow(2,LEVEL);
}
///////////////////////////////////////////////////////////////////////////////////////
if(MARTINGALE_PROGRESSION==true){
LEVEL++;
if(LEVEL>MARTINGALE_LEVELS) LEVEL=0;
start_lot=martingale_lot*MathPow(2,LEVEL);
}
/////////////////////////////////////////////////////////
break;
}
///////////////////////////////////////
} }
///////////////////////////////////////////-------------ORDERS SEND AND MODIFY--------/////////////////////////////

//----

{

}

if(via=="S" && viaID=="NB" && (OrdersTotal()<TOTAL_SELL_ORDERS) && (((AccountBalance()-AccountEquity())*100/AccountBalance())<MAX_ACCOUNT_RISK)) /////////// SELL
{

ticket=OrderSend(Symbol(),OP_SELL,start_lot,Bid,MA X_SLIPPAGE*10,0,0,"",magic,0,Red);
// OrderModify(ticket,OrderOpenPrice(),Bid+STOPLOSSPI PS*Point,Bid-(TAKEPROFITPIPS*Point),0,CLR_NONE);
}

return(0);
}

bharat.ecb
12-10-2013, 06:44 AM
Hi Sir,
Above is mql4 script. I have converted into vtl. Can you tell me . I am doing correct or not.

Dim start_lot 'order lot size
Dim TAKEPROFITPIPS
Dim STOPLOSSPIPS
Dim MAX_ACCOUNT_RISK
Dim X________________1
Dim MARTINGALE_ACTIVATOR
Dim MARTINGALE_LEVELS
Dim MARTINGALE_PROGRESSION
Dim X________________2
Dim TOTAL_SELL_ORDERS
Dim MAX_SLIPPAGE
Dim X________________3
Dim FAST_MACD_P
Dim SLOW_MACD_P
Dim SIGNAL_PERIOD
Dim X________________4

'Global Variables for internal use
Dim ticket
ticket=0
Dim i
i=1
Dim via
via="X"
Dim viaID
viaID="X"
Dim LEVEL
LEVEL=1
Dim magic
magic=666 'magic number
Dim martingale_lot
martingale_lot=0.01
Dim PositionIndex
Dim TotalNumberOfOrders
Dim slippagex

''' <summary>
''' The function is generated when initialization script
''' </summary>

Public Sub OnInit()

start_lot =0.01 'order lot size
TAKEPROFITPIPS = 99 'take profit in pips
STOPLOSSPIPS=99 'stop loss in pips
MAX_ACCOUNT_RISK=25 'in percent,closes all losing trades if AccountEquity goes below AccountBalance by this amount

X________________1="------MARTINGALE------"
MARTINGALE_ACTIVATOR=false ' wanna use martingale system?
MARTINGALE_LEVELS=5 'what levels to go,ex level 5= 2^5 multiplicator for lot

X________________2="------ORDER SETTINGS------"
TOTAL_SELL_ORDERS=1 'how many sell orders to place,maximum
MAX_SLIPPAGE=3 'for placing orders only

X________________3="------MACD SETTINGS------"
FAST_MACD_P=5
SLOW_MACD_P=35
SIGNAL_PERIOD=5

X________________4="------TREND FILTER SETTINGS------"

martingale_lot=start_lot

End Sub

''' <summary>
''' The main function is the entry point for any Script program
''' </summary>

Public Sub main()
'''''''''''''''''''''''''-----------START SIGNALS-------''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''\$ nr 1 the moving average rainbow detector

Dim FMA1
FMA1= ExponentialMovingAverage(0,PRICE_CLOSE, 2)
Dim FMA2
FMA2= ExponentialMovingAverage(0,PRICE_CLOSE, 3)
Dim FMA3
FMA3= ExponentialMovingAverage(0,PRICE_CLOSE, 5)
Dim FMA4
FMA4= ExponentialMovingAverage(0,PRICE_CLOSE, 8)
Dim FMA5
FMA5= ExponentialMovingAverage(0,PRICE_CLOSE, 13)
Dim FMA6
FMA6= ExponentialMovingAverage(0,PRICE_CLOSE, 21)
Dim FMA7
FMA7= ExponentialMovingAverage(0,PRICE_CLOSE, 34)
Dim FMA8
FMA8= ExponentialMovingAverage(0,PRICE_CLOSE, 55)
Dim FMA9
FMA9= ExponentialMovingAverage(0,PRICE_CLOSE, 89)
Dim FMA10
FMA10= ExponentialMovingAverage(0,PRICE_CLOSE, 144)
Dim FMA11
FMA11= ExponentialMovingAverage(0,PRICE_CLOSE, 233)

'SLOPE
Dim MACD_Data
MACD_Data =MACD(0,CINT(FAST_MACD_P), CINT(SLOW_MACD_P),CINT(SIGNAL_PERIOD))

'-----------------------------------------------------------------------'
'''''''''''''''''''''''''''''''''''HOLY SIGNAL'''''''''''''''''''''''''''
'-----------------------------------------------------------------------'

If MACD_Data > 0 Then

viaID="NS"
If FMA1>FMA2 AND FMA2>FMA3 AND FMA3>FMA4 AND FMA4>FMA5 AND FMA5>FMA6 AND FMA6>FMA7 AND FMA7>FMA8 AND FMA8>FMA9 AND FMA9>FMA10 AND FMA10>FMA11 AND ADXTREND>ADX_LIMIT_TRIGGER Then
via="B"
End If

End If

'SELL
If MACD_Data <0 Then
viaID="NB"
If FMA1<FMA2 AND FMA2<FMA3 AND FMA3<FMA4 AND FMA4<FMA5 AND FMA5<FMA6 AND FMA6<FMA7 AND FMA7<FMA8 AND FMA8<FMA9 AND FMA9<FMA10 AND FMA10<FMA11 AND ADXTREND>ADX_LIMIT_TRIGGER Then
via="S"
End If
End If
'-- SELL

'-- PRINT DATA
PrintData "-------BUY OR SELL?: ", via
PrintData "-------DECISION?: ", viaID

Dim accountBal
accountBal = AccountInfoDouble(ACCOUNT_BALANCE)
Dim accountEqt
accountEqt = AccountInfoDouble(ACCOUNT_EQUITY)
Dim orderId
Dim bid
' Get Bid value of selected Chart
SymbolInfoDouble ChartSymbol(ChartId()),SYMBOL_BID,bid

'-----------------------------------------------------------------------'
'-----------------------------------------------------------------------'

If via ="B" OR viaID ="NS" OR (((accountBal-accountEqt)*100/accountBal)>MAX_ACCOUNT_RISK) Then

TotalNumberOfOrders = OrdersTotal()
PositionIndex = TotalNumberOfOrders - 1

While PositionIndex >= 0 'while loop to loop through all Orders . . COUNT DOWN TO ZERO !
orderId =OrderGetID(PositionIndex)

If ( NOT OrderSelect(orderId) ) Then
Continue '<-- if the OrderSelect fails advance the loop to the next PositionIndex
End If

If( OrderSymbol() = Symbol(PositionIndex,True) And ( OrderType() = TRADE_ACTION_SELL )) Then
'<-- does the Orders Magic Number match our EAs magic number ?
' <-- is the Order a SELL Order ?
' <-- PROFITABLE OR NOT NO NEED ?

If (NOT CloseMarketOrder( PositionGetTicket(PositionIndex), OrderLots(orderId)) ) Then '<-- try to close the order
PrintData "Order Close failed, order number: " , PositionGetTicket(PositionIndex), " Error: " , GetLastError() ' <-- if the Order Close failed print some helpful information
End If
End If

PositionIndex = PositionIndex - 1
Wend 'end of While loop

End If

'-----------------------------------------------------------------------'
'-----------------------------------------------------------------------'

'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' SELL SIGNAL CODE'''''''''''''''''''''''''''
'-----------------------------------------------------------------------'

accountBal = AccountInfoDouble(ACCOUNT_BALANCE)
accountEqt = AccountInfoDouble(ACCOUNT_EQUITY)

' Get Bid value of selected Chart
SymbolInfoDouble ChartSymbol(ChartId()),SYMBOL_BID,bid

If(via="S" OR viaID ="NB" OR (((accountBal-accountEqt)*100/accountBal)>MAX_ACCOUNT_RISK)) Then

TotalNumberOfOrders = OrdersTotal()
PositionIndex = TotalNumberOfOrders - 1

While PositionIndex >= 0 ' <-- for loop to loop through all Orders . . COUNT DOWN TO ZERO !

orderId =OrderGetID(PositionIndex)

If ( Not OrderSelect(orderId) ) Then
Continue ' <-- if the OrderSelect fails advance the loop to the next PositionIndex
End If

' <-- does the Order's Symbol match the Symbol our EA is working on ?
'<-- is the Order a Buy Order ?
'<-- PROFITABLE O NOT NO NEED?

If (NOT CloseMarketOrder( PositionGetTicket(PositionIndex), OrderLots(orderId)) ) Then '<-- try to close the order
PrintData "Order Close failed, order number: " , PositionGetTicket(PositionIndex), " Error: " , GetLastError()
' <-- if the Order Close failed print some helpful information
END If
End If
PositionIndex = PositionIndex -1
Wend ' end of While loop

End If
'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' END SELL SIGNAL CODE ''''''''''''''''''''''
'-----------------------------------------------------------------------'

'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' MARTINGALE SYSTEM '''' ''''''''''''''''''''
'-----------------------------------------------------------------------'

If(MARTINGALE_ACTIVATOR) Then
Dim lastClose
Dim lastClosePrev
dim i
lastClosePrev = lastClose

For i=1 To OrdersHistoryTotal()

OrderSelect i
If OrderCloseTime() > lastClosePrev And OrderSymbol() = GetPositionSymbol() And (OrderType() = TRADE_ACTION_BUY Or OrderType() = TRADE_ACTION_SELL ) Then
lastClose = OrderCloseTime()

'''''''''''''''''''''''''''''''''''''''''
If(MARTINGALE_PROGRESSION =false) Then
If(OrderProfit()<=0) Then
LEVEL = LEVEL +1 'LOSS
End If
If(OrderProfit()>0) Then
LEVEL=0 'PROFIT CANCEL OUT
End If

If(LEVEL>MARTINGALE_LEVELS) Then
LEVEL=0
End If
start_lot=martingale_lot*MathPow(2,LEVEL)
End If

''''''''''''''''''''''''''''''''''''''''''''''''

If(MARTINGALE_PROGRESSION= True) Then
LEVEL = LEVEL +1
If(LEVEL>MARTINGALE_LEVELS) Then
LEVEL=0
End If
start_lot=martingale_lot*(2^LEVEL)
End If
''''''''''''''''''''''''''''''''''''''''''''''''

Exit For

End If

Next

End If

'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' ORDERS SEND '''''''''' ''''''''''''''''''''
'-----------------------------------------------------------------------'
accountBal = AccountInfoDouble(ACCOUNT_BALANCE)
accountEqt = AccountInfoDouble(ACCOUNT_EQUITY)
Dim positionSymbol
positionSymbol=GetPositionSymbol()

If( via="B" And viaID ="NS" And (OrdersTotal()<TOTAL_BUY_ORDERS) And (((accountBal-accountEqt)*100/accountBal)<MAX_ACCOUNT_RISK)) Then

End If

If( via="S" And viaID="NB" And (OrdersTotal()<TOTAL_SELL_ORDERS) And (((accountBal-accountEqt)*100/accountBal)<MAX_ACCOUNT_RISK)) Then ''''SELL

End If

'-----------------------------------------------------------------------'
'''''''''''''''''''''''''''''END ORDERS SEND ''''''' ''''''''''''''''''''
'-----------------------------------------------------------------------'
MsgBox "LAst"

End Sub

''' <summary>
''' The function is generated when a new tick is received for any symbol
''' </summary>

Public Sub OnTick(symbolName)

End Sub

''' <summary>
''' The function is generated when deinitialization script
''' </summary>

Public Sub OnDeInit()
''''TODO: deinitialization method

End Sub

''' <summary>
''' The OnTimer function called when the timer event occurs
''' </summary>

Public Sub OnTimer()
''''TODO: Timer Function
End Sub

''' <summary>
''' The OnCalculate function called when a new candle received
''' </summary>

Public Sub OnCalculate(symbol, symbolPeriod, openVal, highVal, lowVal, closeVal)

End Sub
''' <summary>
''' </summary>

End Sub
''' <summary>
''' Raise when Account Selected
''' </summary>

Public Sub AccountSelected(accountNumber)

End Sub
''' <summary>
''' Raise when the server returns order result
''' </summary>

Public Sub OnOrderTrade(actionType ,orderID , returnValue)

End Sub
''' <summary>
''' Raise when the server returns position result
''' </summary>

End Sub
''' <summary>
''' Raise when the server returns Manage SL/TP Orders after calling RequestManageOrders method
''' </summary>

End Sub

Hassan-HS
12-10-2013, 09:09 AM
Dear Bharat,

Thank you for your post, you have sent us a full code script, which is out of our policy, can you please be more specific of what do you want me to fix.

bharat.ecb
12-10-2013, 10:19 AM
Hi Sir,

I am getting run time Exception.
How to resolve it?

[VTL Exception] [Code Name: MAGNA RAPAX - COPPER EDITION - BETA] [Method Name: main]: Type mismatch: 'MACD_Data'

Thank you

Hassan-HS
12-10-2013, 11:18 AM
Dear Sir,

I have notice that many compilation errors exist in your script, i have solved it.

Dim start_lot 'order lot size
Dim TAKEPROFITPIPS
Dim STOPLOSSPIPS
Dim MAX_ACCOUNT_RISK
Dim X________________1
Dim MARTINGALE_ACTIVATOR
Dim MARTINGALE_LEVELS
Dim MARTINGALE_PROGRESSION
Dim X________________2
Dim TOTAL_SELL_ORDERS
Dim MAX_SLIPPAGE
Dim X________________3
Dim FAST_MACD_P
Dim SLOW_MACD_P
Dim SIGNAL_PERIOD
Dim X________________4

'Global Variables for internal use
Dim ticket
ticket=0
Dim i
i=1
Dim via
via="X"
Dim viaID
viaID="X"
Dim LEVEL
LEVEL=1
Dim magic
magic=666 'magic number
Dim martingale_lot
martingale_lot=0.01
Dim PositionIndex
Dim TotalNumberOfOrders
Dim slippagex

''' <summary>
''' The function is generated when initialization script
''' </summary>

Public Sub OnInit()

start_lot =0.01 'order lot size
TAKEPROFITPIPS = 99 'take profit in pips
STOPLOSSPIPS=99 'stop loss in pips
MAX_ACCOUNT_RISK=25 'in percent,closes all losing trades if AccountEquity goes below AccountBalance by this amount

X________________1="------MARTINGALE------"
MARTINGALE_ACTIVATOR=false ' wanna use martingale system?
MARTINGALE_LEVELS=5 'what levels to go,ex level 5= 2^5 multiplicator for lot

X________________2="------ORDER SETTINGS------"
TOTAL_SELL_ORDERS=1 'how many sell orders to place,maximum
MAX_SLIPPAGE=3 'for placing orders only

X________________3="------MACD SETTINGS------"
FAST_MACD_P=5
SLOW_MACD_P=35
SIGNAL_PERIOD=5

X________________4="------TREND FILTER SETTINGS------"

martingale_lot=start_lot

End Sub

''' <summary>
''' The main function is the entry point for any Script program
''' </summary>

Public Sub main()
'''''''''''''''''''''''''-----------START SIGNALS-------''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''\$ nr 1 the moving average rainbow detector

Dim FMA1
FMA1= ExponentialMovingAverage(0,PRICE_CLOSE, 2)
Dim FMA2
FMA2= ExponentialMovingAverage(0,PRICE_CLOSE, 3)
Dim FMA3
FMA3= ExponentialMovingAverage(0,PRICE_CLOSE, 5)
Dim FMA4
FMA4= ExponentialMovingAverage(0,PRICE_CLOSE, 8)
Dim FMA5
FMA5= ExponentialMovingAverage(0,PRICE_CLOSE, 13)
Dim FMA6
FMA6= ExponentialMovingAverage(0,PRICE_CLOSE, 21)
Dim FMA7
FMA7= ExponentialMovingAverage(0,PRICE_CLOSE, 34)
Dim FMA8
FMA8= ExponentialMovingAverage(0,PRICE_CLOSE, 55)
Dim FMA9
FMA9= ExponentialMovingAverage(0,PRICE_CLOSE, 89)
Dim FMA10
FMA10= ExponentialMovingAverage(0,PRICE_CLOSE, 144)
Dim FMA11
FMA11= ExponentialMovingAverage(0,PRICE_CLOSE, 233)

'SLOPE
Dim MACD_Data
MACD 0,CINT(12), CINT(14),CINT(9)

'-----------------------------------------------------------------------'
'''''''''''''''''''''''''''''''''''HOLY SIGNAL'''''''''''''''''''''''''''
'-----------------------------------------------------------------------'

If MACD_Data > 0 Then

viaID="NS"
If FMA1>FMA2 AND FMA2>FMA3 AND FMA3>FMA4 AND FMA4>FMA5 AND FMA5>FMA6 AND FMA6>FMA7 AND FMA7>FMA8 AND FMA8>FMA9 AND FMA9>FMA10 AND FMA10>FMA11 AND ADXTREND>ADX_LIMIT_TRIGGER Then
via="B"
End If

End If

'SELL
If MACD_Data <0 Then
viaID="NB"
If FMA1<FMA2 AND FMA2<FMA3 AND FMA3<FMA4 AND FMA4<FMA5 AND FMA5<FMA6 AND FMA6<FMA7 AND FMA7<FMA8 AND FMA8<FMA9 AND FMA9<FMA10 AND FMA10<FMA11 AND ADXTREND>ADX_LIMIT_TRIGGER Then
via="S"
End If
End If
'-- SELL

'-- PRINT DATA
PrintData "-------BUY OR SELL?: ", via
PrintData "-------DECISION?: ", viaID

Dim accountBal
accountBal = AccountInfoDouble(ACCOUNT_BALANCE)
Dim accountEqt
accountEqt = AccountInfoDouble(ACCOUNT_EQUITY)
Dim orderId
Dim bid
' Get Bid value of selected Chart
SymbolInfoDouble ChartSymbol(ChartId()),SYMBOL_BID,bid

'-----------------------------------------------------------------------'
'-----------------------------------------------------------------------'

If via ="B" OR viaID ="NS" OR (((accountBal-accountEqt)*100/accountBal)>MAX_ACCOUNT_RISK) Then

TotalNumberOfOrders = OrdersTotal()
PositionIndex = TotalNumberOfOrders - 1

While PositionIndex >= 0 'while loop to loop through all Orders . . COUNT DOWN TO ZERO !
orderId =OrderGetID(PositionIndex)

If ( NOT OrderSelect(orderId) ) Then
Continue '<-- if the OrderSelect fails advance the loop to the next PositionIndex
End If

If( OrderSymbol() = Symbol(PositionIndex,True) And ( OrderType() = TRADE_ACTION_SELL )) Then
'<-- does the Orders Magic Number match our EAs magic number ?
' <-- is the Order a SELL Order ?
' <-- PROFITABLE OR NOT NO NEED ?

If (NOT CloseMarketOrder( PositionGetTicket(PositionIndex), OrderLots(orderId)) ) Then '<-- try to close the order
PrintData "Order Close failed, order number: " , PositionGetTicket(PositionIndex), " Error: " , GetLastError() ' <-- if the Order Close failed print some helpful information
End If
End If

PositionIndex = PositionIndex - 1
Wend 'end of While loop

End If

'-----------------------------------------------------------------------'
'-----------------------------------------------------------------------'

'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' SELL SIGNAL CODE'''''''''''''''''''''''''''
'-----------------------------------------------------------------------'

accountBal = AccountInfoDouble(ACCOUNT_BALANCE)
accountEqt = AccountInfoDouble(ACCOUNT_EQUITY)

' Get Bid value of selected Chart
SymbolInfoDouble ChartSymbol(ChartId()),SYMBOL_BID,bid

If(via="S" OR viaID ="NB" OR (((accountBal-accountEqt)*100/accountBal)>MAX_ACCOUNT_RISK)) Then

TotalNumberOfOrders = OrdersTotal()
PositionIndex = TotalNumberOfOrders - 1

While PositionIndex >= 0 ' <-- for loop to loop through all Orders . . COUNT DOWN TO ZERO !

orderId =OrderGetID(PositionIndex)

If ( Not OrderSelect(orderId) ) Then
Continue ' <-- if the OrderSelect fails advance the loop to the next PositionIndex
End If

' <-- does the Order's Symbol match the Symbol our EA is working on ?
'<-- is the Order a Buy Order ?
'<-- PROFITABLE O NOT NO NEED?

If (NOT CloseMarketOrder( PositionGetTicket(PositionIndex), OrderLots(orderId)) ) Then '<-- try to close the order
PrintData "Order Close failed, order number: " , PositionGetTicket(PositionIndex), " Error: " , GetLastError()
' <-- if the Order Close failed print some helpful information
END If
End If
PositionIndex = PositionIndex -1
Wend ' end of While loop

End If
'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' END SELL SIGNAL CODE ''''''''''''''''''''''
'-----------------------------------------------------------------------'

'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' MARTINGALE SYSTEM '''' ''''''''''''''''''''
'-----------------------------------------------------------------------'

If(MARTINGALE_ACTIVATOR) Then
Dim lastClose
Dim lastClosePrev
dim i
lastClosePrev = lastClose

For i=1 To OrdersHistoryTotal()

OrderSelect i
If OrderCloseTime() > lastClosePrev And OrderSymbol() = GetPositionSymbol() And (OrderType() = TRADE_ACTION_BUY Or OrderType() = TRADE_ACTION_SELL ) Then
lastClose = OrderCloseTime()

'''''''''''''''''''''''''''''''''''''''''
If(MARTINGALE_PROGRESSION =false) Then
If(OrderProfit()<=0) Then
LEVEL = LEVEL +1 'LOSS
End If
If(OrderProfit()>0) Then
LEVEL=0 'PROFIT CANCEL OUT
End If

If(LEVEL>MARTINGALE_LEVELS) Then
LEVEL=0
End If
start_lot=martingale_lot*MathPow(2,LEVEL)
End If

''''''''''''''''''''''''''''''''''''''''''''''''

If(MARTINGALE_PROGRESSION= True) Then
LEVEL = LEVEL +1
If(LEVEL>MARTINGALE_LEVELS) Then
LEVEL=0
End If
start_lot=martingale_lot*(2^LEVEL)
End If
''''''''''''''''''''''''''''''''''''''''''''''''

Exit For

End If

Next

End If

'-----------------------------------------------------------------------'
''''''''''''''''''''''''''''' ORDERS SEND '''''''''' ''''''''''''''''''''
'-----------------------------------------------------------------------'
accountBal = AccountInfoDouble(ACCOUNT_BALANCE)
accountEqt = AccountInfoDouble(ACCOUNT_EQUITY)
Dim positionSymbol
positionSymbol=GetPositionSymbol()

If( via="B" And viaID ="NS" And (OrdersTotal()<TOTAL_BUY_ORDERS) And (((accountBal-accountEqt)*100/accountBal)<MAX_ACCOUNT_RISK)) Then

End If

If( via="S" And viaID="NB" And (OrdersTotal()<TOTAL_SELL_ORDERS) And (((accountBal-accountEqt)*100/accountBal)<MAX_ACCOUNT_RISK)) Then ''''SELL

End If

'-----------------------------------------------------------------------'
'''''''''''''''''''''''''''''END ORDERS SEND ''''''' ''''''''''''''''''''
'-----------------------------------------------------------------------'
MsgBox "LAst"

End Sub

mixpol
12-21-2013, 08:31 AM
please convert mt4 connorsi to the OEC platform *.el
also i have eld format to conxert to the el
thx forward

mixpol
12-21-2013, 08:34 AM
convert please mt4- el ( oec indicator)
thx

Hassan-HS
12-21-2013, 08:59 AM
Hello Mixpol,

Please do not hesitate to tell us if you want to convert your script to VTL.

alflahali222
03-18-2015, 02:16 PM
heloo any one make expert adviser for me

Hassan-HS
03-19-2015, 08:13 AM
Dear Alflahali222,

You can have your own EA's by developing them over our VTL or APIs either from your developers or with third parties.

If you need to contact third parties easily, you can use our portal VFXLancer.com to post your own projects easily, then you will receive many bids from Freelancers and development companies that have interest in developing your projects, also we will award you 50\$ as a gift from hybrid solutions.