Hi. I’ve edited some code I found on here to create a simple initial balance indicator “Balance 15m NASDAQ”. See below.
//15 min Time frame
//Initial Ballance calculation
//First Hour in the morning form 8:00-9:00 GMT+1 on DAX
starttime = 143000
endtime = 153000
If Time = endtime then
upper=highest[4](high)
lower=lowest[4](low)
dif=round(abs(lower-upper))
endif
RETURN dif
I want to use the following code as another condition before entering a trade
//Initial balance
myBalance15mNASDAQ = CALL “Balance 15m NASDAQ”
c9 = (myBalance15mNASDAQ <50)
But when I back test the results are unaffected? Even when I change to <5 for example?
What am I doing wrong please?
Tried it like this too, same result?
//Initial balance
myBalance15mNASDAQ = CALL “Balance 15m NASDAQ”
//Conditions to enter long positions
indicator1 = ExponentialAverage[7.8](close)
indicator2 = ExponentialAverage[12.6](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 AND myBalance15mNASDAQ <50 AND not daysForbiddenEntry THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF
My code works fine.
Indicator:
// MyInd indicator
//15 min Time frame
//Initial Ballance calculation
//First Hour in the morning form 8:00-9:00 GMT+1 on DAX
starttime = 143000
endtime = 153000
If Time = endtime then
upper=highest[4](high)
lower=lowest[4](low)
dif=round(abs(lower-upper))
endif
RETURN dif
Strategy:
//Initial balance
myBalance15mNASDAQ = CALL "MyInd"
//Conditions to enter long positions
indicator1 = ExponentialAverage[7.8](close)
indicator2 = ExponentialAverage[12.6](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 AND myBalance15mNASDAQ <50 AND not OnMarket THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF
set target pProfit 100
set stop ploss 100
graph myBalance15mNASDAQ
I think your code actually opened a trade, but it was left open as no SL or TP were planned (test it again and check among opened orders).
Adding SL and TP should work it out.
Thank you.
Did you have to change anything? I’ll have a go at inserting your code tomorrow. This is only a section of the code, I have a SL set and exit parameters too further down.
Thanks again I really appreciate this, I’m very new to this with lots to learn .
I’ve got it working as part of my algo now. I’m not sure why it wasn’t working originally? Must have been syntax?
Thanks again.
Hi there,
I’ve tried a very close piece of code, but can’t manage to open a position. It might be easy however. Any adea ? thanks for your help.
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
//Settings
once IBup=0
once IBdown=0
starttime = 080500
endtime = 090000
If Time = endtime then
IBup = highest[12](high)
IBdown = lowest[12](low)
IBdif = IBup - IBdown
IBp100 = IBup + IBdif
IBp200 = IBup + IBdif + IBdif
IBm100 = IBdown - IBdif
IBm200 = IBdown - IBdif - IBdif
Endif
If not onmarket and time >=090500 and Time <=153000 and close CROSSES OVER IBup then
BUY 1 CONTRACT AT MARKET
SET STOP LOSS IBdif
SET TARGET PROFIT IBdif
ENDIF
Everything looks ok to me. Maybe try removing the “>=090500 and Time <=153000″ and maybe use “close > IBup” instead of “close CROSSES OVER IBup”
I’m very new to this, so this is my best guess.