Please help me to make this EA open one position only.I only want it to open one position with TP and SL set at 500point

 
#include <Trade/Trade.mqh>

int handle;

CTrade trade;

int OnInit(){
 
   string name = "Market\\Dark Point MT5.ex5" ;
   handle = iCustom(_Symbol,PERIOD_CURRENT,name);
   
   return(INIT_SUCCEEDED);
 }

void OnDeinit(const int reason){

}

void OnTick(){

   double indiSell1[];
   CopyBuffer(handle,1,1,1,indiSell1);
   if(indiSell1[0]>0)
    trade.Sell(0.2);
   
   double indiSellB1[];
   CopyBuffer(handle,3,1,1,indiSellB1);
   
   double indiSell2[];
   CopyBuffer(handle,5,1,1,indiSell2);
   
   double indiSellB2[];
   CopyBuffer(handle,7,1,1,indiSellB2);
   
   double indiSell3[];
   CopyBuffer(handle,7,1,1,indiSell3);
   
   double indiSellB3[];
   CopyBuffer(handle,9,1,1,indiSellB3);
   
   double indiBuy1[];
   CopyBuffer(handle,0,1,1,indiBuy1);
   
   double indiBuyB1[];
   CopyBuffer(handle,2,1,1,indiBuyB1);
   
   double indiBuy2[];
   CopyBuffer(handle,4,1,1,indiBuy2);
   
   double indiBuyB2[];
   CopyBuffer(handle,6,1,1,indiBuyB2);
   
   double indiBuy3[];
   CopyBuffer(handle,8,1,1,indiBuy3);
   
   double indiBuyB3[];
   CopyBuffer(handle,11,1,1,indiBuyB3);
   
   
   Comment("\nIndi indiSell1: ",indiSell1[0],
           "\nIndi indiSellB1: ",indiSellB1[0],
           "\nIndi indiSell2: ",indiSell2[0],
           "\nIndi indiSellB2: ",indiSellB2[0],
           "\nIndi indiSell3: ",indiSell3[0],
           "\nIndi indiSellB3: ",indiSellB3[0],
           "\nIndi indiBuy1: ",indiBuy1[0],
           "\nIndi indiBuyB1: ",indiBuyB1[0],
           "\nIndi indiBuy2: ",indiBuy2[0],
           "\nIndi indiBuyB2: ",indiBuyB2[0],
           "\nIndi indiBuy3: ",indiBuy3[0],
           "\nIndi indiBuyB3: ",indiBuyB3[0]);
  }
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


 
watson mulenga: Please help me … I only want it …
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
              No free help (2017)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help (2017)

 
dSergey Golubev #:

thanks for the tip I have edited sir

 
William Roeder #:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
              No free help (2017)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help (2017)

I am learning how to do this. Honestly I cant afford money to pay a coder to do it for me. I cant even afford 10 usd to fund for trading. I am poor bro but this idea if it works it can take me somewhere..Any help yall can provide will be appreciated
 
modify my code to open one position ony
Files:
Capture.PNG  106 kb
 
why not trade.Sell only if there's no open position?
 
watson mulenga:
if(indiSell1[0]>0 && PositionsTotal()==0) 
  trade.Sell(0.2);
 
_MAHA_ #:

thanks alot it worked sir

Reason: