Use indices strategy for forex

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #23092 quote
    RoLaDay
    Participant
    Average

    Hello,

    I wanna use my indices strategy for forex too.

    Can someone tell me what I have to do to make it work for the forex markets?

    Thanks a lot!

    #23114 quote
    Nicolas
    Keymaster
    Master

    Depends of the strategies’ codes of course.

    But you should adapt trading schedules and points calculation (if you use some points values in your code), these are the common things to change first. If you can post a code example, I’ll teach you how 🙂

    #23195 quote
    RoLaDay
    Participant
    Average

    Hello,

    this is the code I try to change:

    defparam cumulateorders = false
    defparam flatafter = 220000
    defparam flatbefore = 080000
    
    if dayofweek=2 then // Tuesday
    daytrading=1
    
    if dayofweek=5 then // Friday
    daytrading=1
    endif
    
    if time =072500 then
    myhigh=high
    mylow=low
    countB=0
    countS=0
    
    
    elsif time >072500 and time <= 080000 then 
    
    myhigh=max(high,myhigh)
    mylow=min(low,mylow)
    TRIGGERLONG=myhigh*pointsize
    TRIGGERSHORT=mylow*pointsize
    OPENRANGE=(myhigh-mylow)*pointsize
    entrylong=TRIGGERLONG+OPENRANGE
    entryshort = TRIGGERSHORT-OPENRANGE
    currentdate=date
    endif
    
    if longonmarket and positionprice<>lastpriceS then
    countS = countS+1
    lastpriceS = positionprice
    endif
    
    if shortonmarket and positionprice<>lastpriceB then
    countB = countB+1
    lastpriceB = positionprice
    endif
    
    if date=currentdate and time >080000 and time <=185500 then
    
    If not longonmarket and daytrading=1 and countS=0 and close < entrylong then
    buy 1 shares at entrylong STOP
    set stop ploss openrange*3.0
    set target profit openrange*1.0
    
    if not shortonmarket and daytrading=1 and countB=0 and close > entryshort then
    sellshort 1 shares at entryshort STOP
    set stop ploss  openrange*3.0
    set target profit openrange*1.0
    
    
    endif
    endif
    endif
    
    #23205 quote
    Nicolas
    Keymaster
    Master

    I do not see anything to be adapted for forex trading, but there are wrong copy/paste or you have modified things in the strategy code, so that now the conditional statements don’t follow any logic.

    I modified the code to be correct I think, I did not test it.. Your job 🙂 Here it is:

    defparam cumulateorders = false
    defparam flatafter = 220000
    defparam flatbefore = 080000
    
    if dayofweek=2 then // Tuesday
    daytrading=1
    endif
    
    if dayofweek=5 then // Friday
    daytrading=1
    endif
    
    if time =072500 then
    myhigh=high
    mylow=low
    countB=0
    countS=0
    
    
    elsif time >072500 and time <= 080000 then
    
    myhigh=max(high,myhigh)
    mylow=min(low,mylow)
    TRIGGERLONG=myhigh*pointsize
    TRIGGERSHORT=mylow*pointsize
    OPENRANGE=(myhigh-mylow)*pointsize
    entrylong=TRIGGERLONG+OPENRANGE
    entryshort = TRIGGERSHORT-OPENRANGE
    currentdate=date
    endif
    
    if longonmarket and positionprice<>lastpriceS then
    countS = countS+1
    lastpriceS = positionprice
    endif
    
    if shortonmarket and positionprice<>lastpriceB then
    countB = countB+1
    lastpriceB = positionprice
    endif
    
    if date=currentdate and time >080000 and time <=185500 then
    
    If not longonmarket and daytrading=1 and countS=0 and close < entrylong then
    buy 1 shares at entrylong STOP
    endif
    
    if not shortonmarket and daytrading=1 and countB=0 and close > entryshort then
    sellshort 1 shares at entryshort STOP
    endif
    
    endif
    
    set stop ploss openrange*3.0
    set target profit openrange*1.0
    #23242 quote
    RoLaDay
    Participant
    Average

    The code works like before… does that mean it wouldn’t have worked for AutoTrading? So I always have to put stop loss and target profit at the bottom?

    So it’s not possible to use the code for forex?

    #23246 quote
    Nicolas
    Keymaster
    Master

    This code can be of course used for forex trading. Like I said, I don’t see anything that could not worked on this type of instrument.

    Just saw a mistake on the STOP LOSS instruction, you should replace the line 54 with this one instead:

    set stop loss openrange*3.0
    #23771 quote
    RoLaDay
    Participant
    Average

    The code works now, thanks a lot!

    Now I have one more question: Is there a possibility that the strategy buys or sells as soon as the price reaches entrylong/entryshort?

    At the moment the strategy buys when the next candle reaches entrylong/entryshort after the close was below or above entrylong/entryshort.

    So is there another code for “close” when I want to buy exactly when entryshort or -long is reached the first time?

    close > entryshort
    #24075 quote
    Nicolas
    Keymaster
    Master

    This strategy should already buy at exact prices of “entrylong” and “entryshort”, because it uses STOP pending orders at these levels. Or maybe I do not understood well your question?

    #24129 quote
    RoLaDay
    Participant
    Average

    Yes it buys at exact prices, but not when the price is triggered the first time! It buys when it’s triggered the second time.

    For example if say buy 1 share at entrylong Stop and entrylong Stop is at 10.000 points, the strategy buys when the course already was over 10.000 points and comes back to 10.000 points at another candle.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Use indices strategy for forex


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
RoLaDay @roladay Participant
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by RoLaDay
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/30/2017
Status: Active
Attachments: No files
Logo Logo
Loading...