BUY FXO Forum Shares
1316
Shares in the BANK:
We BuyWe Sell
$1.8773$1.9354
Results 1 to 10 of 10

Thread: cara biki take profit yang berbeda

  1. #1
    yanti1
    Guest

    Default cara biki take profit yang berbeda

    tolong para master cara bikin tp yang berbeda di ea, khususnya pak abiyanto, saya pake Multi_Lot_Scalper Alejandro Galindo.
    jadi saya ingin untuk posisi pertama tp nya = 8
    untuk posisi selanjutnya kedua, ketiga dan selanjutnya = 30,

    scripnya yang aslinya

    extern double TakeProfit = 40;
    extern double Lots = 0.01;
    extern double InitialStop = 0;
    extern double TrailingStop = 20;

    extern int MaxTrades=10;
    extern int Pips=15;
    extern int SecureProfit=10;
    extern int AccountProtection=1;
    extern int OrderstoProtect=3;
    extern int ReverseCondition=0;
    extern double EURUSDPipValue=10;
    extern double GBPUSDPipValue=10;
    extern double USDCHFPipValue=10;
    extern double USDJPYPipValue=9.715;
    extern int StartYear=2005;
    extern int StartMonth=1;
    extern int EndYear=2006;
    extern int EndMonth=12;
    extern int EndHour=22;
    extern int EndMinute=30;
    extern int mm=0;
    extern int risk=12;
    extern int AccountisNormal=0;

    int OpenOrders=0, cnt=0;
    int slippage=5;
    double sl=0, tp=0;
    double BuyPrice=0, SellPrice=0;
    double lotsi=0, mylotsi=0;
    int mode=0, myOrderType=0;
    bool ContinueOpening=True;
    double LastPrice=0;
    int PreviousOpenOrders=0;
    double Profit=0;
    int LastTicket=0, LastType=0;
    double LastClosePrice=0, LastLots=0;
    double Pivot=0;
    double PipValue=0;
    string text="", text2="";

    bool result;

    //+------------------------------------------------------------------+
    //| expert initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //----

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

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //----
    if (AccountisNormal==1)
    {
    if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000); }
    else { lotsi=Lots; }
    } else { // then is mini
    if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000)/10; }
    else { lotsi=Lots; }
    }
    lotsi=NormalizeDouble(lotsi,2);

    if (lotsi>100){ lotsi=100; }

    OpenOrders=0;
    for(cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol()==Symbol())
    {
    OpenOrders++;
    }
    }

    if (OpenOrders<1)
    {
    if (TimeYear(CurTime())<StartYear) { return(0); }
    if (TimeMonth(CurTime())<StartMonth) { return(0); }
    if (TimeYear(CurTime())>EndYear) { return(0); }
    if (TimeMonth(CurTime())>EndMonth ) { return(0); }
    }

    if (Symbol()=="EURUSD") { PipValue=EURUSDPipValue; }
    if (Symbol()=="GBPUSD") { PipValue=GBPUSDPipValue; }
    if (Symbol()=="USDJPY") { PipValue=USDJPYPipValue; }
    if (Symbol()=="USDCHF") { PipValue=USDCHFPipValue; }
    if (PipValue==0) { PipValue=5; }

    if (PreviousOpenOrders>OpenOrders)
    {
    for(cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    mode=OrderType();
    if (OrderSymbol()==Symbol())
    {
    if (mode==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Blue); }
    if (mode==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Red); }
    return(0);
    }
    }
    }

    PreviousOpenOrders=OpenOrders;
    if (OpenOrders>=MaxTrades)
    {
    ContinueOpening=False;
    } else {
    ContinueOpening=True;
    }

    if (LastPrice==0)
    {
    for(cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    mode=OrderType();
    if (OrderSymbol()==Symbol())
    {
    LastPrice=OrderOpenPrice();
    if (mode==OP_BUY) { myOrderType=2; }
    if (mode==OP_SELL) { myOrderType=1; }
    }
    }
    }

    if (OpenOrders<1)
    {
    myOrderType=3;
    //if (iMACD(14,26,9,MODE_MAIN,0)>0 and iMACD(14,26,9,MODE_MAIN,0)>iMACD(14,26,9,MODE_MAIN,1)) then OrderType=2;
    if (iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) { myOrderType=2; }
    //if (iMACD(14,26,9,MODE_MAIN,0)<0 and iMACD(14,26,9,MODE_MAIN,0)<iMACD(14,26,9,MODE_MAIN,1)) then OrderType=1;
    if (iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)<iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) { myOrderType=1; }
    if (ReverseCondition==1)
    {
    if (myOrderType==1) { myOrderType=2; }
    else { if (myOrderType==2) { myOrderType=1; } }
    }
    }

    // if we have opened positions we take care of them
    for(cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol() == Symbol())
    {
    if (OrderType()==OP_SELL)
    {
    if (TrailingStop>0)
    {
    if (OrderOpenPrice()-Ask>=(TrailingStop+Pips)*Point)
    {
    if (OrderStopLoss()>(Ask+Point*TrailingStop))
    {
    result=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderClosePrice()-TakeProfit*Point-TrailingStop*Point,800,Purple);
    if ( result==false ) Comment("bad ticket=",OrderTicket());
    return(0);
    }
    }
    }
    }

    if (OrderType()==OP_BUY)
    {
    if (TrailingStop>0)
    {
    if (Bid-OrderOpenPrice()>=(TrailingStop+Pips)*Point)
    {
    if (OrderStopLoss()<(Bid-Point*TrailingStop))
    {
    result=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderClosePrice()+TakeProfit*Point+TrailingStop*Point,800,Yellow);
    if ( result==false ) Comment("bad ticket=",OrderTicket());
    return(0);
    }
    }
    }
    }

    }
    }

    Profit=0;
    LastTicket=0;
    LastType=0;
    LastClosePrice=0;
    LastLots=0;
    for(cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol()==Symbol())
    {
    LastTicket=OrderTicket();
    if (OrderType()==OP_BUY) { LastType=OP_BUY; }
    if (OrderType()==OP_SELL) { LastType=OP_SELL; }
    LastClosePrice=OrderClosePrice();
    LastLots=OrderLots();
    if (LastType==OP_BUY)
    {
    //Profit=Profit+(Ord(cnt,VAL_CLOSEPRICE)-Ord(cnt,VAL_OPENPRICE))*PipValue*Ord(cnt,VAL_LOTS);
    if (OrderClosePrice()<OrderOpenPrice())
    { Profit=Profit-(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }
    if (OrderClosePrice()>OrderOpenPrice())
    { Profit=Profit+(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }
    }
    if (LastType==OP_SELL)
    {
    //Profit=Profit+(Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))*PipValue*Ord(cnt,VAL_LOTS);
    if (OrderClosePrice()>OrderOpenPrice())
    { Profit=Profit-(OrderClosePrice()-OrderOpenPrice())*OrderLots()/Point; }
    if (OrderClosePrice()<OrderOpenPrice())
    { Profit=Profit+(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; }
    }
    //Print(Symbol,":",Profit,",",LastLots);
    }
    }

    Profit=Profit*PipValue;
    text2="Profit: $"+DoubleToStr(Profit,2)+" +/-";
    if (OpenOrders>=(MaxTrades-OrderstoProtect) && AccountProtection==1)
    {
    //Print(Symbol,":",Profit);
    if (Profit>=SecureProfit)
    {
    OrderClose(LastTicket,LastLots,LastClosePrice,slippage,Yellow);
    ContinueOpening=False;
    return(0);
    }
    }

    if (!IsTesting())
    {
    if (myOrderType==3) { text="No conditions to open trades"; }
    else { text=" "; }
    Comment("LastPrice=",LastPrice," Previous open orders=",PreviousOpenOrders,"\nContinue opening=",ContinueOpening," OrderType=",myOrderType,"\n",text2,"\nLots=",lotsi,"\n",text);
    }

    if (myOrderType==1 && ContinueOpening)
    {
    if ((Bid-LastPrice)>=Pips*Point || OpenOrders<1)
    {
    SellPrice=Bid;
    LastPrice=0;
    if (TakeProfit==0) { tp=0; }
    else { tp=SellPrice-TakeProfit*Point; }
    if (InitialStop==0) { sl=0; }
    else { sl=SellPrice+InitialStop*Point; }
    if (OpenOrders!=0)
    {
    mylotsi=lotsi;
    for(cnt=1;cnt<=OpenOrders;cnt++)
    {
    if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*1.5,2); }
    else { mylotsi=NormalizeDouble(mylotsi*2,2); }
    }
    } else { mylotsi=lotsi; }
    if (mylotsi>100) { mylotsi=100; }
    OrderSend(Symbol(),OP_SELL,mylotsi,SellPrice,slippage,sl,tp,NULL,0,0,Red);
    return(0);
    }
    }

    if (myOrderType==2 && ContinueOpening)
    {
    if ((LastPrice-Ask)>=Pips*Point || OpenOrders<1)
    {
    BuyPrice=Ask;
    LastPrice=0;
    if (TakeProfit==0) { tp=0; }
    else { tp=BuyPrice+TakeProfit*Point; }
    if (InitialStop==0) { sl=0; }
    else { sl=BuyPrice-InitialStop*Point; }
    if (OpenOrders!=0) {
    mylotsi=lotsi;
    for(cnt=1;cnt<=OpenOrders;cnt++)
    {
    if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*1.5,2); }
    else { mylotsi=NormalizeDouble(mylotsi*2,2); }
    }
    } else { mylotsi=lotsi; }
    if (mylotsi>100) { mylotsi=100; }
    OrderSend(Symbol(),OP_BUY,mylotsi,BuyPrice,slippage,sl,tp,NULL,0,0,Blue);
    return(0);
    }
    }

    //----
    return(0);
    }
    //+------------------------------------------------------------------+

  2. #2
    Intraday Master abiyanto's Avatar
    Join Date
    Apr 2008
    Location
    Semarang, Indonesia
    Posts
    342
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Waduh ....

    Quote Originally Posted by yanti1 View Post
    tolong para master cara bikin tp yang berbeda di ea, khususnya pak abiyanto, saya pake Multi_Lot_Scalper Alejandro Galindo.
    jadi saya ingin untuk posisi pertama tp nya = 8
    untuk posisi selanjutnya kedua, ketiga dan selanjutnya = 30,
    Waduh... saya nubi kok ditanyain EA...
    Coba gini aja deh...

    Pertama code:
    Code:
    if (TakeProfit==0) { tp=0; }
    else { tp=SellPrice-TakeProfit*Point; }
    Dihapus dulu.

    Terus dipindah / diubah di bawah:
    Code:
    for(cnt=1;cnt<=OpenOrders;cnt++)
    {
    
     if (cnt==1 && TakeProfit>0) {TakeProfit==8} else {TakeProfit==30}
    if (TakeProfit==0) { tp=0; }
    else { tp=SellPrice-TakeProfit*Point; } 
    
    if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*1.5,2); }
    else { mylotsi=NormalizeDouble(mylotsi*2,2); }
    }
    } else { mylotsi=lotsi; }
    if (mylotsi>100) { mylotsi=100; }
    OrderSend(Symbol(),OP_SELL,mylotsi,SellPrice,slipp age,sl,tp,NULL,0,0,Red);
    return(0);
    }
    }
    Itu code untuk SELL nya.
    Nah yang untuk BUY bisa ubah sendiri seperti contoh di atas kan ?
    • Forex Trading is 10% skills and 90% psychological
    • Forex Trading is about keeping your losses small and letting your profit runs
    • Risk comes from NOT knowing what you are doing

  3. #3
    In Profit BayiFX's Avatar
    Join Date
    Dec 2008
    Posts
    131
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ikutan belajar yach master ...



    _____________________
    Belajar dari nol hingga nol

  4. #4
    Intraday Master abiyanto's Avatar
    Join Date
    Apr 2008
    Location
    Semarang, Indonesia
    Posts
    342
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Belajar Bersama

    Quote Originally Posted by BayiFX View Post
    Ikutan belajar yach master ...
    Mari kita belajar bersama.....
    Saya juga nggak ngerti banyak-2
    • Forex Trading is 10% skills and 90% psychological
    • Forex Trading is about keeping your losses small and letting your profit runs
    • Risk comes from NOT knowing what you are doing

  5. #5
    Elder Analyst
    Join Date
    Apr 2008
    Posts
    931
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wink

    Bantu dikit ya....

    kan uda ada variabel TakeProfitnya,

    jadi set
    extern double TakeProfit = 8;

    sayang kalo kaga dipake jadinya begini...


    for(cnt=1;cnt<=OpenOrders;cnt++)
    {

    if (cnt>1 && TakeProfit>0) {TakeProfit==30}

    if (TakeProfit==0) { tp=0; }
    else { tp=SellPrice-TakeProfit*Point; }

    if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*1.5,2); }
    else { mylotsi=NormalizeDouble(mylotsi*2,2); }
    }
    } else { mylotsi=lotsi; }
    if (mylotsi>100) { mylotsi=100; }
    OrderSend(Symbol(),OP_SELL,mylotsi,SellPrice,slipp age,sl,tp,NULL,0,0,Red);
    return(0);
    }
    }
    ngubah-ngubah dikit punya bro.abi he...he...he...

    mudah-mudahan bener ya....

  6. #6
    Intraday Master abiyanto's Avatar
    Join Date
    Apr 2008
    Location
    Semarang, Indonesia
    Posts
    342
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Master EA

    Quote Originally Posted by tcl View Post
    Bantu dikit ya....
    kan uda ada variabel TakeProfitnya,
    jadi set
    extern double TakeProfit = 8;
    sayang kalo kaga dipake jadinya begini...

    ngubah-ngubah dikit punya bro.abi he...he...he...
    mudah-mudahan bener ya....
    Akhirnya datang juga ......


    Master EA akhirnya turun gunung juga .... hahaha.....
    Terima kasih atas petunjuknya, Master tcl
    • Forex Trading is 10% skills and 90% psychological
    • Forex Trading is about keeping your losses small and letting your profit runs
    • Risk comes from NOT knowing what you are doing

  7. #7
    Elder Analyst
    Join Date
    Apr 2008
    Posts
    931
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by abiyanto View Post
    Akhirnya datang juga ......


    Master EA akhirnya turun gunung juga .... hahaha.....
    Terima kasih atas petunjuknya, Master tcl
    ha..ha...ha...

    turun gunung.... cape tau ...

    master, .... master dari mana?? orang cuma "nebeng" codingnya bro.abi juga kok... he...he..he...

  8. #8
    In Profit
    Join Date
    Oct 2008
    Posts
    112
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by yanti1 View Post
    tolong para master cara bikin tp yang berbeda di ea, khususnya pak abiyanto, saya pake Multi_Lot_Scalper Alejandro Galindo.
    jadi saya ingin untuk posisi pertama tp nya = 8
    untuk posisi selanjutnya kedua, ketiga dan selanjutnya = 30,
    tolong ada penjelasan sedikit cara buat EA
    Last edited by autodel; 01-30-2009 at 01:56 AM.

  9. #9
    In Profit ef2122's Avatar
    Join Date
    Oct 2008
    Posts
    109
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Mbok kalo bisa dijelasin step by step, maksudnya line per line, jadi yang nubie kaya saya ini mudah ngerti. Sebenarnya apa sih yang dibuat itu.... cara kerjane bagaimana.... Lumayan kan.... semua jadi tahu dan mengerti.
    Kita tidak akan pernah menemukan model yang sempurna untuk menganalisis resiko.

  10. #10
    Intraday Master abiyanto's Avatar
    Join Date
    Apr 2008
    Location
    Semarang, Indonesia
    Posts
    342
    FXO Shares
    0
    FXO Bonus
    0.000
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Prosedur dalam EA

    Quote Originally Posted by ef2122 View Post
    Mbok kalo bisa dijelasin step by step, maksudnya line per line, jadi yang nubie kaya saya ini mudah ngerti. Sebenarnya apa sih yang dibuat itu.... cara kerjane bagaimana.... Lumayan kan.... semua jadi tahu dan mengerti.
    Hehehe.... saya juga nggak begitu ngerti coding EA bro....

    Tapi kalau nggak salah dalam EA - sama spt program - itu ada yang disebut prosedur. Prosedur ini berisi "pekerjaan-2" yg akan dilakukan oleh EA. Prosedur utaman dalam EA antara lain :
    • init() : prosedur yg dijalankan saat EA dipasang ke chart
    • start() : prosedur yg dijalankan EA secara berulang-2 setelah dipasang ke chart
    • deinit() : prosedur yg dijalankan saat EA dilepas dari chart / dihentikan
    Jadi cara membaca "apa yg dilakukan" EA juga mengikuti urutan di atas.
    Yg paling perlu kita perhatikan adalah start() karena ini yg dijalankan secara berulang oleh EA. Biasanya urutan kerjanya :
    • Mendefiniskan variabel
    • Membaca parameter indikator
    • Menentukan buy/sell berdasarkan parameter indikator
    Selain prosedur standar di atas, kita juga bisa membuat prosedur sendiri yg bisa dipanggil dari prosedur standar.

    Selalin prosedur, ada juga yang disebut fungsi. Bedanya, kalau prosedur menghasilkan pekerjaan, kalau fungsi menghasilkan nilai.
    Sorry, cuman itu yg saya tahu bro.... Semoga bermanfaat.

    Salam profit.
    • Forex Trading is 10% skills and 90% psychological
    • Forex Trading is about keeping your losses small and letting your profit runs
    • Risk comes from NOT knowing what you are doing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Disclaimer
2005-2017 © FXOpen All rights reserved. Various trademarks held by their respective owners.

Risk Warning:: Trading on the Forex market involves substantial risks, including complete possible loss of funds and other losses and is not suitable for all members. Clients should make an independent judgment as to whether trading is appropriate for them in the light of their financial condition, investment experience, risk tolerance and other factors.

FXOpen Markets Limited, a company duly registered in Nevis under the company No. C 42235. FXOpen is a member of The Financial Commission.

FXOpen AU Pty Ltd., a company authorised and regulated by the Australian Securities & Investments Commission (ASIC). AFSL 412871ABN 61 143 678 719.

FXOpen Ltd. a company registered in England and Wales under company number 07273392 and is authorised and regulated by the Financial Conduct Authority (previously, the Financial Services Authority) under FCA firm reference number 579202.

FXOpen does not provide services for United States residents.

Join us