molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Wed May 29, 2024 3:02 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: My first EA using Molanis Software
PostPosted: Tue Apr 03, 2012 10:52 am 
Offline

Joined: Fri Mar 30, 2012 11:58 pm
Posts: 10
In this project i managed to incorporate pyramide trading style in one of the EAs that I created using Molanis software.

I did some additions in the trading conditions and there we go:

Attachment:
Molanis Pyramiding.jpg
Molanis Pyramiding.jpg [ 192.68 KiB | Viewed 3349 times ]


The results with strategy tester (every tick mode) are not bad:

Attachment:
Strategy tester report.jpg
Strategy tester report.jpg [ 101.62 KiB | Viewed 3376 times ]


My knowledge in MQL language is not beyond the very basics but thanks to Molanis I managed to build an EA from scratch!!


Top
 Profile  
 
 Post subject: Re: My first EA using Molanis Software
PostPosted: Tue Apr 03, 2012 2:34 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Great.
If you want to share your work you can post the strategy file (.mol file)
We will add a feature to get the number of open positions in an easier way in the next version. This should make increasing the position easier


Top
 Profile  
 
 Post subject: Re: My first EA using Molanis Software
PostPosted: Wed Apr 04, 2012 5:44 am 
Offline

Joined: Fri Mar 30, 2012 11:58 pm
Posts: 10
Attachment:
pyramiding_v1.0.mol [40.08 KiB]
Downloaded 493 times


The mol file is attached.

Also I am attaching the modifications in the EA below:


Code:
// This module returns pt=1 if open positions are long, pt=-1 if short and pt=0 if no positions are open.

int last_trade=OrdersTotal();
if(last_trade>0)
  {
   if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)
     {
      if (OrderMagicNumber()==35) // This is the magic number for long positions.
      int pt = 1;
      else
      pt = -1;
     }
  }
else
pt=0;
   

// Trading code starts here
if (TradeOrAlert) {
// Check conditions


if (  CONDITIONS FOR CLOSING LONG )
   {  CLOSELONG(Symbol()) ;}


if (pt!=-1&& CONDITIONS FOR OPENING THE FIRST SHORT POSITION)
   {  SELL(Symbol(),S_Symbol_LS_0,...}


if ( CONDITIONS FOR CLOSING SHORT )
   {  CLOSESHORT(Symbol()) ;}



if (pt!=1&&CONDITIONS FOR OPENING THE FIRST LONG POSITION)
   {  BUY(Symbol(),B_Symbol_LS_3,...}



//This module reopens long positions 0.2, 0.4 and 0.8 if profit of open trades is negative (every 40 pips)

if ((   pt==1&&AccountProfit()<-506&&OrdersTotal()==3 )  )
   {  BUY(Symbol(),B_Symbol_LS_0,B_Symbol_TP_0,B_Symbol_SL_0,B_Symbol_TS_0,"i...") ;}
if ((   pt==1&&AccountProfit()<-180&&OrdersTotal()==2 )  )
   {  BUY(Symbol(),B_Symbol_LS_1,B_Symbol_TP_1,B_Symbol_SL_1,B_Symbol_TS_1,"if...") ;}
if ((   pt==1&&AccountProfit()<-50&&OrdersTotal()==1 )  )
   {  BUY(Symbol(),B_Symbol_LS_2,B_Symbol_TP_2,B_Symbol_SL_2,B_Symbol_TS_2,"if ...") ;}

// This module reopens short positions 0.2, 0.4 and 0.8 if profit of open trades is negative (every 40 pips)

if ((   pt==-1&&AccountProfit()<-506&&OrdersTotal()==3 )  )
   {  SELL(Symbol(),S_Symbol_LS_1,S_Symbol_TP_1,S_Symbol_SL_1,S_Symbol_TS_1,"if ...") ;}
if ((   pt==-1&&AccountProfit()<-180&&OrdersTotal()==2 )  ) 
   {  SELL(Symbol(),S_Symbol_LS_2,S_Symbol_TP_2,S_Symbol_SL_2,S_Symbol_TS_2,"if ...") ;}
if ((  pt==-1&&AccountProfit()<-50&&OrdersTotal()==1 )  ) 
   {  SELL(Symbol(),S_Symbol_LS_3,S_Symbol_TP_3,S_Symbol_SL_3,S_Symbol_TS_3,"if ...") ;}


I am sure this was not a very professional way of doing it, but it works!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009