Download MetaTrader 5
To add comments, please log in or register
Publish your task in Freelance service and developers will execute your order.
tennisplayer128
17
tennisplayer128 2016.11.23 02:49 

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
13605
whroeder1 2016.11.23 15:14  

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
17
tennisplayer128 2016.11.25 03:56  
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
71
eevviill14 2016.11.25 11:03  
OrderSend(...,MarketInfo(Symbol(),MODE_MAXLOT),...);
whroeder1
13605
whroeder1 2016.11.25 13:04  
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
17
tennisplayer128 2016.11.28 03:26  
eevviill14:
OrderSend(...,MarketInfo(Symbol(),MODE_MAXLOT),...);
thank you for the response . where in my code would I copy and paste this ?
eevviill14
71
eevviill14 2016.11.28 10:30  
tennisplayer128:
thank you for the response . where in my code would I copy and paste this ?
In OrderSend()
tennisplayer128
17
tennisplayer128 2016.12.02 04:47  
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
71
eevviill14 2016.12.02 09:25  
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