I wrote a code that works in GBP/USD and was trying to test it on EUR/JPY today. but I saw the decimal point was in a different place (so instead of 1.2934 it was 129.34)
I created a param called multiplicationFacotr and just divided by 100 and thought it would work. BUT…
the program totally ignores my stake size requests. no matter what I put there the position size is set to 1 and the amount won/loss is way over the amount I am setting
Here is a short part of the program (I didn’t think it was useful to post it all here). what am I doing wrong?
DEFPARAM CumulateOrders = false
ONCE multiplicationFactor=10000
ONCE startTime = 090000
ONCE endTime = 093000
ONCE stopLoss=0
ONCE entryBuffer=10/multiplicationFactor
ONCE profitState=0
ONCE openProfitLoss=0
ONCE myBarIndex=0
ONCE myBarIndexFlag=0
ONCE maxBarIndex=250
ONCE maxPips=10/multiplicationFactor
ONCE maxLoss = 10/multiplicationFactor
ONCE state=0
// **************** INIT PARAMS SHORT/LONG ***********************/
ONCE stakeSizeShort=0
ONCE stakeSizeLong=0
ONCE shortTriggered = 0
ONCE longTriggered = 0
ONCE stopLimitShort=maxPips
ONCE stopLimitLong=maxPips
ONCE stopLimitBoth = maxPips
// **************** END INIT PARAMS SHORT/LONG ***********************/
IF intradaybarindex=0 THEN
maxprice=0
minprice=100*close
ENDIF
IF time>=startTime AND time<=endTime THEN
maxprice= MAX(maxprice, high)
minprice= MIN(minprice, low)
ENDIF
IF time = endTime THEN
myBuyprice = maxprice +EntryBuffer
mySellprice= minprice -EntryBuffer
stopLoss = myBuyprice - mySellprice
profitState = STRATEGYPROFIT
ENDIF
stakeSizeShort = maxLoss/stopLoss
stakeSizeLong = maxLoss/stopLoss
shortTriggered = 0
longTriggered = 0
openProfitLoss = 0
ENDIF
IF NOT ONMARKET THEN
myBarIndex=0
myBarIndexFlag=0
IF profitState>=STRATEGYPROFIT AND longTriggered=0 THEN
BUY stakeSizeLong CONTRACTS AT myBuyprice stop
SET TARGET PROFIT stopLimitLong
ENDIF
IF profitState>=STRATEGYPROFIT AND shortTriggered=0 THEN
SELLSHORT stakeSizeShort CONTRACTS AT mySellprice stop
SET TARGET PROFIT stopLimitShort
ENDIF
SET STOP LOSS stopLoss
ELSIF ONMARKET THEN
IF SHORTONMARKET THEN
shortTriggered=1
openProfitLoss =tradeprice(1)-low
SET TARGET PROFIT stopLimitShort
ENDIF
IF LONGONMARKET THEN
LongTriggered=1
openProfitLoss = high-tradeprice(1)
SET TARGET PROFIT stopLimitLong
ENDIF
ENDIF
Surely this can’t be correct?
100* a close of (for example) 1.3200 can’t be what you want??
minprice=100*close
This is just setting the min value so that the first low will surely be greater and will replace this value. so it is a temp param to start the min (x,y) function
I will explain in the other thread a bit more about the problem, maybe that would shed some light on the issue.
Thanks again!
I will explain in the other thread a bit more about the problem,
aland – This is a prime example of why double posts on the same subject are frowned upon. Please refrain from double posting with future topics as it just leads to confused and fragmented discussion. If you think your first question has not received any answers because it was maybe not clear enough then a second reply on the same topic to clarify things and to bump it back to the top of the list works far better than double posting.
For anyone reading this in the future and wondering where the other discussion is – it is here:
how to change code between FX markets
I think it is best if everyone posts only there from now.