using floating point in FX markets?
Forums › ProRealTime English forum › ProOrder support › using floating point in FX markets?
- This topic has 3 replies, 3 voices, and was last updated 6 years ago by
Vonasi.
-
-
02/18/2019 at 7:49 PM #91679
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?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293DEFPARAM CumulateOrders = falseONCE multiplicationFactor=10000ONCE startTime = 090000ONCE endTime = 093000ONCE stopLoss=0ONCE entryBuffer=10/multiplicationFactorONCE profitState=0ONCE openProfitLoss=0ONCE myBarIndex=0ONCE myBarIndexFlag=0ONCE maxBarIndex=250ONCE maxPips=10/multiplicationFactorONCE maxLoss = 10/multiplicationFactorONCE state=0// **************** INIT PARAMS SHORT/LONG ***********************/ONCE stakeSizeShort=0ONCE stakeSizeLong=0ONCE shortTriggered = 0ONCE longTriggered = 0ONCE stopLimitShort=maxPipsONCE stopLimitLong=maxPipsONCE stopLimitBoth = maxPips// **************** END INIT PARAMS SHORT/LONG ***********************/IF intradaybarindex=0 THENmaxprice=0minprice=100*closeENDIFIF time>=startTime AND time<=endTime THENmaxprice= MAX(maxprice, high)minprice= MIN(minprice, low)ENDIFIF time = endTime THENmyBuyprice = maxprice +EntryBuffermySellprice= minprice -EntryBufferstopLoss = myBuyprice - mySellpriceprofitState = STRATEGYPROFITENDIFstakeSizeShort = maxLoss/stopLossstakeSizeLong = maxLoss/stopLossshortTriggered = 0longTriggered = 0openProfitLoss = 0ENDIFIF NOT ONMARKET THENmyBarIndex=0myBarIndexFlag=0IF profitState>=STRATEGYPROFIT AND longTriggered=0 THENBUY stakeSizeLong CONTRACTS AT myBuyprice stopSET TARGET PROFIT stopLimitLongENDIFIF profitState>=STRATEGYPROFIT AND shortTriggered=0 THENSELLSHORT stakeSizeShort CONTRACTS AT mySellprice stopSET TARGET PROFIT stopLimitShortENDIFSET STOP LOSS stopLossELSIF ONMARKET THENIF SHORTONMARKET THENshortTriggered=1openProfitLoss =tradeprice(1)-lowSET TARGET PROFIT stopLimitShortENDIFIF LONGONMARKET THENLongTriggered=1openProfitLoss = high-tradeprice(1)SET TARGET PROFIT stopLimitLongENDIFENDIF02/20/2019 at 9:13 PM #9186902/21/2019 at 12:35 AM #91889This 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!
02/21/2019 at 9:13 AM #91897I 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:
https://www.prorealcode.com/topic/how-to-change-code-between-fx-markets/
I think it is best if everyone posts only there from now.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on