how to change code between FX markets

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #91829 quote
    aland
    Participant
    Average

    I created a code for GBP/USD pair that works fine.

    When trying to migrate it to EUR/JPY I encountered a weird problem.

    GBP/USD uses 1.XXXXX format

    EUR/JPY uses 1YY.YYYYY format

    I was able to change all the params by simple multiplying by 100. no big deal.

    But I can’t control the position size, and once it gets below 1 it automatically defaults to the value 1.

    So currently every trade I make risks 30,000 Yuan, for example, instead of just 300 yuan for example.

    Does anyone have similar experience and could help me decipher this

    Thanks,

     

     

    (I tried writing about it yesterday but must of over complicated it. see the thread below:

    using floating point in FX markets?


    )

    #91831 quote
    GraHal
    Participant
    Master

    Have you tried using pipsize / pointsize at appropriate places in your code?

    Easiest to understand it might be to check out a few strategies on here using pipsize and / or check out the links below?

    https://www.prorealcode.com/topic/pipsize-confusion/

    aland thanked this post
    #91854 quote
    aland
    Participant
    Average

    this seems to be exactly what I need and I know it is right in front of me but I can’t find any code example on how to use it.

    on this forum I could not find a search button, on the web there is no ref and in the documentation is says that a pip size is a pipsize 🙂

    tries this for example:

    BUY stakeSizeLong*pipsize CONTRACTS AT myBuyprice stop

    tried division too, but since I have no clue how to actually use it I am flying blind…

    any code example that uses this would be a great help

    Thanks

    #91856 quote
    aland
    Participant
    Average

    to be clear, this:

    BUY stakeSizeLong*pipsize CONTRACTS AT myBuyprice stop

    gives me too much leverage and I am unable to reduce the leverage (would like only 0.01 of it really)

    no matter what number I plug in the stakeSize my position defaults to 1 and the leverage is too big

    #91865 quote
    GraHal
    Participant
    Master

    Mmmm I’ve just spent nearly 15 mins trying to find a simple code snippet on here  or info on the net and I agree it’s not easy! 🙂

    A lot of info is too complex for what it’s worth as once you get the hang of it, we kinda take pips for granted etc.

    Anyway have a scan read of the link below. Babypips is a good easy to follow website generally so you may use it again so not time wasted.

    https://www.babypips.com/learn/forex/pips-and-pipettes

    PS I’ll have a go at getting your code going and post on your other Topic.


    @RobertoGozzi
    could spot the issue in an instant! 🙂

    aland thanked this post
    #91870 quote
    aland
    Participant
    Average

    thanks GraHal I really appreciate your help and effort put into answering my question!

    I will look into the link you sent me, however looking at it from another angle I am not totally sure that is the issue, as I use the graph command and do see that the buy and sell order are correct and are triggered correctly. the only thing that doesn’t work for me is the stackSize that is ignored when it is lower to 1 and is just defaulted to one no matter if I insert 0.000001 as a stackSize parameter.

    maybe it is somewhere in the settings? or maybe it is pipvalue/pipsize but I am not using it correctly there

    #91871 quote
    GraHal
    Participant
    Master

    You would not use

    BUY stakeSizeLong*pipsize CONTRACTS AT myBuyprice stop

    But you might use

    BUY stakeSizeLong CONTRACTS AT (myBuyprice+10*pipsize) stop
    #91872 quote
    robertogozzi
    Moderator
    Master

    using “*pipsize” converts a price into pips, usually by dividing the price by 10000, since 1 pip=1/10000th of the price (on Dax and other instruments the divisor is 1, not 10000).

    To retain a value > 1 stakeSizeLong should be at least 20000!

    If you change instrument and switch from Eur to Jpy you can only manually adjust your capital to match that required by the FX pair.

    aland thanked this post
    #91873 quote
    GraHal
    Participant
    Master

    the stackSize that is ignored when it is lower to 1

    What is the minimum lot size on the market you are trading??

    It is probably 1 ? 🙂

    aland thanked this post
    #91875 quote
    robertogozzi
    Moderator
    Master

    Sorry, I can’t edit my post, the first line should read “using “*pipsize” converts pips into price”.

    Dividing a price by pipsize is the other way round.

    #91879 quote
    aland
    Participant
    Average

    Thanks guys for your help.

    I shared parts of my code here, maybe it would make sense:

    using floating point in FX markets?

     

    the stackSize I need in a market such as EUR/JPY using 1yy.yyyy is usually 0.1-0.9 – i tried to manually plug 0.5 as a stacksize but still get 1. So I don’t know how to avoid this problem.

    I do NOT have problems with the entry or exit points, everything else seems to work fine with out the pips so I don’t think “BUY stakeSizeLong CONTRACTS AT (myBuyprice+10*pipsize) stop” will help here. the amount of the order price is correct without the pips…

    All this is new to me, so I am a bit confused as the same code worked perfectly well in DJI and also in GBP/USD where the price format is different.

    Thanks again!

    #91881 quote
    robertogozzi
    Moderator
    Master

    I was talking about your example “BUY stakeSizeLong*pipsize CONTRACTS AT myBuyprice stop”.

    #91882 quote
    GraHal
    Participant
    Master

    so I don’t think “BUY stakeSizeLong CONTRACTS AT (myBuyprice+10*pipsize) stop” will help here

    I was providing an example of the use of pipsize, not suggesting that you need / include above in your code.

    tried to manually plug 0.5 as a stacksize but still get 1

    1 is the minimum lot size on my Platform on EUR/JPY.

    #91883 quote
    GraHal
    Participant
    Master

    1 is the minimum lot size on my Platform on EUR/JPY.

    See attached … it shows in red when the Lot size is not allowed!

    Aland-6.jpg Aland-6.jpg
    #91890 quote
    aland
    Participant
    Average

    Thanks again guys, your great!

    I have a feeling we are going in the wrong direction though…

    Here is my problem again, this time with images.

    I am using a working test code that takes a “normal” stack size (1-4 lots in the example in the image) but when I run the code my account of 10K is depleted within days because the value of each pip is huge.

    I tried reducing the stackSize hoping it would work but it doesn’t (can’t go under 1.0)

    as you can see my screen shows a totally different Sell/Buy pair then yours GraHal. you seem to see it in 1xxxx.x format but I see 1xx.xxx which I believe is the cause of the problem. I just searched for EUR/JPY  – should I have looked under a different market name?

     

    I am hoping the images would help you see how 10 trades totally deplete my account (I would want any loss to be less than 500 EUROS in this case)

    EUR_JPY_PROBLEM2.jpg EUR_JPY_PROBLEM2.jpg EUR_JPY_PROBLEM1.jpg EUR_JPY_PROBLEM1.jpg
Viewing 15 posts - 1 through 15 (of 22 total)
  • You must be logged in to reply to this topic.

how to change code between FX markets


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
aland @aland Participant
Summary

This topic contains 21 replies,
has 3 voices, and was last updated by GraHal
7 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/20/2019
Status: Active
Attachments: 4 files
Logo Logo
Loading...