Script stops buying in high volume or sudden movements
Forums › ProRealTime English forum › ProOrder support › Script stops buying in high volume or sudden movements
- This topic has 22 replies, 5 voices, and was last updated 6 years ago by
GraHal.
-
-
09/11/2019 at 4:33 PM #107219
Hi,
I need urgent help on this. My scripts start stopping during high volume in a market or sudden up & down movements.
I run this script with a time interval of 1 min. Every time there is a high volume the script stops buying or selling. It does not stop it just does not open a new position. I have run in the test environment with different time intervals and also these scripts stop at a high volume, like with an opening of a trading window.
Thanks for your help
Greeting, Hubert Simonis
Russell 2000 1 min script - stop with high volume or sudden movements1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556DEFPARAM CumulateOrders = FALSE// INPUTSTARTTIME = 000000ENDTIME = 220000EURO = 1.10415EXPOEURO = 7500PRO = 0.1LOS = 0.2// CALCULATIONSMAXLOSS = ((EXPOEURO / 100) * -1)EXPOSURE = (EXPOEURO * EURO)TRAIL = LOS * (EXPOSURE /100)NUMBEROFCONTRACTS = (EXPOSURE / Open ) * (1 / POINTVALUE)// CONDITIONSCondition0 = not onmarket and strategyprofit = 0Condition1 = not onmarket and positionperf(1) >= 0 and longonmarket[1]Condition2 = not onmarket and positionperf(1) < 0 and shortonmarket[1]Condition3 = not onmarket and positionperf(1) < 0 and longonmarket[1]Condition4 = not onmarket and positionperf(1) >= 0 and shortonmarket[1]Condition5 = strategyprofit < MAXLOSSCondition6 = currenttime >= starttime and currenttime <=endtimeif Condition0 and Condition6 or Condition1 and Condition6 or Condition2 and Condition6 thenBuy NUMBEROFCONTRACTS CONTRACTS AT MARKETendifif Condition3 and Condition6 or condition4 and Condition6 thenSELLSHORT NUMBEROFCONTRACTS CONTRACTS AT MARKETendifif Condition5 thenQUITendif// STOPSSET STOP $TRAILING TRAILSET TARGET %PROFIT PRO09/12/2019 at 9:23 AM #107324I can’t see any reference to VOLUME, is there any missing code?
09/12/2019 at 10:09 AM #107336Hi Robert,
Thanks for your reply.
There is no volume statement in the script. The uploaded script is the whole script.
During a high volume it looks like orders get cancelled and no new order is created.
The script continues to run but without any others in the market.
Due to this I have no order when there is a nice rally.
Please let me know any advise.
09/12/2019 at 10:15 AM #10733809/12/2019 at 10:42 AM #107342For Forex pairs IG does not return volumes, at present.
Your calculations of your position size seems to be incorrect, yielding over 737 contracts!
If you add these line at the end of your code:
12345678910111213graph prograph maxlossgraph exposuregraph trailgraph numberofcontractsgraph strategyprofitgraph condition0graph condition1graph condition2graph condition3graph condition4graph condition5graph condition6you’ll be able to GRAPH all variables needed to debug your code to be able to detect errors, by watching the VARIABLES’ window in ProBackTest.
The problem is not in spikes, but in some of your calculations.
09/12/2019 at 11:43 AM #107347Hi Robert and Nicolas,
Big thank you for the tips (still learning how to code 🙂
I am running the script on Russell 2000 and in this case the number of contract calculation is correct (0.53 contracts).
The results of the script are quite good I would say.
% Winning Trades 70%
Gain / Loss 1.17
Time interval 1 min
I would be surprised it the error is just the misses parenthesis but I have updated the script and run it in demo, so lets see what happens when Russell 2000 opens today (15:30 local time Netherlands).
Yesterday evening I created a simple version of the script to see if that runs better.
Would this script be ok ? Any tips ?
Index Mix R2000 - SIMPLE v11234567891011121314151617181920212223242526272829303132//-------------------------------------------------------------------------// Main code : Index Mix R2000 - SIMPLE v1//-------------------------------------------------------------------------DEFPARAM CumulateOrders = FALSEDEFPARAM FLATBEFORE = 000000DEFPARAM FLATAFTER = 220000Condition0 = not onmarket and strategyprofit = 0Condition1 = not onmarket and positionperf(1) >= 0 and longonmarket[1]Condition2 = not onmarket and positionperf(1) < 0 and shortonmarket[1]Condition3 = not onmarket and positionperf(1) < 0 and longonmarket[1]Condition4 = not onmarket and positionperf(1) >= 0 and shortonmarket[1]if Condition0 or Condition1 or Condition2 thenBuy 0.53 CONTRACTS AT MARKETendifif Condition3 or condition4 thenSELLSHORT 0.53 CONTRACTS AT MARKETendifif strategyprofit < -75 thenQUITendifSET STOP $TRAILING 16.665SET TARGET $PROFIT 8.333Greetings Hubert
09/12/2019 at 3:44 PM #107360Hi,
Update after the Russell 2000 trading window opening of today ; only the scripts that used the 5 sec timeframe survived the first few hours. Rest stopped opening orders.
I am fine with the 5 sec interval but i am still wondering how this is possible, any thoughts ?
I am updated my code in the following way.
Any tips are highly appreciated. Many thanks
Russell 2000 short & long - 5 sec timeframe12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758DEFPARAM CumulateOrders = FALSEtimeframe (5 seconds)// INPUTSTARTTIME = 000000ENDTIME = 220000EURO = 1.105222EXPOEURO = 7500PRO = 0.1LOS = 0.2// CALCULATIONSMAXLOSS = ((EXPOEURO / 100) * -1.5)EXPOSURE = (EXPOEURO * EURO)TRAIL = LOS * (EXPOSURE /100)NUMBEROFCONTRACTS = (EXPOSURE / Open ) * (1 / POINTVALUE)// CONDITIONSCondition0 = not onmarket and strategyprofit = 0Condition1 = not onmarket and positionperf(1) >= 0 and longonmarket[1]Condition2 = not onmarket and positionperf(1) < 0 and shortonmarket[1]Condition3 = not onmarket and positionperf(1) < 0 and longonmarket[1]Condition4 = not onmarket and positionperf(1) >= 0 and shortonmarket[1]Condition5 = strategyprofit < MAXLOSSCondition6 = currenttime >= starttime and currenttime < endtimeif (Condition0 and Condition6) or (Condition1 and Condition6) or (Condition2 and Condition6) thenBuy NUMBEROFCONTRACTS CONTRACTS AT MARKETendifif (Condition3 and Condition6) or (condition4 and Condition6) thenSELLSHORT NUMBEROFCONTRACTS CONTRACTS AT MARKETendifif Condition5 thenQUITendif// STOPSSET STOP $TRAILING TRAILSET TARGET %PROFIT PRO09/12/2019 at 4:17 PM #107364Line 3 is useless, just run it from a 5-second TF, since you are not using multiple TF’s.
09/12/2019 at 4:33 PM #107367ProOrder needs 1 bar to update the (Long/Short)OnMarket status, so when a trade opens and closes on the same bar your conditions are impossible to be verified.
09/12/2019 at 6:25 PM #10737709/12/2019 at 8:15 PM #107387Check not be OnMarket now and not to have been the previous bar, still STRATEGYPROFIT is different because a trade opened and closed on the same bar:
123IF Not OnMarket AND Not OnMarket[1] AND StrategyProfit <> StrategyProfit[1] THEN. //do whatever you need toENDIF09/12/2019 at 9:24 PM #10739009/13/2019 at 11:07 AM #107432Hi Robert,
I worked till late on my script and finally I found it out.
The system doesn’t get stuck anymore and the back test results are very good (last 2 weeks) but also in the very bear week of 26 August.
Russel 2000 - 1 Min timeframe1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798DEFPARAM CumulateOrders = FALSE// Russell 2000// Timeframe 1 min// INPUTSTARTTIME = 000000ENDTIME = 220000EURO = 1.10989EXPOEURO = 7500PRO = 0.04LOS = 1.5// CALCULATIONSMAXLOSS = ((EXPOEURO / 100) * -5)EXPOSURE = (EXPOEURO * EURO)TRAIL = LOS * (EXPOSURE /100)NUMBEROFCONTRACTS = (EXPOSURE / Open ) * (1 / POINTVALUE)// CONDITIONSNOTTRADING = not onmarketWINDOW = currenttime >= starttime and currenttime <= endtimeSAMEBAR = tradeindex = barindexOTHERBAR = tradeindex < barindexMOREPROFIT = strategyprofit >= strategyprofit[1]LESSPROFIT = strategyprofit < strategyprofit[1]NOPROFIT = strategyprofit = 0LASTLONG = longonmarket[1]LASTSHORT = shortonmarket[1]CURRENTshort = (Average[20](close) >= Average[50](close))CURRENTlong = (Average[20](close) < Average[50](close))FIRSTORDER = NOTTRADING and window and NOPROFITCONTINUELONG = NOTTRADING and window and OTHERBAR and MOREPROFIT and LASTLONGSWITCHLONG = NOTTRADING and window and OTHERBAR and LESSPROFIT and LASTSHORTSWITCHSHORT = NOTTRADING and window and OTHERBAR and LESSPROFIT and LASTLONGCONTINUESHORT = NOTTRADING and window and OTHERBAR and MOREPROFIT and LASTSHORTCONTINUESAMEBAR = NOTTRADING and window and SAMEBARCONTINUELONGINBAR = CONTINUESAMEBAR and CURRENTLONGCONTINUESHORTINBAR = CONTINUESAMEBAR and CURRENTSHORTif not firstorder and not continuelong and not switchlong and not switchshort and not continueshort and not continuelonginbar and not continueshortinbar thenCONTINUELONG = NOTTRADING and window and OTHERBAR and CURRENTlongCONTINUESHORT = NOTTRADING and window and OTHERBAR and CURRENTshortendifif FIRSTORDER or CONTINUELONG or SWITCHLONG or CONTINUELONGINBAR thenBuy NUMBEROFCONTRACTS CONTRACTS AT MARKETendifif SWITCHSHORT or CONTINUESHORT or CONTINUESHORTINBAR thenSELLSHORT NUMBEROFCONTRACTS CONTRACTS AT MARKETendifif strategyprofit < MAXLOSS thenQUITendif// STOPSSET STOP $TRAILING TRAILSET TARGET %PROFIT PRO//graph window//graph NOTTRADING//graph OTHERBAR//graph SAMEBAR//graph MOREPROFIT//graph LESSPROFIT//graph LASTLONG//graph LASTSHORT//graph FIRSTORDER//graph CONTINUELONG//graph SWITCHLONG//graph CONTINUELONGINBAR//graph SWITCHSHORT//graph CONTINUESHORT//graph CONTINUESHORTINBAR09/13/2019 at 11:36 AM #107438With orders AT MARKET it’s easy, if you place a BUY order then you know it’s a LONG trade, if it’s a SELLSHORT then you place a SHORT order.
If it’s a pending order you can reference STRATEGYPROFIT to tell whether it was a winning or losing strategy, then check the prior two TRADEPRICE to tell if it was a Long or a Short trade.
09/13/2019 at 12:26 PM #107447 -
AuthorPosts
Find exclusive trading pro-tools on