Hi Guys,
Looking for some coding help…. I’m interested in developing a code which:
- Can be switched on / off for a chosen market
- Once on, creates a limit order fixed to a moving average, limit to sell/buy at touch of MA +/- 1 tick/point.
- Limit order to auto calculate trade size based on following factors: Account balance, risk %, 1 ATR ie:
- Account balance eg 10,000
- Risk 1% account balance ie 100
- 1 ATR of market eg 580 points
- Trade size = $10,000 * 1% = $100 / 580 points = 0.17 lots
- Limit order will run until switched off, ie each day will recalculate the resting limit order based on today’s account balance, MA value and ATR value
Is this possible in the ProRealtime autotrade environment?
M
There you go (for the Daily TF):
DEFPARAM CumulateOrders = false
TradeON = 1 //1=on, 0=off
MinLotti= 0.5 //0.5 Minimun lot size
Capital = 10000
Balance = Capital + StrategyProfit
Risk = 1 //1% risk
Offset = 1 * pipsize
Entry = average[30,0](close)
EntryL = Entry + Offset
EntryS = Entry - Offset
MyATR = AverageTrueRange[14](close)
LotSize = max(MinLotti,(Balance * Risk / 100) / MyATR)
IF OnMarket THEN
Entry = 0
EntryL = 0
EntryS = 0
ENDIF
IF Not OnMarket AND TradeON THEN
IF close > EntryL THEN
BUY LotSize CONTRACTS AT EntryL LIMIT
ELSE
BUY LotSize CONTRACTS AT EntryL STOP
ENDIF
IF close > EntryS THEN
SELLSHORT LotSize CONTRACTS AT EntryS STOP
ELSE
SELLSHORT LotSize CONTRACTS AT EntryS LIMIT
ENDIF
ENDIF
SET TARGET pPROFIT 300
SET STOP pLOSS 100