Download MetaTrader 5

quick question . max lots expert advisor

To add comments, please log in or register
tennisplayer128
31
tennisplayer128  

hi, im trying to code a basic expert advisor . at the top of my code I have written   extern double Lots =100;

so that sets the amount of lots my expert advisor trades with to 100 lots . I want to change this. my question is , how can I code my expert advisor to trade the maximum amount of lots possible on every trade ?

instead of writing extern double Lots =100;  what would I write instead of that ? thank you

whroeder1
15719
whroeder1  

Do that, and blow your account. But if you insist, make sure you don't get a margin call (stop out.)

  • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
  • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip)
  • Do NOT use TickValue by itself - DeltaPerLot
  • You must normalize lots properly and check against min and max.
  • You must also check FreeMargin to avoid stop out
tennisplayer128
31
tennisplayer128  
whroeder1:

Do that, and blow your account. But if you insist, make sure you don't get a margin call (stop out.)

thank you for the response . I know nothing about coding , would I literally just copy and paste this      Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot

instead of writing         extern double Lots =100;

eevviill14
60
eevviill14  
OrderSend(...,MarketInfo(Symbol(),MODE_MAXLOT),...);
whroeder1
15719
whroeder1  
tennisplayer128: . I know nothing about coding , would I literally just copy and paste this      Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot
  1. And apparently nothing about trading Per your question.
  2. And apparently nothing about math - I gave you an equation not code.
  3. Top of every page is Freelance
tennisplayer128
31
tennisplayer128  
eevviill14:
OrderSend(...,MarketInfo(Symbol(),MODE_MAXLOT),...);
thank you for the response . where in my code would I copy and paste this ?
eevviill14
60
eevviill14  
tennisplayer128:
thank you for the response . where in my code would I copy and paste this ?
In OrderSend()
tennisplayer128
31
tennisplayer128  
eevviill14:
In OrderSend()
thank you again . so I just simply copy and paste that simple line of code wherever it says OrderSend and that's all I have to do ? should I delete this line of code extern double Lots =100;   from the top as well ?
eevviill14
60
eevviill14  
tennisplayer128:
thank you again . so I just simply copy and paste that simple line of code wherever it says OrderSend and that's all I have to do ? should I delete this line of code extern double Lots =100;   from the top as well ?

yes

if you want EA to open max lots

you need to set MarketInfo(Symbol(),MODE_MAXLOT) in OrderSend function in places where lot must be. 

To add comments, please log in or register