Use indices strategy for forex
Forums › ProRealTime English forum › ProOrder support › Use indices strategy for forex
- This topic has 8 replies, 2 voices, and was last updated 7 years ago by RoLaDay.
-
-
01/30/2017 at 2:13 PM #2309201/30/2017 at 4:58 PM #23114
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 🙂
01/31/2017 at 9:29 AM #23195Hello,
this is the code I try to change:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556defparam cumulateorders = falsedefparam flatafter = 220000defparam flatbefore = 080000if dayofweek=2 then // Tuesdaydaytrading=1if dayofweek=5 then // Fridaydaytrading=1endifif time =072500 thenmyhigh=highmylow=lowcountB=0countS=0elsif time >072500 and time <= 080000 thenmyhigh=max(high,myhigh)mylow=min(low,mylow)TRIGGERLONG=myhigh*pointsizeTRIGGERSHORT=mylow*pointsizeOPENRANGE=(myhigh-mylow)*pointsizeentrylong=TRIGGERLONG+OPENRANGEentryshort = TRIGGERSHORT-OPENRANGEcurrentdate=dateendifif longonmarket and positionprice<>lastpriceS thencountS = countS+1lastpriceS = positionpriceendifif shortonmarket and positionprice<>lastpriceB thencountB = countB+1lastpriceB = positionpriceendifif date=currentdate and time >080000 and time <=185500 thenIf not longonmarket and daytrading=1 and countS=0 and close < entrylong thenbuy 1 shares at entrylong STOPset stop ploss openrange*3.0set target profit openrange*1.0if not shortonmarket and daytrading=1 and countB=0 and close > entryshort thensellshort 1 shares at entryshort STOPset stop ploss openrange*3.0set target profit openrange*1.0endifendifendif01/31/2017 at 10:29 AM #23205I 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:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455defparam cumulateorders = falsedefparam flatafter = 220000defparam flatbefore = 080000if dayofweek=2 then // Tuesdaydaytrading=1endifif dayofweek=5 then // Fridaydaytrading=1endifif time =072500 thenmyhigh=highmylow=lowcountB=0countS=0elsif time >072500 and time <= 080000 thenmyhigh=max(high,myhigh)mylow=min(low,mylow)TRIGGERLONG=myhigh*pointsizeTRIGGERSHORT=mylow*pointsizeOPENRANGE=(myhigh-mylow)*pointsizeentrylong=TRIGGERLONG+OPENRANGEentryshort = TRIGGERSHORT-OPENRANGEcurrentdate=dateendifif longonmarket and positionprice<>lastpriceS thencountS = countS+1lastpriceS = positionpriceendifif shortonmarket and positionprice<>lastpriceB thencountB = countB+1lastpriceB = positionpriceendifif date=currentdate and time >080000 and time <=185500 thenIf not longonmarket and daytrading=1 and countS=0 and close < entrylong thenbuy 1 shares at entrylong STOPendifif not shortonmarket and daytrading=1 and countB=0 and close > entryshort thensellshort 1 shares at entryshort STOPendifendifset stop ploss openrange*3.0set target profit openrange*1.001/31/2017 at 12:09 PM #2324201/31/2017 at 12:41 PM #23246This 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:
1set stop loss openrange*3.002/03/2017 at 12:04 PM #23771The 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?
1close > entryshort02/06/2017 at 11:56 AM #2407502/06/2017 at 5:04 PM #24129Yes 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.
-
AuthorPosts
Find exclusive trading pro-tools on