Coding help with d#8217Alembert Forex EA

thread: Coding help with d#8217Alembert Forex EA

  1. #1
    UnSinsajo
    Guest

    Coding help with d#8217Alembert Forex EA

    Hi all,

    I attempt to code an EA that deal with d'alembert progression (for all that don´t know progression d'alembert: http://www.bettingexpert.com/casino/...lembert-system )

    The plan is to start with 0.01 lots and SL 13 pips / TP 14 pips.

    Every time a trade near with a reduction, a new commerce open instantly with additional 0.01 lots and after a triumph trade next trade open instantly with 0.01 lots less than the lotsize before we arrive at 0.01 lots.


    Instance:

    1. trade 0.01 lots loss

    2. Trade 0.02 lots loss

    3. trade 0.03 lots loss

    4. trade 0.04 lots loss

    5. Trade 0.05 lots win

    6. Trade 0.04 lots win

    7. Trade 0.03 lots win

    8. Trade 0.02 lots win

    9. Trade 0.01 lots win


    So here is my first code attempt but it doesn´t operate from the startegy tester. :--LRB-

    who can assist?


    Inserted Code // ------------------------------------------------------------------ //| A4.mq4 | //| Copyright © 2010, MetaQuotes Software Corp.. | //| http://www.metaquotes.net | // ------------------------------------------------------------------ #property copyright Copyright © 2010, MetaQuotes Software Corp. #property Hyperlink http://www.metaquotes.net // ------------------------------------------------------------------ //| extern input parameters | // ------------------------------------------------------------------ extern int MagicNumber_101=101000; extern int SL=13; extern int TP=14; double dXPoint=1; // ------------------------------------------------------------------ //| expert initialization serve | // ------------------------------------------------------------------ int init() //-- //-- return(0); // ------------------------------------------------------------------ //| expert deinitialization function | // ------------------------------------------------------------------ int deinit() //-- //-- return(0); // ------------------------------------------------------------------ //| expert start function | // ------------------------------------------------------------------ int start() double Lotsize = 0.01; if (OrdersHistoryTotal()gt;=1) OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS); Lotsize = OrderLots(); if (OrderProfit()lt;0 OrdersHistoryTotal()gt;=1) Lotsize = Lotsize 0.01; if (OrderProfit()gt;0 OrdersHistoryTotal()gt;=1 Lotsizegt;=0.02) Lotsize = Lotsize - 0.01; if (OrdersHistoryTotal()lt;1 Minute()==00) OrderSend(Symbol(),OP_BUY,0.01,MarketInfo(Symbol() ,MODE_ASK),2,Bid-SL*Point,Bid TP*Point,buy,MagicNumber_101,0,CLR_NONE); Sleep(120000); if (OrdersTotal()==0 Minute()==00) OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS); if (OrderProfit()gt;0 OrderType()==OP_BUY) OrderSend(Symbol(),OP_BUY,0.01,MarketInfo(Symbol() ,MODE_ASK),2,Bid-SL*Point,Bid TP*Point,buy,MagicNumber_101,0,CLR_NONE); Sleep(120000); if (OrdersTotal()==0 Minute()==00) if (OrderProfit()gt;0 OrderType()==OP_SELL) OrderSend(Symbol(),OP_SELL,0.01,MarketInfo(Symbol( ),MODE_BID),2,Ask SL*Point,Ask-TP*Point,market,MagicNumber_101,0,CLR_NONE); Sleep(120000); if (OrdersTotal()==0 Minute()==00) if (OrderProfit()lt;0 OrderType()==OP_SELL) OrderSend(Symbol(),OP_BUY,0.01,MarketInfo(Symbol() ,MODE_ASK),2,Bid-SL*Point,Bid TP*Point,buy,MagicNumber_101,0,CLR_NONE); Sleep(120000); if (OrdersTotal()==0 Minute()==00) if (OrderProfit()lt;0 OrderType()==OP_BUY) OrderSend(Symbol(),OP_SELL,0.01,MarketInfo(Symbol( ),MODE_BID),2,Ask SL*Point,Ask-TP*Point,market,MagicNumber_101,0,CLR_NONE); Sleep(120000); return(0);
    Please no comments just like Blow your account away. . .blabla
    Just sharing a trading egy.

    Regards.

  2. #2
    UnSinsajo
    Guest
    Hello rockit,

    thanks! Can this mql5-Code?

    Regards.

  3. #3
    IV
    Guest
    No, this is official MQL4 since MT4 build 600 (currently 755).
    Another style is depreed and should not be used anymore. It is limiting anyhow.

  4. #4
    UnSinsajo
    Guest
    Hi rockit,

    the code works fine Despite the fact That Each new Commerce has to be Started with the trend, that means:

    - if a long Transaction closes with profit, next Commerce is a long trade
    - if a long Transaction closes loss, next Commerce is a short trade
    - if Your short trade closes profit, next trade is a short trade
    - if Your short trade closes loss, next Commerce is a long trade

    Regards and many thanks in advance

  5. #5
    UnSinsajo
    Guest
    Hi rockit,

    I Believe I fixed it...

    Inserted Code { if(OrderSelect(0, SELECT_BY_POS)) return; OrderSelect(ticket, SELECT_BY_TICKET); if(OrderProfit() lt; 0.0) lot = 0.01; if (OrderType()==OP_BUY) ticket = OrderSend(Symbol(), OP_SELL, lot, Bid, 2, Bid SL*Point, Bid-TP*Stage ); if (OrderType()==OP_SELL) ticket = OrderSend(Symbol(), OP_BUY, lot, Ask, 2, Ask-SL*Point, Ask TP*Stage ); else if(lot gt; 0.01) lot -= 0.01; if (OrderType()==OP_SELL) ticket = OrderSend(Symbol(), OP_SELL, lot, Bid, 2, Bid SL*Point, Bid-TP*Stage ); if (OrderType()==OP_BUY) ticket = OrderSend(Symbol(), OP_BUY, lot, Ask, 2, Ask-SL*Point, Ask TP*Stage );
    Many thanks for your support!

  6. #6
    IV
    Guest
    Try this (from the tester that is. .) :

    Inserted Code #property strict input int SL = 130; enter int TP = 140; dual lot = 0.01; int ticket; int OnInit() ticket = OrderSend(Symbol(), OP_BUY, lot, Ask, two, Ask-SL*Point, Ask TP*Stage ); if(ticket gt; -1) return INIT_SUCCEEDED; reunite INIT_FAILED; void OnTick() if(OrderSelect(0, SELECT_BY_POS)) return; OrderSelect(ticket, SELECT_BY_TICKET); should (OrderProfit() lt; 0.0) lot = 0.01; ticket = OrderSend(Symbol(), OP_SELL, lot, Bid, two, Bid SL*Point, Bid-TP*Stage ); else if(lot gt; 0.01) lot -= 0.01; ticket = OrderSend(Symbol(), OP_BUY, lot, Ask, two, Ask-SL*Point, Ask TP*Stage );

  •